gis-ops / routingpy

🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.
https://routingpy.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
270 stars 26 forks source link

List index out of range error for google directions #15

Closed alichass closed 3 years ago

alichass commented 4 years ago

Here's what I did (dry run output):

url: https://maps.googleapis.com/maps/api/directions/json?departure_time=1602059400&destination=37.42306%2C-122.08413&key=####################&mode=transit&origin=37.26044%2C-122.11921&units=metric Parameters: { "headers": { "User-Agent": "routingpy/v0.3.2", "Content-Type": "application/json" }, "timeout": 60 }


Here's what I got

image

Seems to be cause by this repsonse: {'available_travel_modes': ['DRIVING', 'WALKING', 'BICYCLING'], 'geocoded_waypoints': [{}, {}], 'routes': [], 'status': 'ZERO_RESULTS'}


Here's what I was expecting

Empty direction object if response is: {'available_travel_modes': ['DRIVING', 'WALKING', 'BICYCLING'], 'geocoded_waypoints': [{}, {}], 'routes': [], 'status': 'ZERO_RESULTS'}

nilsnolde commented 4 years ago

What I'd expect from a well-behaved API is a 404.. Or any 4xx, which is what would prevent smth like that. But google maps :shrug:

nilsnolde commented 3 years ago

I guess we should still handle it (eventually anyways;)), even if Google is being idiot here..

alichass commented 3 years ago

There's another really weird unrelated (unsure if its google specific, likely is) edge case, where requesting a walk or car route can sometimes result in a route with a ferry step