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



90
91
92
93
94
95
96
97
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 90

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)


99
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 99

def is_simple?
  arcs_ = _arcs
  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

#lengthObject



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