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
#arcs ⇒ Object
94 95 96 97 98 |
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 94 def arcs @arcs ||= (0..num_points - 2).map do |i| SphericalMath::ArcXYZ.new(point_n(i).xyz, point_n(i + 1).xyz) end end |
#is_simple? ⇒ Boolean
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 100 def is_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 |
#length ⇒ Object
123 124 125 |
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 123 def length arcs.inject(0.0) { |sum, arc| sum + arc.length } * SphericalMath::RADIUS end |