Class: Geos::MultiPolygon

Inherits:
GeometryCollection show all
Defined in:
lib/geos/multi_polygon.rb

Instance Method Summary collapse

Methods inherited from GeometryCollection

#[], #as_json, #each, #last, #to_georss, #to_kml

Instance Method Details

#to_geojsonable(options = {}) ⇒ Object Also known as: as_geojson



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/geos/multi_polygon.rb', line 4

def to_geojsonable(options = {})
  options = {
    :interior_rings => true
  }.merge(options)

  {
    :type => 'MultiPolygon',
    :coordinates => self.to_a.collect { |polygon|
      coords = [ polygon.exterior_ring.coord_seq.to_a ]

      if options[:interior_rings] && polygon.num_interior_rings > 0
        coords.concat polygon.interior_rings.collect { |r|
          r.coord_seq.to_a
        }
      end

      coords
    }
  }
end