@@ -15,7 +15,7 @@ categories = ['map']
15paging = False
15paging = False
17# search-url
17# search-url
18−url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1'
18+url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1&addressdetails=1'
20result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
20result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}'
@@ -47,6 +47,30 @@ def response(resp):
47 geojson = {u'type':u'Point',
47 geojson = {u'type':u'Point',
48 u'coordinates':[r['lon'],r['lat']]}
48 u'coordinates':[r['lon'],r['lat']]}
50+ address_raw = r.get('address')
54+ if r['class'] == 'amenity' or\
55+ r['class'] == 'shop' or\
56+ r['class'] == 'tourism' or\
57+ r['class'] == 'leisure':
58+ if address_raw.get('address29'):
59+ address = {'name':address_raw.get('address29')}
61+ address = {'name':address_raw.get(r['type'])}
63+ # add rest of adressdata, if something is already found
64+ if address.get('name'):
65+ address.update({'house_number':address_raw.get('house_number'),
66+ 'road':address_raw.get('road'),
67+ 'locality':address_raw.get('town', address_raw.get('village')),
68+ 'postcode':address_raw.get('postcode'),
69+ 'country':address_raw.get('country'),
70+ 'country_code':address_raw.get('country_code')})
50 # append result
74 # append result
51 results.append({'template': 'map.html',
75 results.append({'template': 'map.html',
52 'title': title,
76 'title': title,
@@ -55,6 +79,7 @@ def response(resp):
55 'latitude': r['lat'],
79 'latitude': r['lat'],
56 'boundingbox': r['boundingbox'],
80 'boundingbox': r['boundingbox'],
57 'geojson': geojson,
81 'geojson': geojson,
58 'url': url})
83 'url': url})
60 # return results
85 # return results