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:



113
114
115
116
117
118
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 113

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

#coordinatesObject



124
125
126
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 124

def coordinates
  @points.map(&:coordinates)
end

#geometry_typeObject



120
121
122
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 120

def geometry_type
  Feature::Line
end

#initialize(factory_, start_, end_) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 101

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)
  raise Error::InvalidGeometry, "Could not cast end: #{end_}" unless cend_
  @points = [cstart_, cend_]
  _validate_geometry
end