forked from hans/Nominatim
unify address details lookup
Introduces new AddressDetails class which is responsible for address lookups. Saves always the complete result and then allows filtering throught the different access function. Remove special handling in Geocode() and use there the lookup throught PlaceLookup() as well.
This commit is contained in:
@@ -32,25 +32,29 @@ 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'])) {
|
||||
$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']);
|
||||
|
||||
@@ -33,7 +33,9 @@ if (empty($aPlace)) {
|
||||
|
||||
$aFilteredPlaces['properties']['display_name'] = $aPlace['langaddress'];
|
||||
|
||||
if (isset($aPlace['aAddress'])) $aFilteredPlaces['properties']['address'] = $aPlace['aAddress'];
|
||||
if (isset($aPlace['address'])) {
|
||||
$aFilteredPlaces['properties']['address'] = $aPlace['address']->getAddressNames();
|
||||
}
|
||||
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['properties']['extratags'] = $aPlace['sExtraTags'];
|
||||
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['properties']['namedetails'] = $aPlace['sNameDetails'];
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ if (empty($aPlace)) {
|
||||
|
||||
$aFilteredPlaces['display_name'] = $aPlace['langaddress'];
|
||||
|
||||
if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
|
||||
if (isset($aPlace['address'])) {
|
||||
$aFilteredPlaces['address'] = $aPlace['address']->getAddressNames();
|
||||
}
|
||||
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
|
||||
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ if (empty($aPlace)) {
|
||||
}
|
||||
echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
|
||||
|
||||
if (isset($aPlace['aAddress'])) {
|
||||
if (isset($aPlace['address'])) {
|
||||
echo '<addressparts>';
|
||||
foreach ($aPlace['aAddress'] as $sKey => $sValue) {
|
||||
foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
|
||||
$sKey = str_replace(' ', '_', $sKey);
|
||||
echo "<$sKey>";
|
||||
echo htmlspecialchars($sValue);
|
||||
|
||||
@@ -49,8 +49,8 @@ foreach ($aBatchResults as $aSearchResults) {
|
||||
$aPlace['icon'] = $aPointDetails['icon'];
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
|
||||
$aPlace['address'] = $aPointDetails['address'];
|
||||
if (isset($aPointDetails['address'])) {
|
||||
$aPlace['address'] = $aPointDetails['address']->getAddressNames();
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['asgeojson'])) {
|
||||
|
||||
@@ -22,25 +22,29 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) {
|
||||
|
||||
$aPlace['properties']['geocoding']['name'] = $aPointDetails['placename'];
|
||||
|
||||
$aFieldMappings = array(
|
||||
'house_number' => 'housenumber',
|
||||
'road' => 'street',
|
||||
'locality' => 'locality',
|
||||
'postcode' => 'postcode',
|
||||
'city' => 'city',
|
||||
'district' => 'district',
|
||||
'county' => 'county',
|
||||
'state' => 'state',
|
||||
'country' => 'country'
|
||||
);
|
||||
if (isset($aPointDetails['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($aPointDetails['address'][$sFrom])) {
|
||||
$aPlace['properties']['geocoding'][$sTo] = $aPointDetails['address'][$sFrom];
|
||||
$aAddrNames = $aPointDetails['address']->getAddressNames();
|
||||
foreach ($aFieldMappings as $sFrom => $sTo) {
|
||||
if (isset($aAddrNames[$sFrom])) {
|
||||
$aPlace['properties']['geocoding'][$sTo] = $aAddrNames[$sFrom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aPlace['properties']['geocoding']['admin'] = $aPointDetails['aAddressAdminLevels'];
|
||||
$aPlace['properties']['geocoding']['admin']
|
||||
= $aPointDetails['address']->getAdminLevels();
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['asgeojson'])) {
|
||||
$aPlace['geometry'] = json_decode($aPointDetails['asgeojson']);
|
||||
|
||||
@@ -41,8 +41,8 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) {
|
||||
$aPlace['properties']['icon'] = $aPointDetails['icon'];
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
|
||||
$aPlace['properties']['address'] = $aPointDetails['address'];
|
||||
if (isset($aPointDetails['address'])) {
|
||||
$aPlace['properties']['address'] = $aPointDetails['address']->getAddressNames();
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['asgeojson'])) {
|
||||
|
||||
@@ -44,8 +44,8 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) {
|
||||
$aPlace['icon'] = $aPointDetails['icon'];
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
|
||||
$aPlace['address'] = $aPointDetails['address'];
|
||||
if (isset($aPointDetails['address'])) {
|
||||
$aPlace['address'] = $aPointDetails['address']->getAddressNames();
|
||||
}
|
||||
|
||||
if (isset($aPointDetails['asgeojson'])) {
|
||||
|
||||
@@ -116,7 +116,7 @@ foreach ($aSearchResults as $iResNum => $aResult) {
|
||||
echo '>';
|
||||
}
|
||||
echo "\n";
|
||||
foreach ($aResult['address'] as $sKey => $sValue) {
|
||||
foreach ($aResult['address']->getAddressNames() as $sKey => $sValue) {
|
||||
$sKey = str_replace(' ', '_', $sKey);
|
||||
echo "<$sKey>";
|
||||
echo htmlspecialchars($sValue);
|
||||
|
||||
Reference in New Issue
Block a user