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



167
168
169
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 167

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

#boundaryObject



171
172
173
174
175
176
177
178
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 171

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

#coordinatesObject



180
181
182
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 180

def coordinates
  @elements.map(&:coordinates)
end

#geometry_typeObject



163
164
165
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 163

def geometry_type
  Feature::MultiPolygon
end

#initialize(factory_, elements_) ⇒ Object



153
154
155
156
157
158
159
160
161
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 153

def initialize(factory_, elements_)
  _set_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
  _validate_geometry
end