class Geos::Point
Public Instance Methods
as_geojson(options = {})
click to toggle source
# File lib/geos/point.rb, line 113 def as_geojson(options = {}) { :type => 'Point', :coordinates => self.to_a } end
Also aliased as: to_geojsonable
as_json(options = {})
click to toggle source
Returns a Hash suitable for converting to JSON.
# File lib/geos/point.rb, line 103 def as_json(options = {}) cs = self.coord_seq if self.has_z? { :type => 'point', :lat => cs.get_y(0), :lng => cs.get_x(0), :z => cs.get_z(0) } else { :type => 'point', :lat => cs.get_y(0), :lng => cs.get_x(0) } 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/point.rb, line 122 def dump_points(cur_path = []) cur_path.push(self.dup) end
to_a()
click to toggle source
Returns the Point's coordinates as an Array in the following format:
[ x, y, z ]
The Z coordinate will only be present for Points which have a Z dimension.
# File lib/geos/point.rb, line 53 def to_a if defined?(@to_a) @to_a else cs = self.coord_seq @to_a = if self.has_z? [ cs.get_x(0), cs.get_y(0), cs.get_z(0) ] else [ cs.get_x(0), cs.get_y(0) ] end end end
to_georss(*args)
click to toggle source
Build some XmlMarkup for GeoRSS. You should include the appropriate georss and gml XML namespaces in your document.
# File lib/geos/point.rb, line 93 def to_georss(*args) xml = Geos::Helper.xml_options(*args)[0] xml.georss(:where) do xml.gml(:Point) do xml.gml(:pos, "#{self.lat} #{self.lng}") end end end
to_kml(*args)
click to toggle source
Build some XmlMarkup for KML. You can set KML options for extrude and altitudeMode. Use Rails/Ruby-style code and it will be converted appropriately, i.e. :altitude_mode, not :altitudeMode.
# File lib/geos/point.rb, line 82 def to_kml(*args) xml, options = Geos::Helper.xml_options(*args) xml.Point(:id => options[:id]) do xml.extrude(options[:extrude]) if options[:extrude] xml.altitudeMode(Geos::Helper.camelize(options[:altitude_mode])) if options[:altitude_mode] xml.coordinates(self.to_a.join(',')) end end
x()
click to toggle source
Returns the X coordinate of the Point
.
# File lib/geos/point.rb, line 23 def x self.to_a[0] end
y()
click to toggle source
Returns the Y coordinate of the Point
.
# File lib/geos/point.rb, line 8 def y self.to_a[1] end
z()
click to toggle source
Returns the Z coordinate of the Point
.
# File lib/geos/point.rb, line 38 def z if self.has_z? self.to_a[2] else nil end end