]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/ClassTypes.php
rename nominatim.admin to nominatim.tools
[nominatim.git] / lib / ClassTypes.php
index 4b94d86539b716ee18911b88f7e96621b2dba14c..bb7b0486cb628c687c342faa9faea86a8032ad5c 100644 (file)
@@ -17,7 +17,9 @@ function getLabelTag($aPlace, $sCountry = null)
     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 ($aPlace['type'] == 'postal_code') {
+        $sLabel = 'postcode';
     } elseif ($iRank < 26) {
         $sLabel = $aPlace['type'];
     } elseif ($iRank < 28) {
@@ -32,7 +34,7 @@ function getLabelTag($aPlace, $sCountry = null)
         $sLabel = $aPlace['class'];
     }
 
-    return strtolower(str_replace('_', ' ', $sLabel));
+    return strtolower(str_replace(' ', '_', $sLabel));
 }
 
 /**
@@ -47,11 +49,11 @@ function getLabel($aPlace, $sCountry = null)
     }
 
     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
-    if (isset(getImportance($aPlace)) {
+    if (getImportance($aPlace) !== null) {
         return ucwords(str_replace('_', ' ', $aPlace['type']));
     }
 
@@ -82,10 +84,19 @@ function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative'
                                            6 => 'County',
                                            7 => 'Municipality',
                                            8 => 'City',
-                                           9 => 'City District'
+                                           9 => 'City District',
                                            10 => 'Suburb',
-                                           11 => 'Neighbourhood'
-                                           )
+                                           11 => 'Neighbourhood',
+                                           12 => 'City Block'
+                                          ),
+                             'no' => array (
+                                      3 => 'State',
+                                      4 => 'County'
+                                     ),
+                             'se' => array (
+                                      3 => 'State',
+                                      4 => 'County'
+                                     )
             );
 
     if (isset($aBoundaryList[$sCountry])
@@ -108,7 +119,7 @@ function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative'
 function getDefRadius($aPlace)
 {
     $aSpecialRadius = array(
-                       'place:continent' => 25
+                       'place:continent' => 25,
                        'place:country' => 7,
                        'place:state' => 2.6,
                        'place:province' => 2.6,
@@ -236,6 +247,24 @@ function getIcon($aPlace)
     return $aIcons[$sClassPlace] ?? null;
 }
 
+/**
+ * Get an icon for the given object with its full URL.
+ */
+function getIconFile($aPlace)
+{
+    if (CONST_MapIcon_URL === false) {
+        return null;
+    }
+
+    $sIcon = getIcon($aPlace);
+
+    if (!isset($sIcon)) {
+        return null;
+    }
+
+    return CONST_MapIcon_URL.'/'.$sIcon.'.p.20.png';
+}
+
 /**
  * Return a class importance value for the given place.
  *
@@ -246,7 +275,11 @@ function getIcon($aPlace)
  */
 function getImportance($aPlace)
 {
-    static $aWithImportance = array_flip(array(
+    static $aWithImportance = null;
+
+    if ($aWithImportance === null) {
+        $aWithImportance = array_flip(array(
+                                           'boundary:administrative',
                                            'place:country',
                                            'place:state',
                                            'place:province',
@@ -526,7 +559,8 @@ function getImportance($aPlace)
                                            'railway:disused_station',
                                            'railway:abandoned',
                                            'railway:disused'
-                );
+                ));
+    }
 
     $sClassPlace = $aPlace['class'].':'.$aPlace['type'];