|
@@ -15,7 +15,7 @@ categories = ['map']
|
|
paging = False
|
|
paging = False
|
|
|
|
|
|
# search-url
|
|
# search-url
|
|
-url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1'
|
|
|
|
|
|
+url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1&addressdetails=1'
|
|
|
|
|
|
result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
|
|
result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
|
|
|
|
|
|
@@ -47,6 +47,30 @@ def response(resp):
|
|
geojson = {u'type':u'Point',
|
|
geojson = {u'type':u'Point',
|
|
u'coordinates':[r['lon'],r['lat']]}
|
|
u'coordinates':[r['lon'],r['lat']]}
|
|
|
|
|
|
|
|
+ address_raw = r.get('address')
|
|
|
|
+ address = {}
|
|
|
|
+
|
|
|
|
+ # get name
|
|
|
|
+ if r['class'] == 'amenity' or\
|
|
|
|
+ r['class'] == 'shop' or\
|
|
|
|
+ r['class'] == 'tourism' or\
|
|
|
|
+ r['class'] == 'leisure':
|
|
|
|
+ if address_raw.get('address29'):
|
|
|
|
+ address = {'name':address_raw.get('address29')}
|
|
|
|
+ else:
|
|
|
|
+ address = {'name':address_raw.get(r['type'])}
|
|
|
|
+
|
|
|
|
+ # add rest of adressdata, if something is already found
|
|
|
|
+ if address.get('name'):
|
|
|
|
+ address.update({'house_number':address_raw.get('house_number'),
|
|
|
|
+ 'road':address_raw.get('road'),
|
|
|
|
+ 'locality':address_raw.get('town', address_raw.get('village')),
|
|
|
|
+ 'postcode':address_raw.get('postcode'),
|
|
|
|
+ 'country':address_raw.get('country'),
|
|
|
|
+ 'country_code':address_raw.get('country_code')})
|
|
|
|
+ else:
|
|
|
|
+ address = None
|
|
|
|
+
|
|
# append result
|
|
# append result
|
|
results.append({'template': 'map.html',
|
|
results.append({'template': 'map.html',
|
|
'title': title,
|
|
'title': title,
|
|
@@ -55,6 +79,7 @@ def response(resp):
|
|
'latitude': r['lat'],
|
|
'latitude': r['lat'],
|
|
'boundingbox': r['boundingbox'],
|
|
'boundingbox': r['boundingbox'],
|
|
'geojson': geojson,
|
|
'geojson': geojson,
|
|
|
|
+ 'address': address,
|
|
'url': url})
|
|
'url': url})
|
|
|
|
|
|
# return results
|
|
# return results
|