Skip to content
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

Fixing error with some HERE responses #16

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/traveltime_google_comparison/requests/here_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ async def send_request(
for section in first_route["sections"]
)

# For some reason, HERE provider returns 0 duration, 0 length
# for some routes in the mountains, but doesn't indicate anywhere
# that it failed. Returning 0 fails `asType(int)` conversion later.
# Example route in UK where this happens:
# "58.61966879999991, -5.0040819999999995","58.578906999999894, -4.880025099999999"
if total_duration == 0:
return RequestResult(None)

Comment on lines +65 to +72
Copy link
Contributor Author

@arnasbr arnasbr Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the whole UK input file, this only happened for the HERE provider, nowhere else.

Another solution would be to simply remove the routes (only 4 of them, they seem to be somewhere in the northern mountains) that return this 0 travel time result. They seem to get pretty random results in other APIs, ranging from 900 to 7500. But even if we do that, having this for safety is still probably nice.

return RequestResult(travel_time=total_duration)
else:
error_message = data.get("detailedError", "")
Expand Down
Loading