class Charta::MultiPolygon

Represent a Geometry with contains only polygons

Public Instance Methods

each_polygon() { |polygon, index + 1| ... } click to toggle source
# File lib/charta/multi_polygon.rb, line 4
def each_polygon(&block)
  if block.arity == 1
    polygons.each(&block)
  elsif block.arity == 2
    polygons.each_with_index do |polygon, index|
      yield polygon, index + 1
    end
  else
    raise 'Cannot browse each polygon without parameter'
  end
end
polygons() click to toggle source

Extract polygons ordered by 'PointOnSurface' position

# File lib/charta/multi_polygon.rb, line 17
def polygons
  @polygons ||= feature.elements.map do |polygon|
    Polygon.new(polygon)
  end || []
end