]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/address-geocodejson.php
ignore isaddress in details output when it is not present
[nominatim.git] / lib / template / address-geocodejson.php
index 92efc8fec784a12b302d61d99bac8969601cd6ef..98c368b324b0342b7cb3d2db804eec02337cde7c 100644 (file)
@@ -32,26 +32,15 @@ if (empty($aPlace)) {
 
     $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
 
-    $aFieldMappings = array(
-                       'house_number' => 'housenumber',
-                       'road' => 'street',
-                       'locality' => 'locality',
-                       'postcode' => 'postcode',
-                       'city' => 'city',
-                       'district' => 'district',
-                       'county' => 'county',
-                       'state' => 'state',
-                       'country' => 'country'
-                      );
+    if (isset($aPlace['address'])) {
+        $aPlace['address']->addGeocodeJsonAddressParts(
+            $aFilteredPlaces['properties']['geocoding']
+        );
 
-    foreach ($aFieldMappings as $sFrom => $sTo) {
-        if (isset($aPlace['aAddress'][$sFrom])) {
-            $aFilteredPlaces['properties']['geocoding'][$sTo] = $aPlace['aAddress'][$sFrom];
-        }
+        $aFilteredPlaces['properties']['geocoding']['admin']
+            = $aPlace['address']->getAdminLevels();
     }
 
-    $aFilteredPlaces['properties']['geocoding']['admin'] = $aPlace['aAddressAdminLevels'];
-
     if (isset($aPlace['asgeojson'])) {
         $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
     } else {
@@ -72,6 +61,6 @@ if (empty($aPlace)) {
                                            'licence' => 'ODbL',
                                            'query' => $sQuery
                                           ),
-                           'features' => $aFilteredPlaces
+                           'features' => array($aFilteredPlaces)
                           ));
 }