Module: RGeo::ImplHelper::BasicLineMethods

Included in:
Cartesian::LineImpl, Geographic::ProjectedLineImpl, Geographic::SphericalLineImpl
Defined in:
lib/rgeo/impl_helper/basic_line_string_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_validate_geometryObject

:nodoc:


171
172
173
174
175
176
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 171

def _validate_geometry  # :nodoc:
  super
  if @points.size > 2
    raise Error::InvalidGeometry, 'Line must have 0 or 2 points'
  end
end

#geometry_typeObject


179
180
181
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 179

def geometry_type
  Feature::Line
end

#initialize(factory_, start_, end_) ⇒ Object


156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 156

def initialize(factory_, start_, end_)
  _set_factory(factory_)
  cstart_ = Feature.cast(start_, factory_, Feature::Point)
  unless cstart_
    raise Error::InvalidGeometry, "Could not cast start: #{start_}"
  end
  cend_ = Feature.cast(end_, factory_, Feature::Point)
  unless cend_
    raise Error::InvalidGeometry, "Could not cast end: #{end_}"
  end
  @points = [cstart_, cend_]
  _validate_geometry
end