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:



157
158
159
160
161
162
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 157

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

#geometry_typeObject



165
166
167
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 165

def geometry_type
  Feature::Line
end

#initialize(factory_, start_, end_) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 142

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