X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1faa0f4d41da125dfb35d20dc2449e87f2497e20..64ace51e02790bf88e162a15236c5ac2af865c5e:/lib/ClassTypes.php?ds=sidebyside diff --git a/lib/ClassTypes.php b/lib/ClassTypes.php index 4b94d865..4077d211 100644 --- a/lib/ClassTypes.php +++ b/lib/ClassTypes.php @@ -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') { - $sLabel = getBoundaryLabel($iRank, $sCountry); + $sLabel = getBoundaryLabel($iRank/2, $sCountry); } elseif ($iRank < 26) { $sLabel = $aPlace['type']; } elseif ($iRank < 28) { @@ -32,7 +32,7 @@ function getLabelTag($aPlace, $sCountry = null) $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') { - 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 +82,18 @@ function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative' 6 => 'County', 7 => 'Municipality', 8 => 'City', - 9 => 'City District' + 9 => 'City District', 10 => 'Suburb', 11 => 'Neighbourhood' - ) + ), + 'no' => array ( + 3 => 'State', + 4 => 'County' + ), + 'se' => array ( + 3 => 'State', + 4 => 'County' + ) ); if (isset($aBoundaryList[$sCountry]) @@ -108,7 +116,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 +244,20 @@ function getIcon($aPlace) 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. * @@ -246,7 +268,10 @@ function getIcon($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', @@ -526,7 +551,8 @@ function getImportance($aPlace) 'railway:disused_station', 'railway:abandoned', 'railway:disused' - ); + )); + } $sClassPlace = $aPlace['class'].':'.$aPlace['type'];