diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index d73a116ba..e5deba1e5 100644 --- a/searx/engines/openstreetmap.py +++ b/searx/engines/openstreetmap.py @@ -15,7 +15,7 @@ categories = ['map'] paging = False # 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}' @@ -47,6 +47,30 @@ def response(resp): geojson = {u'type':u'Point', 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 results.append({'template': 'map.html', 'title': title, @@ -55,6 +79,7 @@ def response(resp): 'latitude': r['lat'], 'boundingbox': r['boundingbox'], 'geojson': geojson, + 'address': address, 'url': url}) # return results diff --git a/searx/static/oscar/css/oscar.min.css b/searx/static/oscar/css/oscar.min.css index 1afd3e866..b8d6fba15 100644 --- a/searx/static/oscar/css/oscar.min.css +++ b/searx/static/oscar/css/oscar.min.css @@ -5,7 +5,7 @@ input[type=checkbox]:checked~.label_hide_if_checked{display:none} input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none} .result_header{margin-bottom:5px;margin-top:20px}.result_header .favicon{margin-bottom:-3px} .result_header a{vertical-align:bottom}.result_header a .highlight{font-weight:bold} -.result-content .highlight{font-weight:bold} +.result-content{margin-top:5px}.result-content .highlight{font-weight:bold} .result-default{clear:both} .result-images{float:left !important} .img-thumbnail{margin:5px;max-height:128px;min-height:128px} diff --git a/searx/static/oscar/less/oscar/results.less b/searx/static/oscar/less/oscar/results.less index 9ca2109bc..08500b3ff 100644 --- a/searx/static/oscar/less/oscar/results.less +++ b/searx/static/oscar/less/oscar/results.less @@ -17,6 +17,8 @@ } .result-content { + margin-top: 5px; + .highlight { font-weight:bold; } diff --git a/searx/templates/oscar/result_templates/map.html b/searx/templates/oscar/result_templates/map.html index 45aa76356..2c1e549e3 100644 --- a/searx/templates/oscar/result_templates/map.html +++ b/searx/templates/oscar/result_templates/map.html @@ -7,7 +7,29 @@ {% if (result.latitude and result.longitude) or result.boundingbox %} • {{ icon('globe') }} {{ _('show map') }} {% endif %} - + +{% if result.address %} +
+ {% if result.address.name %}
+ {{ result.address.name }}
+ {% endif %}
+ {% if result.address.road %}
+
+ {% if result.address.house_number %}{{ result.address.house_number }}, {% endif %}
+ {{ result.address.road }}
+
+ {% endif %}
+ {% if result.address.locality %}
+ {{ result.address.locality }},
+ {% if result.address.postcode %} {{ result.address.postcode }}{% endif %}
+
+ {% endif %}
+ {% if result.address.country %}
+ {{ result.address.country }}
+ {% endif %}
+
{{ result.content|safe }}
{% endif %} {% if (result.latitude and result.longitude) or result.boundingbox %}