How can I sort of geoPoint by distance?

Hi, any news on this subject?

is it?

Thanks

This issue has been fixed on the server-side.

Regards,
Mark

mmmm it’s not working for me.
I get first far away objects…

This is my query

query.whereClause = “distance( 41.39032416998498,2.158678314632413 , location.latitude , location.longitude) < km(100)”

How can I sort ASC instead of DESC?
query.queryOptions.sortBy = new Array(“location ASC”);?? Doesn’t work…
Thanks.

Same problem, still not working! :frowning:

Can we get an example ?

Olivier, what is not working? Please provide more details.

I get first far away objects…

This is my query

query.whereClause = “distance( 41.39032416998498,2.158678314632413 , location.latitude , location.longitude) < km(100)”

How can I sort ASC instead of DESC?
query.queryOptions.sortBy = new Array(“location ASC”);?? Doesn’t work…

Can we get an example ?
Thanks.

@Mark

My details are the same as Roberto.
Is there another way to sort by distance ASC

Hi, Mark.

Have you seen Oliver’s and I messages?
Thanks…

Hi Roberto and Olivier,

Currently there is no way to change the sorting order with the query. As a workaround, you can do it on the client-side or simply process the returned collection in the reversed order.

Regards,
Mark

Hi Mark, this doesn’t sound like a workaround if you load data page by page.

It will work if you loads the pages in the reversed order as well… I agree, it sounds silly (although totally doable).

This will work properly in Backendless 4.

Regards,
Mark

Hello, is this feature working in Backendless 4? Just want to be sure.

Yes, it should be working properly. Please let us know if you see a different behavior.

Ok, thanks! I will check and let you know.

Hello, is this feature working, because I am deffinitly not getting the closest geo first

Hi @snakeeyes!

The old Geolocation is no longer supported and will be removed in one of next releases.
I strictly recommend you to switch to the new Geo. (https://backendless.com/docs/rest/data_spatial_overview.html)

Or you get wrong behavior with new Geo?

Regards, Andriy

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.