Created
January 21, 2015 18:32
Revisions
-
dodecaphonic created this gist
Jan 21, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ require "rgeo" WGS84 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" WGS84_UTM = "+proj=utm +zone=22 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs" x0, y0 = -48.10311146131618, -15.894902327065926 x1, y1 = -48.103022948419394, -15.894858472899413 mercator = RGeo::Geographic.simple_mercator_factory geographic = RGeo::Geographic.projected_factory(projection_proj4: WGS84) spherical = RGeo::Geographic.spherical_factory utm = RGeo::Geographic.projected_factory(projection_proj4: WGS84_UTM) p0m = mercator.point(x0, y0) p1m = mercator.point(x1, y1) p0g = geographic.point(x0, y0) p1g = geographic.point(x1, y1) p0s = spherical.point(x0, y0) p1s = spherical.point(x1, y1) p0u = utm.point(x0, y0) p1u = utm.point(x1, y1) p0ul = utm.point(x0, y0).projection p1ul = utm.point(x1, y1).projection dist = Math.sqrt((p1ul.x - p0ul.x)**2 + (p1ul.y - p0ul.y)**2) puts "Mercator: #{p0m.distance(p1m)}" puts "Geographic: #{p0g.distance(p1g) * 111_300}" puts "Spherical: #{p0s.distance(p1s)}" puts "UTM: #{p0u.distance(p1u)}" puts "UTM Linear: #{dist}"