I would like to query some geo location points with morphia framework. I use my latitude, longitude, and radius(100 km.) with “Near” method to query the other around my location and limit 10 results. Just like this :
morphia.ds.find(Location.class).field("Location").near(latitude, longitude, 100).limit(10).asList();
It doesn’t error but the result shows me the location points that around me and out of scope of my radius(100km.). So, my radius doesn’t concern when query the result.
What is my problem with query statement?
Thanks you in advance
The length of an arcdegree of north-south latitude difference, is about 60 nautical miles, 111 kilometres or 69 statute miles at any latitude; You can read more about here in wikipedia or in mongo geospatial page The Earth is Round but Maps are Flat.
Convert distance by 111.12 (one degree is approximately 111.12 kilometers) when using km, or by 69 (for miles).
So change your query to
And make sure mongodb accepts the co-ordinates in [long,lat].