Skip to content

Commit

Permalink
Merge pull request #13 from 12v/12v/fix-osm-api
Browse files Browse the repository at this point in the history
Fix OSM API URL format
  • Loading branch information
ribenamaplesyrup authored Sep 14, 2023
2 parents b888b23 + 9a3fa0b commit 5f150c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sugartrail/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 5f150c0

Please sign in to comment.