diff options
author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-11-02 13:00:28 +0100 |
---|---|---|
committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-11-02 13:00:28 +0100 |
commit | 740594a4b73952ad3f5fa52dd1bb939c73dcc7c2 (patch) | |
tree | 07966947a2c61b7de99b9c52cd1bd4eebcc85759 /searx/engines/openstreetmap.py | |
parent | b4829891f93515c7d19af2472a855eccd7807c4a (diff) | |
download | searxng-740594a4b73952ad3f5fa52dd1bb939c73dcc7c2.tar.gz searxng-740594a4b73952ad3f5fa52dd1bb939c73dcc7c2.zip |
[enh] oscar_template: initial osm-map support for map results
* TODO: remove leaflet.min.css if not required
Diffstat (limited to 'searx/engines/openstreetmap.py')
-rw-r--r-- | searx/engines/openstreetmap.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index ea7251486..d73a116ba 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' +url = 'https://nominatim.openstreetmap.org/search/{query}?format=json&polygon_geojson=1' result_base_url = 'https://openstreetmap.org/{osm_type}/{osm_id}' @@ -38,9 +38,23 @@ def response(resp): osm_type = r.get('osm_type', r.get('type')) url = result_base_url.format(osm_type=osm_type, osm_id=r['osm_id']) + + geojson = r.get('geojson') + + # if no geojson is found and osm_type is a node, add geojson Point + if not geojson and\ + osm_type == 'node': + geojson = {u'type':u'Point', + u'coordinates':[r['lon'],r['lat']]} + # append result - results.append({'title': title, + results.append({'template': 'map.html', + 'title': title, 'content': '', + 'longitude': r['lon'], + 'latitude': r['lat'], + 'boundingbox': r['boundingbox'], + 'geojson': geojson, 'url': url}) # return results |