]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/address-geocodejson.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / template / address-geocodejson.php
index 92efc8fec784a12b302d61d99bac8969601cd6ef..032dcf4347a1046eb684a517af6cebb980aef176 100644 (file)
@@ -32,25 +32,29 @@ if (empty($aPlace)) {
 
     $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
 
 
     $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'])) {
+        $aFieldMappings = array(
+                           'house_number' => 'housenumber',
+                           'road' => 'street',
+                           'locality' => 'locality',
+                           'postcode' => 'postcode',
+                           'city' => 'city',
+                           'district' => 'district',
+                           'county' => 'county',
+                           'state' => 'state',
+                           'country' => 'country'
+                          );
 
 
-    foreach ($aFieldMappings as $sFrom => $sTo) {
-        if (isset($aPlace['aAddress'][$sFrom])) {
-            $aFilteredPlaces['properties']['geocoding'][$sTo] = $aPlace['aAddress'][$sFrom];
+        $aAddressNames = $aPlace['address']->getAddressNames();
+        foreach ($aFieldMappings as $sFrom => $sTo) {
+            if (isset($aAddressNames[$sFrom])) {
+                $aFilteredPlaces['properties']['geocoding'][$sTo] = $aAddressNames[$sFrom];
+            }
         }
         }
-    }
 
 
-    $aFilteredPlaces['properties']['geocoding']['admin'] = $aPlace['aAddressAdminLevels'];
+        $aFilteredPlaces['properties']['geocoding']['admin']
+            = $aPlace['address']->getAdminLevels();
+    }
 
     if (isset($aPlace['asgeojson'])) {
         $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
 
     if (isset($aPlace['asgeojson'])) {
         $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
@@ -72,6 +76,6 @@ if (empty($aPlace)) {
                                            'licence' => 'ODbL',
                                            'query' => $sQuery
                                           ),
                                            'licence' => 'ODbL',
                                            'query' => $sQuery
                                           ),
-                           'features' => $aFilteredPlaces
+                           'features' => array($aFilteredPlaces)
                           ));
 }
                           ));
 }