]> git.openstreetmap.org Git - nominatim.git/commitdiff
merge json and jsonv2 templates, they were very similar
authorMarc Tobias Metten <mtmail@gmx.net>
Sat, 10 Mar 2018 00:30:22 +0000 (01:30 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 13 Mar 2018 22:49:04 +0000 (23:49 +0100)
lib/template/address-json.php
lib/template/address-jsonv2.php [deleted file]
lib/template/search-json.php
lib/template/search-jsonv2.php [deleted file]
website/reverse.php
website/search.php

index cea8774549cef955eb4c91a783cdccbb835f692c..85f6fe8eb7c5fb7cdfe04fb29fd2ef3e4c9fd83a 100644 (file)
@@ -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 (file)
index 399c978..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-$aFilteredPlaces = array();
-
-if (!sizeof($aPlace)) {
-    if (isset($sError))
-        $aFilteredPlaces['error'] = $sError;
-    else $aFilteredPlaces['error'] = 'Unable to geocode';
-} else {
-    if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
-    $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
-    $sOSMType = formatOSMType($aPlace['osm_type']);
-    if ($sOSMType) {
-        $aFilteredPlaces['osm_type'] = $sOSMType;
-        $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
-    }
-    if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];
-    if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];
-
-    $aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
-
-    $aFilteredPlaces['category'] = $aPlace['class'];
-    $aFilteredPlaces['type'] = $aPlace['type'];
-
-    $aFilteredPlaces['importance'] = $aPlace['importance'];
-
-    $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
-
-    $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
-    $aFilteredPlaces['name'] = $aPlace['placename'];
-
-    if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
-    if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
-    if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
-
-    if (isset($aPlace['aBoundingBox'])) {
-        $aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
-    }
-
-    if (isset($aPlace['asgeojson'])) {
-        $aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
-    }
-
-    if (isset($aPlace['assvg'])) {
-        $aFilteredPlaces['svg'] = $aPlace['assvg'];
-    }
-
-    if (isset($aPlace['astext'])) {
-        $aFilteredPlaces['geotext'] = $aPlace['astext'];
-    }
-
-    if (isset($aPlace['askml'])) {
-        $aFilteredPlaces['geokml'] = $aPlace['askml'];
-    }
-}
-
-javascript_renderData($aFilteredPlaces);
index b997f6d97b1fcb01f7ed12b74f8f3468b5d8377a..774b5be08b3e6bca7db863ab6584542986416cbc 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-header('content-type: application/json; charset=UTF-8');
 
 $aFilteredPlaces = array();
 foreach ($aSearchResults as $iResNum => $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 (file)
index 7610330..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-$aFilteredPlaces = array();
-foreach ($aSearchResults as $iResNum => $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);
index b6d0f5e6de0b3d406bfc99f94ab25cf349403650..6df90029052bdf6c00443384d6e55f93672da485 100755 (executable)
@@ -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');
index 9f3ae470c03153edf35bede48eae9353660a33ed..346f5b5740a1f96380fb3518ec9b03cb7c259e1a 100755 (executable)
@@ -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');