From: Marc Tobias Metten Date: Sat, 10 Mar 2018 00:30:22 +0000 (+0100) Subject: merge json and jsonv2 templates, they were very similar X-Git-Tag: v3.2.0~110 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/88beeb79164d0fec40778678e5d93ae44b8f07d8 merge json and jsonv2 templates, they were very similar --- diff --git a/lib/template/address-json.php b/lib/template/address-json.php index cea87745..85f6fe8e 100644 --- a/lib/template/address-json.php +++ b/lib/template/address-json.php @@ -16,7 +16,22 @@ if (!sizeof($aPlace)) { } if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat']; if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon']; + + if ($sOutputFormat == 'jsonv2') { + $aFilteredPlaces['place_rank'] = $aPlace['rank_search']; + + $aFilteredPlaces['category'] = $aPlace['class']; + $aFilteredPlaces['type'] = $aPlace['type']; + + $aFilteredPlaces['importance'] = $aPlace['importance']; + + $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']); + + $aFilteredPlaces['name'] = $aPlace['placename']; + } + $aFilteredPlaces['display_name'] = $aPlace['langaddress']; + if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress']; if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags']; if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails']; diff --git a/lib/template/address-jsonv2.php b/lib/template/address-jsonv2.php deleted file mode 100644 index 399c978f..00000000 --- a/lib/template/address-jsonv2.php +++ /dev/null @@ -1,57 +0,0 @@ - $aPointDetails) { $aPlace = array( 'place_id'=>$aPointDetails['place_id'], - 'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright', + 'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', ); $sOSMType = formatOSMType($aPointDetails['osm_type']); @@ -30,7 +29,12 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) { $aPlace['lon'] = $aPointDetails['lon']; $aPlace['display_name'] = $aPointDetails['name']; - $aPlace['class'] = $aPointDetails['class']; + if ($sOutputFormat == 'jsonv2') { + $aPlace['place_rank'] = $aPointDetails['rank_search']; + $aPlace['category'] = $aPointDetails['class']; + } else { + $aPlace['class'] = $aPointDetails['class']; + } $aPlace['type'] = $aPointDetails['type']; $aPlace['importance'] = $aPointDetails['importance']; @@ -39,7 +43,7 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) { $aPlace['icon'] = $aPointDetails['icon']; } - if (isset($aPointDetails['address'])) { + if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])) { $aPlace['address'] = $aPointDetails['address']; } diff --git a/lib/template/search-jsonv2.php b/lib/template/search-jsonv2.php deleted file mode 100644 index 76103304..00000000 --- a/lib/template/search-jsonv2.php +++ /dev/null @@ -1,68 +0,0 @@ - $aPointDetails) { - $aPlace = array( - 'place_id'=>$aPointDetails['place_id'], - 'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', - ); - - $sOSMType = formatOSMType($aPointDetails['osm_type']); - if ($sOSMType) { - $aPlace['osm_type'] = $sOSMType; - $aPlace['osm_id'] = $aPointDetails['osm_id']; - } - - if (isset($aPointDetails['aBoundingBox'])) { - $aPlace['boundingbox'] = $aPointDetails['aBoundingBox']; - - if (isset($aPointDetails['aPolyPoints'])) { - $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints']; - } - } - - if (isset($aPointDetails['zoom'])) { - $aPlace['zoom'] = $aPointDetails['zoom']; - } - - $aPlace['lat'] = $aPointDetails['lat']; - $aPlace['lon'] = $aPointDetails['lon']; - $aPlace['display_name'] = $aPointDetails['name']; - $aPlace['place_rank'] = $aPointDetails['rank_search']; - - $aPlace['category'] = $aPointDetails['class']; - $aPlace['type'] = $aPointDetails['type']; - - $aPlace['importance'] = $aPointDetails['importance']; - - if (isset($aPointDetails['icon'])) { - $aPlace['icon'] = $aPointDetails['icon']; - } - - if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) { - $aPlace['address'] = $aPointDetails['address']; - } - - if (isset($aPointDetails['asgeojson'])) { - $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']); - } - - if (isset($aPointDetails['assvg'])) { - $aPlace['svg'] = $aPointDetails['assvg']; - } - - if (isset($aPointDetails['astext'])) { - $aPlace['geotext'] = $aPointDetails['astext']; - } - - if (isset($aPointDetails['askml'])) { - $aPlace['geokml'] = $aPointDetails['askml']; - } - - if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags']; - if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails']; - - $aFilteredPlaces[] = $aPlace; -} - -javascript_renderData($aFilteredPlaces); diff --git a/website/reverse.php b/website/reverse.php index b6d0f5e6..6df90029 100755 --- a/website/reverse.php +++ b/website/reverse.php @@ -76,4 +76,6 @@ if ($sOutputFormat == 'html') { $sTileURL = CONST_Map_Tile_URL; $sTileAttribution = CONST_Map_Tile_Attribution; } -include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php'); + +$sOutputTemplate = ($sOutputFormat=='jsonv2' ? 'json' : $sOutputFormat); +include(CONST_BasePath.'/lib/template/address-'.$sOutputTemplate.'.php'); diff --git a/website/search.php b/website/search.php index 9f3ae470..346f5b57 100755 --- a/website/search.php +++ b/website/search.php @@ -81,4 +81,5 @@ $sMoreURL = CONST_Website_BaseURL.'search.php?'.http_build_query($aMoreParams); if (CONST_Debug) exit; -include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php'); +$sOutputTemplate = ($sOutputFormat=='jsonv2' ? 'json' : $sOutputFormat); +include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');