// send the query to the nominatim geocoder and parse the json response
url_template = "https://nominatim.openstreetmap.org/search?format=json&limit=1&q={}"
url = url_template.format(query)
response = requests.get(url, timeout=60)results = response.json()
// if results were returned, parse lat and long out of the result
if len(results) > 0 and "lat" in results[0] and "lon" in results[0]:
lat = float(results[0]["lat"])
After Change
// define the parameters
params = OrderedDict()
params["format"] = "json"
params["limit"] = 1
params["dedupe"] = 0 // prevent OSM from deduping results so we get precisely "limit" // of results
params["q"] = query