From 9a3fa0b59bfa23d3c3fad9ede1d7433b1175be53 Mon Sep 17 00:00:00 2001 From: 12v <11772383+12v@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:17:07 +0100 Subject: [PATCH] Update OSM API URL format --- sugartrail/processing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sugartrail/processing.py b/sugartrail/processing.py index b100f14..06d61ce 100644 --- a/sugartrail/processing.py +++ b/sugartrail/processing.py @@ -70,8 +70,8 @@ def get_nearby_postcode(postcode_string): def get_coords_from_address(address_string): """Attempt retrieval of coords for input address string.""" - address = urllib.parse.quote(address_string) - url = 'https://nominatim.openstreetmap.org/search/' + urllib.parse.quote(address) +'?format=json' + params = {'q': address_string, 'format': 'json'} + url = 'https://nominatim.openstreetmap.org/search?' + urllib.parse.urlencode(params) response = requests.get(url).json() if response: return {'lat': response[0]['lat'], 'lon': response[0]['lon'], 'address': address_string}