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



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

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)


154
155
156
157
158
159
160
161
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 154

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

#intersects?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
148
149
150
151
152
# File 'lib/rgeo/geographic/spherical_feature_methods.rb', line 145

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

#lengthObject



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

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

#simple?Boolean

Returns:

  • (Boolean)


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

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