From: marc tobias Date: Sun, 21 Jul 2019 21:20:48 +0000 (+0200) Subject: lookup endpoint supports jsonv2 and geocodejson output now X-Git-Tag: v3.4.0~22^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/1560685020f7c19eeee6d28b12a863cd0c6b6592 lookup endpoint supports jsonv2 and geocodejson output now --- diff --git a/docs/api/Lookup.md b/docs/api/Lookup.md index 84ebb5d8..2412be1e 100644 --- a/docs/api/Lookup.md +++ b/docs/api/Lookup.md @@ -19,7 +19,7 @@ Additional optional parameters are explained below. ### Output format -* `format=[xml|json|geojson]` +* `format=[xml|json|jsonv2|geojson|geocodejson]` See [Place Output Formats](Output.md) for details on each format. (Default: xml) diff --git a/test/bdd/api/lookup/simple.feature b/test/bdd/api/lookup/simple.feature index 660598db..dc80c235 100644 --- a/test/bdd/api/lookup/simple.feature +++ b/test/bdd/api/lookup/simple.feature @@ -4,14 +4,16 @@ Feature: Places by osm_type and osm_id Tests Scenario Outline: address lookup for existing node, way, relation When sending lookup query for N3284625766,W6065798,,R123924,X99,N0 - Then the result is valid + Then the result is valid And exactly 3 results are returned Examples: - | format | - | xml | - | json | - | geojson | + | format | outformat | + | xml | xml | + | json | json | + | jsonv2 | json | + | geojson | geojson | + | geocodejson | geocodejson | Scenario: address lookup for non-existing or invalid node, way, relation When sending xml lookup query for X99,,N0,nN158845944,ABC,,W9 diff --git a/test/bdd/steps/queries.py b/test/bdd/steps/queries.py index 76ce9810..3f0cffff 100644 --- a/test/bdd/steps/queries.py +++ b/test/bdd/steps/queries.py @@ -455,8 +455,12 @@ def website_lookup_request(context, fmt, query): if fmt == 'json ': outfmt = 'json' + elif fmt == 'jsonv2 ': + outfmt = 'json' elif fmt == 'geojson ': outfmt = 'geojson' + elif fmt == 'geocodejson ': + outfmt = 'geocodejson' else: outfmt = 'xml' diff --git a/website/lookup.php b/website/lookup.php index 20d06af0..e5f01232 100644 --- a/website/lookup.php +++ b/website/lookup.php @@ -9,7 +9,7 @@ ini_set('memory_limit', '200M'); $oParams = new Nominatim\ParameterParser(); // Format for output -$sOutputFormat = $oParams->getSet('format', array('xml', 'json', 'geojson'), 'xml'); +$sOutputFormat = $oParams->getSet('format', array('xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'xml'); set_exception_handler_by_format($sOutputFormat); // Preferred language @@ -49,8 +49,10 @@ foreach ($aOsmIds as $sItem) { $oResult = $oPlace; unset($oResult['aAddress']); if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress']; - unset($oResult['langaddress']); - $oResult['name'] = $oPlace['langaddress']; + if ($sOutputFormat != 'geocodejson') { + unset($oResult['langaddress']); + $oResult['name'] = $oPlace['langaddress']; + } $aSearchResults[] = $oResult; } }