Module: RGeo::ImplHelper::BasicLineMethods
- Defined in:
- lib/rgeo/impl_helper/basic_line_string_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#_validate_geometry ⇒ Object
:nodoc:.
- #coordinates ⇒ Object
- #geometry_type ⇒ Object
- #initialize(factory_, start_, end_) ⇒ Object
Instance Method Details
#_validate_geometry ⇒ Object
: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 |
#coordinates ⇒ Object
124 125 126 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 124 def coordinates @points.map(&:coordinates) end |
#geometry_type ⇒ Object
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 |