class Geos::GeometryCollection
Public Instance Methods
[](*args)
click to toggle source
Returns the nth geometry from the collection.
# File lib/geos/geometry_collection.rb, line 18 def [](*args) self.to_a[*args] end
as_geojson(options = {})
click to toggle source
# File lib/geos/geometry_collection.rb, line 53 def as_geojson(options = {}) { :type => 'GeometryCollection', :geometries => self.to_a.collect { |g| g.to_geojsonable(options) } } end
Also aliased as: to_geojsonable
as_json(options = {})
click to toggle source
Returns a Hash suitable for converting to JSON.
# File lib/geos/geometry_collection.rb, line 30 def as_json(options = {}) self.collect do |p| p.to_jsonable options end end
Also aliased as: to_jsonable
dump_points(cur_path = [])
click to toggle source
Dumps points similarly to the PostGIS `ST_DumpPoints` function.
# File lib/geos/geometry_collection.rb, line 62 def dump_points(cur_path = []) self.each do |geom| cur_path << geom.dump_points end cur_path end
each() { |get_geometry_n| ... }
click to toggle source
Iterates the collection through the given block.
# File lib/geos/geometry_collection.rb, line 10 def each self.num_geometries.times do |n| yield self.get_geometry_n(n) end nil end
last()
click to toggle source
Returns the last geometry from the collection.
# File lib/geos/geometry_collection.rb, line 25 def last self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0 end
to_georss(*args)
click to toggle source
Build some XmlMarkup for GeoRSS. Since GeoRSS is pretty trimed down, we just take the entire collection and use the exterior_ring as a Polygon
. Not to bright, mind you, but until GeoRSS stops with the suck, what are we to do. You should include the appropriate georss and gml XML namespaces in your document.
# File lib/geos/geometry_collection.rb, line 49 def to_georss(*args) self.exterior_ring.to_georss(*args) end
to_kml(*args)
click to toggle source
Build some XmlMarkup for KML.
# File lib/geos/geometry_collection.rb, line 38 def to_kml(*args) self.collect do |p| p.to_kml(*args) end end