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:
Sarah Hoffmann
2018-07-10 23:38:27 +02:00
parent 320d488627
commit 25baaf530d
18 changed files with 195 additions and 213 deletions

View File

@@ -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."'";