-
Notifications
You must be signed in to change notification settings - Fork 1
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
Adds fallback for OSRM "NoRoute" errors #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT, just smaller remarks. Not sure if they are blocking, you decide
nextplot/osrm.py
Outdated
) | ||
distances.append(common.haversine(f, t)) | ||
durations.append(common.haversine(f, t) / TRAVEL_SPEED) | ||
return OsrRouteResponse(paths=paths, distances=distances, durations=durations, no_route=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a "m" missing? 🧐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good catch. 😊
@@ -40,9 +41,26 @@ def query_route( | |||
# Query OSRM | |||
try: | |||
response = requests.get(url) | |||
# If no route was found, use as-the-crow-flies fallback | |||
if response.status_code == 400 and response.json()["code"] == "NoRoute": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it was a "bad request" why not always fall back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. 🤔
I think the reason here is that it will likely fall back for all routes, which might be worse. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will leave it like it for now. Let's see whether we want to change this in future.
Description
This PR introduces a fallback mechanism for when OSRM fails to find a route, alongside improved error handling.
Changes