]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/address-geocodejson.php
address ranks must not invert admin_level hierarchy
[nominatim.git] / lib / template / address-geocodejson.php
index 68fae7d1605dcde0b883be5e806dec791d662291..0066e80e29adb13cce8320360c57eafddf7ba87e 100644 (file)
@@ -30,27 +30,14 @@ if (empty($aPlace)) {
 
     $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress'];
 
 
     $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress'];
 
-    $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
+    if ($aPlace['placename'] !== null) {
+        $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
+    }
 
     if (isset($aPlace['address'])) {
 
     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'
-                          );
-
-        $aAddressNames = $aPlace['address']->getAddressNames();
-        foreach ($aFieldMappings as $sFrom => $sTo) {
-            if (isset($aAddressNames[$sFrom])) {
-                $aFilteredPlaces['properties']['geocoding'][$sTo] = $aAddressNames[$sFrom];
-            }
-        }
+        $aPlace['address']->addGeocodeJsonAddressParts(
+            $aFilteredPlaces['properties']['geocoding']
+        );
 
         $aFilteredPlaces['properties']['geocoding']['admin']
             = $aPlace['address']->getAdminLevels();
 
         $aFilteredPlaces['properties']['geocoding']['admin']
             = $aPlace['address']->getAdminLevels();
@@ -76,6 +63,6 @@ if (empty($aPlace)) {
                                            'licence' => 'ODbL',
                                            'query' => $sQuery
                                           ),
                                            'licence' => 'ODbL',
                                            'query' => $sQuery
                                           ),
-                           'features' => [$aFilteredPlaces]
+                           'features' => array($aFilteredPlaces)
                           ));
 }
                           ));
 }