Use estimates for NoRoute in table requests #5257
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When working with very large table requests (1M+ entries), it can be difficult to parse/modify/handle the large response.
A common request we've had from customers is to "never return a null value in a table response" - usually, if no route is found, some estimate can be used instead.
This PR implements a new Table API parameter called
fallback_speed
. When used, if anull
field exists in a table JSON response, it will be replaced by a straight-line estimate between the source/destination. By default, we measure the distance between the input coordinates (supplied in the request), but you can usefallback_coordinate=snapped
to use the snapped location instead. Once the distance is found, it is divided by thefallback_speed
value to come up with a duration estimate.Doing this work inside OSRM before constructing the response JSON is significantly more convenient and performant than doing it after the fact dealing with JSON data.
For 1,000,000 cell table requests (which takes about 2-3s on my test machine), this adds approximately 0.7ms if there are no
null
values to be replaced, and about 30ms if all cells need to be replaced.Tasklist