Module: RGeo::Geographic::ProjectedLineStringMethods

Included in:
ProjectedLineImpl, ProjectedLineStringImpl, ProjectedLinearRingImpl
Defined in:
lib/rgeo/geographic/projected_feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_validate_geometryObject


217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/rgeo/geographic/projected_feature_methods.rb', line 217

def _validate_geometry
  size_ = @points.size
  if size_ > 1
    last_ = @points[0]
    (1...size_).each do |i_|
      p_ = @points[i_]
      last_x_ = last_.x
      p_x_ = p_.x
      changed_ = true
      if p_x_ < last_x_ - 180.0
        p_x_ += 360.0 while p_x_ < last_x_ - 180.0
      elsif p_x_ > last_x_ + 180.0
        p_x_ -= 360.0 while p_x_ > last_x_ + 180.0
      else
        changed_ = false
      end
      if changed_
        p_ = factory.point(p_x_, p_.y)
        @points[i_] = p_
      end
      last_ = p_
    end
  end
  super
end