]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/details.php
Merge pull request #1089 from lonvia/clean-up-address-computation
[nominatim.git] / website / details.php
index bc98d40058bc8302ef8b2d8feb9250bc2f4c9588..c9e86312c9cc63a8c9da6954db45b214c9adff4e 100755 (executable)
@@ -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();
@@ -106,7 +107,7 @@ $sSQL .= '    ROUND(EXTRACT(epoch FROM indexed_date)) AS indexed_epoch,';
 $sSQL .= '    parent_place_id, ';
 $sSQL .= '    rank_address, ';
 $sSQL .= '    rank_search, ';
-$sSQL .= '    get_searchrank_label(rank_search) AS rank_search_label,';
+$sSQL .= '    get_searchrank_label(rank_search) AS rank_search_label,'; // only used in HTML output
 $sSQL .= "    get_name_by_language(name,$sLanguagePrefArraySQL) AS localname, ";
 $sSQL .= "    ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') AS isarea, ";
 $sSQL .= '    ST_y(centroid) AS lat, ';
@@ -135,15 +136,7 @@ if (!$aPointDetails) {
 }
 
 $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
-
-$aClassType = getClassTypesWithImportance();
-
-$sPointClassType = $aPointDetails['class'].':'.$aPointDetails['type'];
-if (isset($aClassType[$sPointClassType]) && $aClassType[$sPointClassType]['icon']) {
-    $aPointDetails['icon'] = $aClassType[$sPointClassType]['icon'];
-} else {
-    $aPointDetails['icon'] = false;
-}
+$aPointDetails['icon'] = Nominatim\ClassTypes\getProperty($aPointDetails, 'icon', false);
 
 // Get all alternative names (languages, etc)
 $sSQL = 'SELECT (each(name)).key,(each(name)).value FROM placex ';
@@ -172,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