]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/hierarchy.php
Merge pull request #1186 from mtmail/getAddressDetails-fix
[nominatim.git] / website / hierarchy.php
index 8f2f5237e6ccada5de2e97168733569089fa4539..3ac4f3231a8a8f2d43a22c3db8ea41f5c1cd3b16 100755 (executable)
@@ -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(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');
 
 require_once(CONST_BasePath.'/lib/output.php');
 ini_set('memory_limit', '200M');
 
@@ -56,13 +56,11 @@ if (CONST_Use_Aux_Location_data) {
     if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
 }
 
     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 (!sizeof($aPlaceAddress)) userError('Unknown place id.');
+if (empty($aPlaceAddress)) userError('Unknown place id.');
 
 $aBreadcrums = array();
 foreach ($aPlaceAddress as $i => $aPlace) {
 
 $aBreadcrums = array();
 foreach ($aPlaceAddress as $i => $aPlace) {
@@ -100,20 +98,14 @@ $sSQL .= ' where parent_place_id in ('.join(',', $aRelatedPlaceIDs).') and name
 $sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber';
 $aParentOfLines = chksql($oDB->getAll($sSQL));
 
 $sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber';
 $aParentOfLines = chksql($oDB->getAll($sSQL));
 
-if (sizeof($aParentOfLines)) {
+if (!empty($aParentOfLines)) {
     echo '<h2>Parent Of:</h2>';
     echo '<h2>Parent Of:</h2>';
-    $aClassType = getClassTypesWithImportance();
     $aGroupedAddressLines = array();
     foreach ($aParentOfLines as $aAddressLine) {
     $aGroupedAddressLines = array();
     foreach ($aParentOfLines as $aAddressLine) {
-        if (isset($aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label'])
-            && $aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label']
-        ) {
-            $aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label'];
-        } elseif (isset($aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'])
-            && $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label']
-        ) {
-            $aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'];
-        } else $aAddressLine['label'] = ucwords($aAddressLine['type']);
+        $aAddressLine['label'] = Nominatim\ClassTypes\getProperty($aAddressLine, 'label');
+        if (!$aAddressLine['label']) {
+            $aAddressLine['label'] = ucwords($aAddressLine['type']);
+        }
 
         if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
             $aGroupedAddressLines[$aAddressLine['label']][] = $aAddressLine;
 
         if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
             $aGroupedAddressLines[$aAddressLine['label']][] = $aAddressLine;
@@ -136,7 +128,7 @@ if (sizeof($aParentOfLines)) {
             echo '</div>';
         }
     }
             echo '</div>';
         }
     }
-    if (sizeof($aParentOfLines) >= 500) {
+    if (count($aParentOfLines) >= 500) {
         echo '<p>There are more child objects which are not shown.</p>';
     }
     echo '</div>';
         echo '<p>There are more child objects which are not shown.</p>';
     }
     echo '</div>';