mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 05:18:00 +00:00
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:
35
lib/lib.php
35
lib/lib.php
@@ -83,41 +83,6 @@ function javascript_renderData($xVal, $iOptions = 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getAddressDetails(&$oDB, $sLanguagePrefArraySQL, $iPlaceID, $sCountryCode = false, $housenumber = -1, $bRaw = false)
|
||||
{
|
||||
$sSQL = "select *,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata($iPlaceID, $housenumber)";
|
||||
if (!$bRaw) $sSQL .= " WHERE isaddress OR type = 'country_code'";
|
||||
$sSQL .= ' order by rank_address desc,isaddress desc';
|
||||
|
||||
$aAddressLines = chksql($oDB->getAll($sSQL));
|
||||
if ($bRaw) return $aAddressLines;
|
||||
//echo "<pre>";
|
||||
//var_dump($aAddressLines);
|
||||
$aAddress = array();
|
||||
$aFallback = array();
|
||||
foreach ($aAddressLines as $aLine) {
|
||||
$bFallback = false;
|
||||
$aTypeLabel = Nominatim\ClassTypes\getInfo($aLine);
|
||||
|
||||
if ($aTypeLabel === false) {
|
||||
$aTypeLabel = Nominatim\ClassTypes\getFallbackInfo($aLine);
|
||||
$bFallback = true;
|
||||
}
|
||||
|
||||
if ((isset($aLine['localname']) && $aLine['localname']) || (isset($aLine['housenumber']) && $aLine['housenumber'])) {
|
||||
$sTypeLabel = strtolower(isset($aTypeLabel['simplelabel'])?$aTypeLabel['simplelabel']:$aTypeLabel['label']);
|
||||
$sTypeLabel = str_replace(' ', '_', $sTypeLabel);
|
||||
if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel]) || $aLine['class'] == 'place') {
|
||||
$aAddress[$sTypeLabel] = $aLine['localname']?$aLine['localname']:$aLine['housenumber'];
|
||||
}
|
||||
$aFallback[$sTypeLabel] = $bFallback;
|
||||
}
|
||||
}
|
||||
return $aAddress;
|
||||
}
|
||||
|
||||
|
||||
function addQuotes($s)
|
||||
{
|
||||
return "'".$s."'";
|
||||
|
||||
Reference in New Issue
Block a user