You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the /api/v1/stops endpoint with a latitude, longitude and a range results in an unsorted array. This means that the first item of the array isn't guaranteed to be the closest one.
Which basically asks for stops within 100 meters of 45.485188, 9.202954.
The query returns a (randomly?) sorted result, with the following distances (calculated with this method)
Current result
In our application, running our test function without sortStops (aka client side sorting) results:
s-u0ndc2jphn-stazionecentralepzaducadaostam2m3 is 61.503709069580765 meters away
s-u0ndc2jnh6-centralefs is 83.20704925537221 meters away
s-u0ndc2jqcq-stazionecentralepzaducadaostam2m3 is 66.50666845595956 meters away
s-u0ndc2m6km-milanocentrale is 0.0 meters away
A sorted array such as the items are ordered as following:
s-u0ndc2m6km-milanocentrale is 0.0 meters away
s-u0ndc2jphn-stazionecentralepzaducadaostam2m3 is 61.503709069580765 meters away
s-u0ndc2jqcq-stazionecentralepzaducadaostam2m3 is 66.50666845595956 meters away
s-u0ndc2jnh6-centralefs is 83.20704925537221 meters away
which in our case we get it with a sort function after the API call (reference)
The text was updated successfully, but these errors were encountered:
denysvitali
changed the title
Stops search via lat,lng, range returns an unsorted array
Stops search via lat, lng, range returns an unsorted array
Mar 18, 2018
You are correct; the default ordering is based on the internal stop id. In the geometry query, I am applying an ordering by distance, but I mistakingly allow this to be overridden by the pagination methods. I'll add this as a feature request.
Problem description
Using the
/api/v1/stops
endpoint with alat
itude,lon
gitude and ar
ange results in an unsorted array. This means that the first item of the array isn't guaranteed to be the closest one.Take for example the following request:
http://transit.land/api/v1/stops?lat=45.485188&lon=9.202954&r=100
Which basically asks for stops within 100 meters of
45.485188, 9.202954
.The query returns a (randomly?) sorted result, with the following distances (calculated with this method)
Current result
In our application, running our test function without sortStops (aka client side sorting) results:
Original JSON response from server:
Expected result
A sorted array such as the items are ordered as following:
which in our case we get it with a sort function after the API call (reference)
Maybe related
#1077
The text was updated successfully, but these errors were encountered: