kovacsbalu / WazeRouteCalculator

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

Add support to calculate routes with addresses in Brazil #60

Open coelholm opened 3 years ago

coelholm commented 3 years ago

Although it is possible to calculate distances using lat/long in Brazil with region AU, it is not possible to convert address to lat/long from AU region, without country information. Looks like issue is related to base coordinates. I have added BR with base coordinates and it works accordingly.

import WazeRouteCalculator
import logging

logger = logging.getLogger('WazeRouteCalculator.WazeRouteCalculator')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
logger.addHandler(handler)

# from_address = '-22.609454573, -43.179068844'
# to_address = '-22.902955752, -43.185864835'
from_address = 'rua sete de setembro,rio de janeiro'
to_address = 'avenida presidente vargas, rio de janeiro'
region = 'BR'
route = WazeRouteCalculator.WazeRouteCalculator(from_address, to_address, region)
route.calc_route_info()

Output

From: rua sete de setembro,rio de janeiro - to: avenida presidente vargas, rio de janeiro
Start coords: (-22.609454573, -43.179068844)
End coords: (-22.902955752, -43.185864835)
Time 53.87 minutes, distance 51.97 km.

Changing region to AU coordinates would be wrong

region = 'AU'

Output

From: rua sete de setembro,rio de janeiro - to: avenida presidente vargas, rio de janeiro
Start coords: (-34.84001541137695, 150.593994140625)
End coords: (-26.43230438232422, 133.2591094970703)
Time 1555.48 minutes, distance 2354.24 km.

I have submitted a pull request with this support to Brazil. #56 Add support to region BR

lichessboy commented 1 year ago

i have a simmilar issue in Australia, i have the region as 'AU', is that the problem?

Output From: 1 Marita Road, Perth, WA - to: 1 North Street, Perth, WA Start coords: (-34.4881591796875, 150.90646362304688) End coords: (-31.931893945, 115.85721939) Time 2661.83 minutes, distance 4010.51 km. this is incorrect because 1 northstreet is like 1KM from Marita Road so it makes no sense

Output From: 1 Marita Road, Perth, WA - to: 5 Davies Road, Perth, WA Start coords: (-34.4881591796875, 150.90646362304688) End coords: (-34.4881591796875, 150.90646362304688) Time 0.23 minutes, distance 0.04 km. this is actually correct,

Output From: 182 Little Marine Parade, Perth, WA - to: 5 Davies Road, Perth, WA Start coords: (-27.988226795, 153.429991207) End coords: (-34.4881591796875, 150.90646362304688) Time 581.32 minutes, distance 952.95 km.

but this is also incorrect, as these places are also 5KM from each other, so i dont think the start coords are correct, cos 153 isnt the y coord of 182 Little Marine Parade.

how do i fix this issue, it seems like it is just getting the wrong place, is there anyway to ensure that this doesnt happen? specifying the suburb ect. could potentially be done, but the suburbs are just randomly assigned in my data, with many of them just being 'suburb1', so if there are any other suggestions that would be easier as i have hundreds of addresses in my db.

kovacsbalu commented 1 year ago

@lichessboy please check https://github.com/kovacsbalu/WazeRouteCalculator/issues/57#issuecomment-1004755839