Class: CloudMade::MultiPolygon

Inherits:
Geometry
  • Object
show all
Defined in:
lib/cloudmade/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

parse

Constructor Details

#initialize(coords) ⇒ MultiPolygon

Returns a new instance of MultiPolygon.



144
145
146
# File 'lib/cloudmade/geometry.rb', line 144

def initialize(coords)
  @polygons = coords.map { |poly_coords| Polygon.new(poly_coords) }
end

Instance Attribute Details

#polygonsObject

Returns the value of attribute polygons.



142
143
144
# File 'lib/cloudmade/geometry.rb', line 142

def polygons
  @polygons
end

Instance Method Details

#to_sObject



148
149
150
# File 'lib/cloudmade/geometry.rb', line 148

def to_s
  "MultiPolygon(#{@polygons.join(',')})"
end

#to_wktObject



152
153
154
# File 'lib/cloudmade/geometry.rb', line 152

def to_wkt
  "MULTIPOLYGON (#{wkt_helper})"
end

#wkt_helperObject



156
157
158
# File 'lib/cloudmade/geometry.rb', line 156

def wkt_helper
  @polygons.map { |polygon| "(#{polygon.wkt_helper})"}.join(', ')
end