How can I sort of geoPoint by distance?

Is it possible to sort geoPoint by distance?, may be in BackendlessGeoQuery there is an such feature?

This is not currently possible, but this would be very useful. I will add it to the planned features list.

Regards,
Mark

Any update for this feature ?

I’m looking for this feature for my app.

Thanks,

Hi Olivier,

When geo points are returned, they should now be automatically sorted by distance.

Regards,
Mark

I’m still receiving unsorted result :frowning:

Can you tell me how I can sort by location.distance ASC, using Rest Console ?
http://support.backendless.com/public/attachments/a3a3bdd915c9d7fadf804f9cf578ea06.png</img>

Thank you

Just to confirm - you’re trying to retrieve data objects which have related geo points. You’re using the distance() function in the “where clause”. Did I get that right?

Yes, I want the 20 nearest location from my current location order by location distance ASC.

Are there any news about this issue? I’m using iOS and this clause works for me:

query.whereClause = “distance((userCoordinate.latitude), (userCoordinate.longitude), location.latitude, location.longitude ) < km(1100)”

But the objects are partially returned as furthest first and cannot modify sorting order. Tried using sortBy, no luck.
This is a blocker for me right now.

We’ll get this fixed in the next hotfix. Internal ticket number is 11910

Any updates?

I’m waiting for this fix to push my new update.

thx

Hi Olivier,

The internal system shows the QA has rejected the fix. I am escalating the ticket to put it in the priority queue.

Regards,
Mark

Hey Mark,

Any updates on this?

Best,
Matt

Hi Matt,

Sorry, it is still not available in production.

Regards,
Mark

Hey Mark,

Any updates on this?
Thx!

@Override
public void run() {
    QueryOptions options = new QueryOptions();
    options.setRelationsDepth(1);

    BackendlessDataQuery query = new BackendlessDataQuery(options);
    StringBuilder builderQuery = new StringBuilder("distance(")
            .append(myLocation.getLatitude()).append(", ").append(myLocation.getLongitude()).append(", ")
            .append("location.latitude, location.longitude")
            .append(") < km(100)");

    String in = createIn();
    if (in != null){
        builderQuery.append(" AND category.objectId in (").append(in).append(")");
    }
    Log.d("DownloadOffers", "where: " + builderQuery.toString());
    query.setWhereClause(builderQuery.toString());


    try {
        BackendlessCollection&lt;Offer&gt; collection = Offer.find(query);
        offers = collection.getCurrentPage();
        for (Offer o : offers) {
            Log.d("DownloadOffers", "distance: " + o.getLocation().getDistance());
        }
    } catch (BackendlessException e) {
        this.e = e;
        Log.e("DownloadOffers", e.getMessage() + "");
        e.printStackTrace();
    }

    setCompleted();
}
06-23 15:45:29.119 23499-23818/------------ D/DownloadOffers: where: distance(49.7747234, 19.2230695, location.latitude, location.longitude) < km(100)
06-23 15:45:30.240 23499-23818/------------ D/DownloadOffers: distance: 26746.30421120584
06-23 15:45:30.240 23499-23818/------------ D/DownloadOffers: distance: 10171.374704674983
06-23 15:45:30.240 23499-23818/------------ D/DownloadOffers: distance: 9446.9660542435
06-23 15:45:30.240 23499-23818/------------ D/DownloadOffers: distance: 1069.4648005503018
06-23 15:45:30.240 23499-23818/------------ D/DownloadOffers: distance: 9446.9660542435

I still have problem wiht sorting by distance. Not working automatically sorting:/
In log is visible that not get sorted result. Please help me.

Hello @rxdev, @Olivier Lamarche
I have increased the priority for ticket 11910. Our engineers will look at it as soon as possible.
Artur

Any news on this issue? Thanks.

an updates on this issue?

I have requested our developers on the status of the ticket, I will inform you as soon as they will give an answer.

Ok Thanks…