DenisCarriere / geocoder

:earth_asia: Python Geocoder
http://geocoder.readthedocs.org
MIT License
1.63k stars 288 forks source link

Mapbox location search is splitting apartment addresses on the '#' and using second half as URL anchor #437

Open omnilord opened 3 years ago

omnilord commented 3 years ago

The mapbox module does a self.url.format(location) to generate the base URL instead of properly encoding the URL. This results in apartment addresses being split at the '#' symbol for the apartment number, and the access token being injected in the middle of the address instead of after the '.json' extension.

Example:

g = geocoder.mapbox('1300 Foulk Rd, #8, Wilmington, DE 19803')

Status code 404 from https://api.mapbox.com/geocoding/v5/mapbox.places/1300 Foulk Rd, #8, Wilmington, DE 19803.json: ERROR - 404 Client Error: Not Found for url:
https://api.mapbox.com/geocoding/v5/mapbox.places/1300%20Foulk%20Rd,%20?access_token=<token>#8,%20Wilmington,%20DE%2019803.json

Using an alternate module such as google works fine, but that may not be an option for some projects.

python - 3.9.1 geocoder - 1.38.1