X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/12db7a9af2cdabf4a273c45542824d4a051501c9..2ab9e4acd3a2ceb5ff871b6b6afc786377e8739f:/lib/template/address-geocodejson.php?ds=sidebyside diff --git a/lib/template/address-geocodejson.php b/lib/template/address-geocodejson.php index 032dcf43..0066e80e 100644 --- a/lib/template/address-geocodejson.php +++ b/lib/template/address-geocodejson.php @@ -30,27 +30,14 @@ 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']; + } 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();