From 3303e2ba2266f89bb243b8700f46b20bfe01fa2d Mon Sep 17 00:00:00 2001 From: Arnas Bradauskas <140691866+arnasbr@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:35:50 +0300 Subject: [PATCH] Fixing error with some HERE responses (#16) --- src/traveltime_google_comparison/requests/here_handler.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/traveltime_google_comparison/requests/here_handler.py b/src/traveltime_google_comparison/requests/here_handler.py index 9c5a9c9..0cc9804 100644 --- a/src/traveltime_google_comparison/requests/here_handler.py +++ b/src/traveltime_google_comparison/requests/here_handler.py @@ -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) + return RequestResult(travel_time=total_duration) else: error_message = data.get("detailedError", "")