Skip to content

Instantly share code, notes, and snippets.

@kenichi
Created April 18, 2014 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenichi/11068341 to your computer and use it in GitHub Desktop.
Save kenichi/11068341 to your computer and use it in GitHub Desktop.
# geographic postgis
>> DB.get :st.distance( :st.geogfromwkb( :st.makepoint(-122.6764, 45.5165) ), :st.geogfromwkb( :st.makepoint(-122.6864, 45.5265) ) )
=> 1358.549604392
# geomteric postgis (?)
>> DB.get :st.distance( :st.transform(:st.setsrid(:st.makepoint(-122.6764, 45.5165), 4326), 3857), :st.transform(:st.setsrid(:st.makepoint(-122.6864, 45.5265), 4326), 3857) )
=> 1939.9894392485
# terraformer ruby (using port of mapattack js gc distance)
>> Terraformer::Coordinate.new(-122.6764, 45.5165).great_circle_distance Terraformer::Coordinate.new(-122.6864, 45.5265)
=> 1357.7162840942958
# terraformer + mapattack js
> gc_distance(new tf.Point([-122.6764, 45.5165]), new tf.Point([-122.6864, 45.5265]));
1357.716284094343
@aaronpk
Copy link

aaronpk commented Apr 19, 2014

# redis-geo
> geoadd test 45.5165 -122.6764 a 45.5265 -122.6864 b
> georadius test 45.5165 -122.6764 1360 m withdistance
1) 1) "a"
   2) "0.13"
2) 1) "b"
   2) "1358.13"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment