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
- #boundary ⇒ Object
- #contains?(rhs) ⇒ Boolean
- #coordinates ⇒ Object
- #geometry_type ⇒ Object
- #initialize(factory, elements) ⇒ Object
- #is_closed? ⇒ Boolean
- #length ⇒ Object
Instance Method Details
#boundary ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 98 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].odd? end factory.multipoint([array]) end |
#contains?(rhs) ⇒ Boolean
117 118 119 120 121 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 117 def contains?(rhs) return super unless Feature::Point === rhs @elements.any? { |line| line.contains?(rhs) } end |
#coordinates ⇒ Object
113 114 115 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 113 def coordinates @elements.map(&:coordinates) end |
#geometry_type ⇒ Object
86 87 88 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 86 def geometry_type Feature::MultiLineString end |
#initialize(factory, elements) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 76 def initialize(factory, elements) self.factory = factory @elements = elements.map do |elem| elem = Feature.cast(elem, factory, Feature::LineString, :keep_subtype) raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem elem end validate_geometry end |
#is_closed? ⇒ Boolean
90 91 92 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 90 def is_closed? all?(&:is_closed?) end |
#length ⇒ Object
94 95 96 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 94 def length @elements.inject(0.0) { |sum, obj| sum + obj.length } end |