kovacsbalu / WazeRouteCalculator

Calculate actual route time and distance with Waze api
GNU General Public License v3.0
144 stars 57 forks source link

calc_all_routes_info always return dict with 1 value. #64

Closed homemain closed 2 years ago

homemain commented 2 years ago

I'm trying to get info about possible routes between two points

from WazeRouteCalculator import WazeRouteCalculator
from_address = 'Budapest, Hungary'
to_address = 'Győr, Hungary'
wrc = WazeRouteCalculator(from_address, to_address)
routes = wrc.calc_all_routes_info()
print(len(routes))

I played with different addresses and input params, but routes as result of calc_all_routes_info always has just one element, while I expected several (according to README.md)

I dig into source of of the method and found following Lines 208-209 in WazeRouteCalculator

routes = self.get_route(npaths, time_delta)
results = {route['routeName' if 'routeName' in route else 'route_name']: self._add_up_route(route['results' if 'results' in route else 'result'], real_time=real_time, stop_at_bounds=stop_at_bounds) for route in routes}

On line 208 variable routes as result of the API call has 2 values (as expected) but on the line 209 results has only one value, which is returned afterwards.

I'm not good in python, so I cannot understand the logic of the results calculation, but it looks strange.

Is is an expected behavior?

Thanks in advance, for your clarification

kovacsbalu commented 2 years ago

Hi @homemain, you are right, waze won't send route_name. Python dictionary drops out other items with "same" empty name. I will fix it soon.