-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up JSON response #519
Comments
I vote! This is more rational, and similar to the Google Maps approach. But please, when changing the API, document the Server API (https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api) in parallel:
|
This will break backwards compatibility but would make handling responses in frontends much simpler. My goal is to get something similar to what we currently use as Mapbox Directions API: Problems:
@perliedman as you are maintaining a popular frontend, any opinions on this? |
Breaking changes are of course always a hassle, but none the less I'm 👍 for this. The current API has always struck me as a bit weird. I'm also a fan of using GeoJSON. Using a standardized formatt makes it easy to work with the routes in ways that were not necessarily intended, and makes it really is easy to visualize results in a large number of tools. If there's not a great performance penalty here, I'd vote for this as well. |
I vote for something more similar to the Google Maps Directions API response, spliting the route in legs, the legs in steps and the steps in points (polyline). I think it's much more rational. |
First draft of the
Primary changes to
@perliedman @freenerd any feedback is appreciated. The wiki can be freely edited in case of suggestions. |
Question about route service, "geometry" attribute: What will be the exact output for "polyline" and "array" options Please don't discard the encoded polyline option. On an Android device, for a long route, this is the only acceptable solution (json decoding takes a while). |
@MKergall Thanks for the feedback, will specify more clearly. 👍 No the encoded polyline option will stay of course. |
I looked at the New Server API, generally I'm 👍 but think that there is some cases where the docs should be more precise. Comments below. I really don't like the repetition and positional query arguments. These queries can be hard to create with some HTTP Libraries, something that we hit in our own test suite. It means that people just have to fallback to building query parameter strings themselves, which feels okay with me. The other option would be indexing parameter keys (e.g. The
Could we always return a key like
Should we enable uturns by default in 5.0? Maybe warrants another ticket.
What's the difference between these two? Also will the "Impossible Route" be a
What is the difference between these two errors? Are these errors for the whole match or can they happen also on sub-matches? How would they be present in the response then? If there is no match, will there be an empty
Can it be that a point can't be matched? Or will it always be in a trip (with the most extreme case a trip with only this one point)?
The examples should include several |
I would like to stay somewhat with the old query-parameter design. Makes things easier to port and the
I don't see why this would reduce the effort for the programmer.
I don't think it is a safe assumption that executing a u-turn is in general always possible. This can lead to absurd (and unsafe) suggestions like doing u-turns in the middle of high traffic streets.
Needs clarification: First one means the nearest neighbor search could not find a matching segment. Will update the docs.
Good catch. Needs clarification. Would like to opt for the same appraoch as
Same, needs clarification. Would like to be maximal restrictive and only allow either single point options (
Supported for all queries as outlined at the beginning. Not sure if we should back-link to the common options each time?
As skipping trace points is expected behaviour this works analogous to
In case of error the error object will be returned.
Trip length is minimum one waypoint.
Good point. |
Other HTTP status codes like switch (body.code) {
case 'ok':
// normal processing with safe access to body.routes
case 'no-route':
// error message to user
default:
// panic
}
Moving to #1922
Cool. Likely best would be to throw an error instead of taking precedence.
I'd re-add it in this case, since it adds clarity.
I think this should say: In case of an error only the error object will be returned. |
Ok changed
👍
👍 I also slightly modified the draft to split the route into legs now. There is a new |
It looks like Also, it appers both the Other than that, I think this is shaping up really nicely, good job! |
Don't mind my first comment, I found the |
Yeah that is also the only problem I see with the leg approach: If you want to provide the aggregated values for |
Duplicating How about using indices into the complete route's |
https://github.com/Project-OSRM/osrm-backend/wiki/New-Server-api#properties
I guess
What is the default https://github.com/Project-OSRM/osrm-backend/wiki/New-Server-api#query
Does this mean The docs should note that using The url example should be split into to, with one example for The example should include the repetition of query parameters, in the same style as the
|
@freenerd thanks for the feedback. 👍 I hope a lot of the confusion w.r.t.
e.g. for a
As you can see the |
An alternative approach was brought up by @jfirebaugh of using nested parameters like this: Pro:
Con:
Either we go ahead and implement a parser with some actual validation, or we need to live with random results form the query parsing. |
The request format has now been decided to a version with @TheMarex One thing I realized when looking at errors:
|
👍 Updating. |
@TheMarex More feedback/questions/suggestions. Let's discuss! Check boxes when dismissed, or resolved in docs and code.
|
Sadly no, but we should make one internally. Can you open a ticket for that?
These will be profile defined. Profiles will pass a string (not a number like now) and will be passed through to the client. |
Question regarding U-Turns: Given that every coordinate can have u-turns enabled/disabled, for which legs are they available then? For the leg before the coordinate, for the leg after the coordinate or for both? My intuition here is that they are valid for the leg after the coordinate, which would mean that the u-turn value for the last coordinate has no effect. |
I think the function is not clear here. Technically you can always do a uturn at the first waypoint because you are not yet constrained in the travel direction. |
Moved the uturn discussion to #2012 |
Just reporting on my first attempts with the new server API. There seem to be a few inconsistencies between the current rewrite/new-api branch responses and the documentation at For a malformed query, I get an |
@jcoupey oh good catch yes, I forgot to adapt the server code. 👍 |
Did some more testing with the rewrite/new-api branch and saw that all durations and distances are currently returned as floats in the json response. Is this a general policy for the new server API or just somehow related to the development phase? |
@jcoupey no we switched from deci-seconds for duration to actually returning seconds and meters should always have been a float. |
Related question/concern if you return a number of seconds as a float: what happens in a table request when some routes are not found? The corresponding duration used to be |
@jcoupey good point, there is a lack in docs there right now. It should be |
The new API has been merged into develop. Expect smaller parameter name changes/default changes to happen before RC2. Otherwise the API is fixed now. |
the response structure is currently:
i think it would be cleaner to reorganize routes and alternate routes into a single array, with each element containing all the info for that particular route:
if you did not request alternative routes, the array contains one element. if you did request alternatives, it could have 2 or more, or 1 if not alternative was found.
at the moment, info for a specific route is scattered across several arrays (which hopefully have the same length).
it also seems natural to move the route names into the route array elements, and drop the 'route_' prefix on the elements in the route array.
The text was updated successfully, but these errors were encountered: