$geoNear

29 views
Skip to first unread message

alexmnyc

unread,
Sep 2, 2013, 7:49:32 PM9/2/13
to rogue...@googlegroups.com
Hi guys,

Does anyone know if $geoNear is implemented in the latest rogue branch? I'm looking for a way to return distance to the location as well as the location itself. Is there any other way to achieve this without $geoNear?

Thank you.

Alex

Jason Liszka

unread,
Sep 3, 2013, 3:50:25 PM9/3/13
to rogue...@googlegroups.com
It's not implemented at the moment, but you can use the haversine formula to calculate the distance between two lat/long points: http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points


--
You received this message because you are subscribed to the Google Groups "rogue-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rogue-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

alexmnyc

unread,
Sep 4, 2013, 10:42:13 AM9/4/13
to rogue...@googlegroups.com
Thanks, Jason.

Do you know if $near returns result sorted by distance? In this case distance calculation can be done at runtime without a problem in my use case. I basically need to find the nearest points to LatLng and display distance from it in a paged query.


Jason Liszka

unread,
Sep 4, 2013, 11:30:24 AM9/4/13
to rogue...@googlegroups.com
Yes:

The $near operator specifies a point for which a geospatial query returns the 100 closest documents. The query sorts the documents from nearest to farthest.

http://docs.mongodb.org/manual/reference/operator/near/


On Wed, Sep 4, 2013 at 10:42 AM, alexmnyc <a.mik...@gmail.com> wrote:
Thanks, Jason.

Do you know if $near returns result sorted by distance? In this case distance calculation can be done at runtime without a problem in my use case. I basically need to find the nearest points to LatLng and display distance from it in a paged query.


alexmnyc

unread,
Sep 4, 2013, 11:37:05 AM9/4/13
to rogue...@googlegroups.com
Doing $near with limit(1) then should return the closest point. Great, thank you again.
Reply all
Reply to author
Forward
0 new messages