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


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

def _arcs
  unless defined?(@arcs)
    @arcs = (0..num_points-2).map do |i_|
      SphericalMath::ArcXYZ.new(point_n(i_)._xyz, point_n(i_+1)._xyz)
    end
  end
  @arcs
end

#is_simple?Boolean

Returns:

  • (Boolean)

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 150

def is_simple?
  arcs_ = _arcs
  len_ = arcs_.length
  return false if arcs_.any?{ |a_| a_.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)
    if 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
  end
  true
end

#lengthObject


176
177
178
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 176

def length
  _arcs.inject(0.0){ |sum_, arc_| sum_ + arc_.length } * SphericalMath::RADIUS
end