class GeoRuby::SimpleFeatures::MultiPolygon

Represents a group of polygons (see Polygon).

Public Class Methods

from_coordinates(point_sequence_sequences, srid = DEFAULT_SRID, with_z = false, with_m = false) click to toggle source

Creates a multi polygon from sequences of points : ((((x,y)…(x,y)),((x,y)…(x,y)),((x,y)…(x,y)))

# File lib/geo_ruby/simple_features/multi_polygon.rb, line 48
def self.from_coordinates(point_sequence_sequences, srid = DEFAULT_SRID, with_z = false, with_m = false)
  multi_polygon = new(srid, with_z, with_m)
  multi_polygon.concat(point_sequence_sequences.collect { |point_sequences| Polygon.from_coordinates(point_sequences, srid, with_z, with_m) })
  multi_polygon
end
from_polygons(polygons, srid = DEFAULT_SRID, with_z = false, with_m = false) click to toggle source

Creates a multi polygon from an array of polygons

# File lib/geo_ruby/simple_features/multi_polygon.rb, line 41
def self.from_polygons(polygons, srid = DEFAULT_SRID, with_z = false, with_m = false)
  multi_polygon = new(srid, with_z, with_m)
  multi_polygon.concat(polygons)
  multi_polygon
end
new(srid = DEFAULT_SRID, _with_z = false, _with_m = false) click to toggle source
# File lib/geo_ruby/simple_features/multi_polygon.rb, line 7
def initialize(srid = DEFAULT_SRID, _with_z = false, _with_m = false)
  super(srid)
end

Public Instance Methods

as_json(_options = {}) click to toggle source
# File lib/geo_ruby/simple_features/multi_polygon.rb, line 35
def as_json(_options = {})
  { type: 'MultiPolygon',
    coordinates: to_coordinates }
end
points() click to toggle source
# File lib/geo_ruby/simple_features/multi_polygon.rb, line 15
def points
  @points ||= geometries.reduce([]) do |arr, r|
    arr.concat(r.rings.map(&:points).flatten)
  end
end
to_coordinates() click to toggle source
# File lib/geo_ruby/simple_features/multi_polygon.rb, line 31
def to_coordinates
  geometries.map(&:to_coordinates)
end