How can I sort of geoPoint by distance?

Thanks @Andriy_Konoz. I am glad you told me this as we are launching in 3 weeks and this is a major change given that we have everything Geo based. 2 questions if you don’t mind

  1. Since we have the existing column being Geo based and I see the points in Geo Table, in order to migrate do I need to delete the column and re add a new column with Point and populate that again?
  2. I understand the Point/Spatial system gives the DistanceOfSpehere which is what we need to find all the points within 1000M of point x,y. What’s the sort order of the points returned? Is the data returned in “closest to furthest”? If not then how do I sort this data given that there could be more than 100 points (ie pagination)

Thank you again. This is critical for our launch

Hello,

  1. Yes, you should recreate a new column.
  2. To return data in “closest to furthest” please use this query in request:
query.whereClause = "distanceOnSphere(location,'POINT(-96.77 32.79)')<=1000'";
query.addProperties( "distanceOnSphere(location,'POINT(-96.77 32.79)') as dist" );
query.setSortBy( "dist" );

Regards,
Olha

2 Likes

Beautiful. Works perfectly.