]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/ClassTypes.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / ClassTypes.php
index 4b94d86539b716ee18911b88f7e96621b2dba14c..4077d211bc94a211420838ac892cc7bcc4b6e21a 100644 (file)
@@ -17,7 +17,7 @@ function getLabelTag($aPlace, $sCountry = null)
     if (isset($aPlace['place_type'])) {
         $sLabel = $aPlace['place_type'];
     } elseif ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
     if (isset($aPlace['place_type'])) {
         $sLabel = $aPlace['place_type'];
     } elseif ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
-        $sLabel = getBoundaryLabel($iRank, $sCountry);
+        $sLabel = getBoundaryLabel($iRank/2, $sCountry);
     } elseif ($iRank < 26) {
         $sLabel = $aPlace['type'];
     } elseif ($iRank < 28) {
     } elseif ($iRank < 26) {
         $sLabel = $aPlace['type'];
     } elseif ($iRank < 28) {
@@ -32,7 +32,7 @@ function getLabelTag($aPlace, $sCountry = null)
         $sLabel = $aPlace['class'];
     }
 
         $sLabel = $aPlace['class'];
     }
 
-    return strtolower(str_replace('_', ' ', $sLabel));
+    return strtolower(str_replace(' ', '_', $sLabel));
 }
 
 /**
 }
 
 /**
@@ -47,11 +47,11 @@ function getLabel($aPlace, $sCountry = null)
     }
 
     if ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
     }
 
     if ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
-        return getBoundaryLabel((int)($aPlace['admin_level'] ?? 15, $sCountry ?? null);
+        return getBoundaryLabel(($aPlace['rank_address'] ?? 30)/2, $sCountry ?? null);
     }
 
     // Return a label only for 'important' class/type combinations
     }
 
     // Return a label only for 'important' class/type combinations
-    if (isset(getImportance($aPlace)) {
+    if (getImportance($aPlace) !== null) {
         return ucwords(str_replace('_', ' ', $aPlace['type']));
     }
 
         return ucwords(str_replace('_', ' ', $aPlace['type']));
     }
 
@@ -82,10 +82,18 @@ function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative'
                                            6 => 'County',
                                            7 => 'Municipality',
                                            8 => 'City',
                                            6 => 'County',
                                            7 => 'Municipality',
                                            8 => 'City',
-                                           9 => 'City District'
+                                           9 => 'City District',
                                            10 => 'Suburb',
                                            11 => 'Neighbourhood'
                                            10 => 'Suburb',
                                            11 => 'Neighbourhood'
-                                           )
+                                          ),
+                             'no' => array (
+                                      3 => 'State',
+                                      4 => 'County'
+                                     ),
+                             'se' => array (
+                                      3 => 'State',
+                                      4 => 'County'
+                                     )
             );
 
     if (isset($aBoundaryList[$sCountry])
             );
 
     if (isset($aBoundaryList[$sCountry])
@@ -108,7 +116,7 @@ function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative'
 function getDefRadius($aPlace)
 {
     $aSpecialRadius = array(
 function getDefRadius($aPlace)
 {
     $aSpecialRadius = array(
-                       'place:continent' => 25
+                       'place:continent' => 25,
                        'place:country' => 7,
                        'place:state' => 2.6,
                        'place:province' => 2.6,
                        'place:country' => 7,
                        'place:state' => 2.6,
                        'place:province' => 2.6,
@@ -236,6 +244,20 @@ function getIcon($aPlace)
     return $aIcons[$sClassPlace] ?? null;
 }
 
     return $aIcons[$sClassPlace] ?? null;
 }
 
+/**
+ * Get an icon for the given object with its full URL.
+ */
+function getIconFile($aPlace)
+{
+    $sIcon = getIcon($aPlace);
+
+    if (!isset($sIcon)) {
+        return null;
+    }
+
+    return CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.p.20.png';
+}
+
 /**
  * Return a class importance value for the given place.
  *
 /**
  * Return a class importance value for the given place.
  *
@@ -246,7 +268,10 @@ function getIcon($aPlace)
  */
 function getImportance($aPlace)
 {
  */
 function getImportance($aPlace)
 {
-    static $aWithImportance = array_flip(array(
+    static $aWithImportance = null;
+
+    if ($aWithImportance === null) {
+        $aWithImportance = array_flip(array(
                                            'place:country',
                                            'place:state',
                                            'place:province',
                                            'place:country',
                                            'place:state',
                                            'place:province',
@@ -526,7 +551,8 @@ function getImportance($aPlace)
                                            'railway:disused_station',
                                            'railway:abandoned',
                                            'railway:disused'
                                            'railway:disused_station',
                                            'railway:abandoned',
                                            'railway:disused'
-                );
+                ));
+    }
 
     $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
 
 
     $sClassPlace = $aPlace['class'].':'.$aPlace['type'];