mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +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:
@@ -5,6 +5,7 @@ require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||
require_once(CONST_BasePath.'/lib/log.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
require_once(CONST_BasePath.'/lib/AddressDetails.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oParams = new Nominatim\ParameterParser();
|
||||
@@ -164,14 +165,8 @@ if (PEAR::isError($aPointDetails['aExtraTags'])) { // possible timeout
|
||||
// Address
|
||||
$aAddressLines = false;
|
||||
if ($bIncludeAddressDetails) {
|
||||
$aAddressLines = getAddressDetails(
|
||||
$oDB,
|
||||
$sLanguagePrefArraySQL,
|
||||
$iPlaceID,
|
||||
$aPointDetails['country_code'],
|
||||
-1,
|
||||
true
|
||||
);
|
||||
$oDetails = new Nominatim\AddressDetails($oDB, $iPlaceID, -1, $sLanguagePrefArraySQL);
|
||||
$aAddressLines = $oDetails->getAddressDetails(true);
|
||||
}
|
||||
|
||||
// Linked places
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||
require_once(CONST_BasePath.'/lib/log.php');
|
||||
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/AddressDetails.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
@@ -56,11 +56,9 @@ if (CONST_Use_Aux_Location_data) {
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
|
||||
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
|
||||
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
|
||||
$oAddressLookup = new AddressDetails($oDB, $iPlaceID, -1, $aLangPrefOrder);
|
||||
$aPlaceAddress = array_reverse($oAddressLookup->getAddressDetails());
|
||||
|
||||
if (empty($aPlaceAddress)) userError('Unknown place id.');
|
||||
|
||||
@@ -106,7 +104,7 @@ if (!empty($aParentOfLines)) {
|
||||
foreach ($aParentOfLines as $aAddressLine) {
|
||||
$aAddressLine['label'] = Nominatim\ClassTypes\getProperty($aAddressLine, 'label');
|
||||
if (!$aAddressLine['label']) {
|
||||
$aAddressLine['label'] = ucwords($aAddressLine['type']);
|
||||
$aAddressLine['label'] = ucwords($aAddressLine['type']);
|
||||
}
|
||||
|
||||
if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
|
||||
|
||||
@@ -25,6 +25,7 @@ $aCleanedQueryParts = array();
|
||||
|
||||
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
||||
$oPlaceLookup->loadParamArray($oParams);
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
|
||||
$aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
||||
$oPlaceLookup->loadParamArray($oParams);
|
||||
if ($sOutputFormat == 'geocodejson') {
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
$oPlaceLookup->setAddressAdminLevels(true);
|
||||
}
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
|
||||
$sOsmType = $oParams->getSet('osm_type', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osm_id', -1);
|
||||
|
||||
Reference in New Issue
Block a user