Skip to content

Instantly share code, notes, and snippets.

@kenichi
Last active December 27, 2015 19:39
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/7378894 to your computer and use it in GitHub Desktop.
Save kenichi/7378894 to your computer and use it in GitHub Desktop.
geom geog
rgeo 0.8510518256839603 78198.3596190946
postgis 0.85105182568396 78189.9134208575

RGeo

>> f = geomf
=> #<RGeo::Geos::CAPIFactory:0x3ffc62405d50 srid=4326 bufres=8 flags=8>
>> f.point(-122.6764, 45.5165).distance( f.point(-122,45) )
=> 0.8510518256839603

>> f = spherical
=> #<RGeo::Geographic::Factory:0x007ff8c411a3e0 @impl_prefix="Spherical", @point_class=RGeo::Geographic::SphericalPointImpl, ...>
>> f.point(-122.6764, 45.5165).distance( f.point(-122,45) )
=> 78198.3596190946

PostGIS

>> DB.get :st.distance( :st.makepoint(-122.6764, 45.5165), :st.makepoint(-122, 45) )
=> 0.85105182568396

>> DB.get :st.distance(:st.geogfromwkb(:st.makepoint(-122.6764, 45.5165)), :st.geogfromwkb(:st.makepoint(-122, 45)) )
=> 78189.9134208575
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment