Created
October 30, 2010 16:44
-
-
Save ferblape/655494 to your computer and use it in GitHub Desktop.
geo_ruby samples of code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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