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

Instance Method Details

#areaObject


237
238
239
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 237

def area
  @elements.inject(0.0){ |sum_, obj_| sum_ + obj_.area }
end

#boundaryObject


242
243
244
245
246
247
248
249
250
251
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 242

def boundary
  array_ = []
  @elements.each do |poly_|
    unless poly_.is_empty?
      array_ << poly_.exterior_ring
    end
    array_.concat(poly_.interior_rings)
  end
  factory.multi_line_string(array_)
end

#geometry_typeObject


232
233
234
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 232

def geometry_type
  Feature::MultiPolygon
end

#initialize(factory_, elements_) ⇒ Object


219
220
221
222
223
224
225
226
227
228
229
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 219

def initialize(factory_, elements_)
  _set_factory(factory_)
  @elements = elements_.map do |elem_|
    elem_ = Feature.cast(elem_, factory_, Feature::Polygon, :keep_subtype)
    unless elem_
      raise Error::InvalidGeometry, "Could not cast #{elem_}"
    end
    elem_
  end
  _validate_geometry
end