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



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/rgeo/geographic/projected_feature_methods.rb', line 153

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