Module: RGeo::ImplHelper::BasicMultiLineStringMethods
- Included in:
- Cartesian::MultiLineStringImpl, Geographic::ProjectedMultiLineStringImpl, Geographic::SphericalMultiLineStringImpl
- Defined in:
- lib/rgeo/impl_helper/basic_geometry_collection_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#_add_boundary(hash_, point_) ⇒ Object
:nodoc:.
- #boundary ⇒ Object
- #geometry_type ⇒ Object
- #initialize(factory_, elements_) ⇒ Object
- #is_closed? ⇒ Boolean
- #length ⇒ Object
Instance Method Details
#_add_boundary(hash_, point_) ⇒ Object
:nodoc:
138 139 140 141 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 138 def _add_boundary(hash_, point_) # :nodoc: hval_ = [point_.x, point_.y].hash (hash_[hval_] ||= [point_, 0])[1] += 1 end |
#boundary ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 144 def boundary hash_ = {} @elements.each do |line_| if !line_.is_empty? && !line_.is_closed? _add_boundary(hash_, line_.start_point) _add_boundary(hash_, line_.end_point) end end array_ = [] hash_.each do |hval_, data_| array_ << data_[0] if data_[1] % 2 == 1 end factory.multi_point([array_]) end |
#geometry_type ⇒ Object
123 124 125 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 123 def geometry_type Feature::MultiLineString end |
#initialize(factory_, elements_) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 110 def initialize(factory_, elements_) _set_factory(factory_) @elements = elements_.map do |elem_| elem_ = Feature.cast(elem_, factory_, Feature::LineString, :keep_subtype) unless elem_ raise Error::InvalidGeometry, "Could not cast #{elem_}" end elem_ end _validate_geometry end |
#is_closed? ⇒ Boolean
128 129 130 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 128 def is_closed? all?{ |elem_| elem_.is_closed? } end |
#length ⇒ Object
133 134 135 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 133 def length @elements.inject(0.0){ |sum_, obj_| sum_ + obj_.length } end |