Module: RGeo::ImplHelper::BasicMultiPolygonMethods
- Included in:
- Cartesian::MultiPolygonImpl, Geographic::ProjectedMultiPolygonImpl, Geographic::SphericalMultiPolygonImpl
- Defined in:
- lib/rgeo/impl_helper/basic_geometry_collection_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #area ⇒ Object
- #boundary ⇒ Object
- #contains?(rhs) ⇒ Boolean
- #coordinates ⇒ Object
- #geometry_type ⇒ Object
- #initialize(factory, elements) ⇒ Object
Instance Method Details
#area ⇒ Object
173 174 175 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 173 def area @elements.inject(0.0) { |sum, obj| sum + obj.area } end |
#boundary ⇒ Object
177 178 179 180 181 182 183 184 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 177 def boundary array = [] @elements.each do |poly| array << poly.exterior_ring unless poly.empty? array.concat(poly.interior_rings) end factory.multi_line_string(array) end |
#contains?(rhs) ⇒ Boolean
190 191 192 193 194 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 190 def contains?(rhs) return super unless Feature::Point === rhs @elements.any? { |poly| poly.contains?(rhs) } end |
#coordinates ⇒ Object
186 187 188 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 186 def coordinates @elements.map(&:coordinates) end |
#geometry_type ⇒ Object
169 170 171 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 169 def geometry_type Feature::MultiPolygon end |
#initialize(factory, elements) ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 159 def initialize(factory, elements) self.factory = factory @elements = elements.map do |elem| elem = Feature.cast(elem, factory, Feature::Polygon, :keep_subtype) raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem elem end init_geometry end |