Start a new topic

can _geoloc return the distance?

Hiya,



I am using Android Kinvey and my collection has a field _geoloc that for querying people around me. Below are the code to query



Query q2 = new Query();

q2.nearSphere("_geoloc", location.getLatitude(), location.getLongitude(), 50);



AsyncAppData findNearByPeople = mKinveyClient().appData("userdata", UserData.class);



findNearByPeople.get(q2, new KinveyListCallback() {



@Override

public void onSuccess(UserData[] result) {



}



@Override

public void onFailure(Throwable error) {



}



});



How does kinvey or will kinvey return the distance as I need to sort my result by distance.

Appreciate any help please. Thanks !



Cheerios,

Mark Thien


Good morning Mark,



This is not something that we presently support as nearsphere is actually a feature of MongoDB and not of the kinvey platform. You can read more about the implementation / limitations of MongoDB's nearsphere over here: http://docs.mongodb.org/manual/reference/operator/query/nearSphere/#behavior



Some people who have run into issues have opted to use within instead (http://docs.mongodb.org/v2.2/reference/operator/query/within/) , which again, has it's own set of issues to work through.



Thanks,
Hi Damien,



Thanks a lot for your answer. Do you recommend any other api service that can return distance ?



Cheerios,

Mark
markthien,



You can do it right within mongo, it's just not the most pretty stuff ever...



http://docs.mongodb.org/manual/tutorial/calculate-distances-using-spherical-geometry-with-2d-geospatial-indexes/



Login or Signup to post a comment