Class: Geos::GeometryCollection
- Inherits:
-
Object
- Object
- Geos::GeometryCollection
- Includes:
- Enumerable
- Defined in:
- lib/geos/yaml/syck.rb,
lib/geos/geometry_collection.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#[](*args) ⇒ Object
(also: #slice)
Returns the nth geometry from the collection.
- #as_geojson(options = {}) ⇒ Object (also: #to_geojsonable)
-
#as_json(options = {}) ⇒ Object
(also: #to_jsonable)
Returns a Hash suitable for converting to JSON.
-
#each ⇒ Object
Iterates the collection through the given block.
-
#last ⇒ Object
Returns the last geometry from the collection.
-
#to_georss(*args) ⇒ Object
Build some XmlMarkup for GeoRSS.
-
#to_kml(*args) ⇒ Object
Build some XmlMarkup for KML.
Instance Method Details
#[](*args) ⇒ Object Also known as: slice
Returns the nth geometry from the collection.
16 17 18 |
# File 'lib/geos/geometry_collection.rb', line 16 def [](*args) self.to_a[*args] end |
#as_geojson(options = {}) ⇒ Object Also known as: to_geojsonable
51 52 53 54 55 56 |
# File 'lib/geos/geometry_collection.rb', line 51 def as_geojson( = {}) { :type => 'GeometryCollection', :geometries => self.to_a.collect { |g| g.to_geojsonable() } } end |
#as_json(options = {}) ⇒ Object Also known as: to_jsonable
Returns a Hash suitable for converting to JSON.
28 29 30 31 32 |
# File 'lib/geos/geometry_collection.rb', line 28 def as_json( = {}) self.collect do |p| p.to_jsonable end end |
#each ⇒ Object
Iterates the collection through the given block.
8 9 10 11 12 13 |
# File 'lib/geos/geometry_collection.rb', line 8 def each self.num_geometries.times do |n| yield self.get_geometry_n(n) end nil end |
#last ⇒ Object
Returns the last geometry from the collection.
23 24 25 |
# File 'lib/geos/geometry_collection.rb', line 23 def last self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0 end |
#to_georss(*args) ⇒ Object
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.
47 48 49 |
# File 'lib/geos/geometry_collection.rb', line 47 def to_georss(*args) self.exterior_ring.to_georss(*args) end |
#to_kml(*args) ⇒ Object
Build some XmlMarkup for KML.
36 37 38 39 40 |
# File 'lib/geos/geometry_collection.rb', line 36 def to_kml(*args) self.collect do |p| p.to_kml(*args) end end |