X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e52ee350618d8cbbe2ab147bfb2cef6507d6e12e..228ef1972a915d1f960e021f4496147645e22370:/lib/template/address-geocodejson.php?ds=sidebyside diff --git a/lib/template/address-geocodejson.php b/lib/template/address-geocodejson.php index 92efc8fe..0066e80e 100644 --- a/lib/template/address-geocodejson.php +++ b/lib/template/address-geocodejson.php @@ -30,28 +30,19 @@ if (empty($aPlace)) { $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress']; - $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename']; + if ($aPlace['placename'] !== null) { + $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 +63,6 @@ if (empty($aPlace)) { 'licence' => 'ODbL', 'query' => $sQuery ), - 'features' => $aFilteredPlaces + 'features' => array($aFilteredPlaces) )); }