Skip to content

Instantly share code, notes, and snippets.

@ferblape
Created October 30, 2010 16:44
Show Gist options
  • Save ferblape/655494 to your computer and use it in GitHub Desktop.
Save ferblape/655494 to your computer and use it in GitHub Desktop.
geo_ruby samples of code
require 'rubygems'
require 'geo_ruby'
# http://georuby.rubyforge.org/georuby-doc/index.html
point = GeoRuby::SimpleFeatures::Point.from_lon_lat(-3.726489543914795, 40.453423411115494)
puts point.y
puts point.x
puts point.as_kml
puts point.as_wkt
# => "POINT(-71 33.2)"
bar = GeoRuby::SimpleFeatures::Point.from_lon_lat(-3.7259557843208313, 40.45303562320312)
bar.euclidian_distance(point)
subway = GeoRuby::SimpleFeatures::Point.from_lon_lat(3.726789951324463, 40.44353412028846)
subway.euclidian_distance(point)
conference_points = GeoRuby::SimpleFeatures::Polygon.from_points([[point, bar, subway]])
conference_points.as_wkt
# => "POLYGON((-3.72648954391479 40.4534234111155,-3.72595578432083 40.4530356232031,3.72678995132446 40.4435341202885))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment