Module: RGeo::Geographic::SphericalLineStringMethods

Included in:
SphericalLineImpl, SphericalLineStringImpl, SphericalLinearRingImpl
Defined in:
lib/rgeo/geographic/spherical_feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#arcsObject


111
112
113
114
115
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 111

def arcs
  @arcs ||= (0..num_points - 2).map do |i|
    SphericalMath::ArcXYZ.new(point_n(i).xyz, point_n(i + 1).xyz)
  end
end

#crosses?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

158
159
160
161
162
163
164
165
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 158

def crosses?(rhs)
  case rhs
  when Feature::LineString
    crosses_line_string?(rhs)
  else
    super
  end
end

#intersects?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

149
150
151
152
153
154
155
156
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 149

def intersects?(rhs)
  case rhs
  when Feature::LineString
    intersects_line_string?(rhs)
  else
    super
  end
end

#is_simple?Boolean

Returns:

  • (Boolean)

140
141
142
143
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 140

def is_simple?
  warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
  simple?
end

#lengthObject


145
146
147
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 145

def length
  arcs.inject(0.0) { |sum, arc| sum + arc.length } * SphericalMath::RADIUS
end

#simple?Boolean

Returns:

  • (Boolean)

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 117

def simple?
  len = arcs.length
  return false if arcs.any?(&:degenerate?)
  return true if len == 1
  return arcs[0].s != arcs[1].e if len == 2
  arcs.each_with_index do |arc, index|
    nindex = index + 1
    nindex = nil if nindex == len
    return false if nindex && arc.contains_point?(arcs[nindex].e)
    pindex = index - 1
    pindex = nil if pindex < 0
    return false if pindex && arc.contains_point?(arcs[pindex].s)
    next unless nindex
    oindex = nindex + 1
    while oindex < len
      oarc = arcs[oindex]
      return false if !(index == 0 && oindex == len - 1 && arc.s == oarc.e) && arc.intersects_arc?(oarc)
      oindex += 1
    end
  end
  true
end