X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1faa0f4d41da125dfb35d20dc2449e87f2497e20..61e3a053723a6a1131e234aa8ad1a37f18bbec56:/lib/ClassTypes.php?ds=sidebyside diff --git a/lib/ClassTypes.php b/lib/ClassTypes.php index 4b94d865..f2c1ab84 100644 --- a/lib/ClassTypes.php +++ b/lib/ClassTypes.php @@ -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,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 +118,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 +246,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 +270,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 +553,8 @@ function getImportance($aPlace) 'railway:disused_station', 'railway:abandoned', 'railway:disused' - ); + )); + } $sClassPlace = $aPlace['class'].':'.$aPlace['type'];