Module: RGeo::ImplHelper::BasicLineStringMethods
- Included in:
- Cartesian::LineImpl, Cartesian::LineStringImpl, Cartesian::LinearRingImpl, Geographic::ProjectedLineImpl, Geographic::ProjectedLineStringImpl, Geographic::ProjectedLinearRingImpl, Geographic::SphericalLineImpl, Geographic::SphericalLineStringImpl, Geographic::SphericalLinearRingImpl
- Defined in:
- lib/rgeo/impl_helper/basic_line_string_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #_validate_geometry ⇒ Object
- #boundary ⇒ Object
- #dimension ⇒ Object
- #end_point ⇒ Object
- #eql?(rhs_) ⇒ Boolean
- #geometry_type ⇒ Object
- #initialize(factory_, points_) ⇒ Object
- #is_closed? ⇒ Boolean
- #is_empty? ⇒ Boolean
- #is_ring? ⇒ Boolean
- #num_points ⇒ Object
- #point_n(n_) ⇒ Object
- #points ⇒ Object
- #start_point ⇒ Object
Instance Method Details
#_validate_geometry ⇒ Object
58 59 60 61 62 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 58 def _validate_geometry if @points.size == 1 raise Error::InvalidGeometry, 'LineString cannot have 1 point' end end |
#boundary ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 104 def boundary array_ = [] if !is_empty? && !is_closed? array_ << @points.first << @points.last end factory.multi_point([array_]) end |
#dimension ⇒ Object
89 90 91 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 89 def dimension 1 end |
#end_point ⇒ Object
118 119 120 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 118 def end_point @points.last end |
#eql?(rhs_) ⇒ Boolean
65 66 67 68 69 70 71 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 65 def eql?(rhs_) if rhs_.is_a?(self.class) && rhs_.factory.eql?(@factory) && @points.size == rhs_.num_points rhs_.points.each_with_index{ |p_, i_| return false unless @points[i_].eql?(p_) } else false end end |
#geometry_type ⇒ Object
94 95 96 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 94 def geometry_type Feature::LineString end |
#initialize(factory_, points_) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 45 def initialize(factory_, points_) _set_factory(factory_) @points = points_.map do |elem_| elem_ = Feature.cast(elem_, factory_, Feature::Point) unless elem_ raise Error::InvalidGeometry, "Could not cast #{elem_}" end elem_ end _validate_geometry end |
#is_closed? ⇒ Boolean
123 124 125 126 127 128 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 123 def is_closed? unless defined?(@is_closed) @is_closed = @points.size > 2 && @points.first == @points.last end @is_closed end |
#is_empty? ⇒ Boolean
99 100 101 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 99 def is_empty? @points.size == 0 end |
#is_ring? ⇒ Boolean
131 132 133 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 131 def is_ring? is_closed? && is_simple? end |
#num_points ⇒ Object
74 75 76 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 74 def num_points @points.size end |
#point_n(n_) ⇒ Object
79 80 81 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 79 def point_n(n_) @points[n_] end |
#points ⇒ Object
84 85 86 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 84 def points @points.dup end |
#start_point ⇒ Object
113 114 115 |
# File 'lib/rgeo/impl_helper/basic_line_string_methods.rb', line 113 def start_point @points.first end |