3 namespace Nominatim\ClassTypes;
6 * Create a label tag for the given place that can be used as an XML name.
8 * @param array[] $aPlace Information about the place to label.
10 * A label tag groups various object types together under a common
11 * label. The returned value is lower case and has no spaces
13 function getLabelTag($aPlace, $sCountry = null)
15 $iRank = (int) ($aPlace['rank_address'] ?? 30);
17 if (isset($aPlace['place_type'])) {
18 $sLabel = $aPlace['place_type'];
19 } elseif ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
20 $sLabel = getBoundaryLabel($iRank/2, $sCountry);
21 } elseif ($aPlace['type'] == 'postal_code') {
23 } elseif ($iRank < 26) {
24 $sLabel = $aPlace['type'];
25 } elseif ($iRank < 28) {
27 } elseif ($aPlace['class'] == 'place'
28 && ($aPlace['type'] == 'house_number' ||
29 $aPlace['type'] == 'house_name' ||
30 $aPlace['type'] == 'country_code')
32 $sLabel = $aPlace['type'];
34 $sLabel = $aPlace['class'];
37 return strtolower(str_replace(' ', '_', $sLabel));
41 * Create a label for the given place.
43 * @param array[] $aPlace Information about the place to label.
45 function getLabel($aPlace, $sCountry = null)
47 if (isset($aPlace['place_type'])) {
48 return ucwords(str_replace('_', ' ', $aPlace['place_type']));
51 if ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
52 return getBoundaryLabel(($aPlace['rank_address'] ?? 30)/2, $sCountry ?? null);
55 // Return a label only for 'important' class/type combinations
56 if (getImportance($aPlace) !== null) {
57 return ucwords(str_replace('_', ' ', $aPlace['type']));
65 * Return a simple label for an administrative boundary for the given country.
67 * @param int $iAdminLevel Content of admin_level tag.
68 * @param string $sCountry Country code of the country where the object is
69 * in. May be null, in which case a world-wide
71 * @param string $sFallback String to return if no explicit string is listed.
75 function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative')
77 static $aBoundaryList = array (
83 5 => 'State District',
89 11 => 'Neighbourhood',
102 if (isset($aBoundaryList[$sCountry])
103 && isset($aBoundaryList[$sCountry][$iAdminLevel])
105 return $aBoundaryList[$sCountry][$iAdminLevel];
108 return $aBoundaryList['default'][$iAdminLevel] ?? $sFallback;
112 * Return an estimated radius of how far the object node extends.
114 * @param array[] $aPlace Information about the place. This must be a node
117 * @return float The radius around the feature in degrees.
119 function getDefRadius($aPlace)
121 $aSpecialRadius = array(
122 'place:continent' => 25,
123 'place:country' => 7,
124 'place:state' => 2.6,
125 'place:province' => 2.6,
126 'place:region' => 1.0,
127 'place:county' => 0.7,
128 'place:city' => 0.16,
129 'place:municipality' => 0.16,
130 'place:island' => 0.32,
131 'place:postcode' => 0.16,
132 'place:town' => 0.04,
133 'place:village' => 0.02,
134 'place:hamlet' => 0.02,
135 'place:district' => 0.02,
136 'place:borough' => 0.02,
137 'place:suburb' => 0.02,
138 'place:locality' => 0.01,
139 'place:neighbourhood'=> 0.01,
140 'place:quarter' => 0.01,
141 'place:city_block' => 0.01,
142 'landuse:farm' => 0.01,
143 'place:farm' => 0.01,
144 'place:airport' => 0.015,
145 'aeroway:aerodrome' => 0.015,
146 'railway:station' => 0.005
149 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
151 return $aSpecialRadius[$sClassPlace] ?? 0.00005;
155 * Get the icon to use with the given object.
157 function getIcon($aPlace)
160 'boundary:administrative' => 'poi_boundary_administrative',
161 'place:city' => 'poi_place_city',
162 'place:town' => 'poi_place_town',
163 'place:village' => 'poi_place_village',
164 'place:hamlet' => 'poi_place_village',
165 'place:suburb' => 'poi_place_village',
166 'place:locality' => 'poi_place_village',
167 'place:airport' => 'transport_airport2',
168 'aeroway:aerodrome' => 'transport_airport2',
169 'railway:station' => 'transport_train_station2',
170 'amenity:place_of_worship' => 'place_of_worship_unknown3',
171 'amenity:pub' => 'food_pub',
172 'amenity:bar' => 'food_bar',
173 'amenity:university' => 'education_university',
174 'tourism:museum' => 'tourist_museum',
175 'amenity:arts_centre' => 'tourist_art_gallery2',
176 'tourism:zoo' => 'tourist_zoo',
177 'tourism:theme_park' => 'poi_point_of_interest',
178 'tourism:attraction' => 'poi_point_of_interest',
179 'leisure:golf_course' => 'sport_golf',
180 'historic:castle' => 'tourist_castle',
181 'amenity:hospital' => 'health_hospital',
182 'amenity:school' => 'education_school',
183 'amenity:theatre' => 'tourist_theatre',
184 'amenity:library' => 'amenity_library',
185 'amenity:fire_station' => 'amenity_firestation3',
186 'amenity:police' => 'amenity_police2',
187 'amenity:bank' => 'money_bank2',
188 'amenity:post_office' => 'amenity_post_office',
189 'tourism:hotel' => 'accommodation_hotel2',
190 'amenity:cinema' => 'tourist_cinema',
191 'tourism:artwork' => 'tourist_art_gallery2',
192 'historic:archaeological_site' => 'tourist_archaeological2',
193 'amenity:doctors' => 'health_doctors',
194 'leisure:sports_centre' => 'sport_leisure_centre',
195 'leisure:swimming_pool' => 'sport_swimming_outdoor',
196 'shop:supermarket' => 'shopping_supermarket',
197 'shop:convenience' => 'shopping_convenience',
198 'amenity:restaurant' => 'food_restaurant',
199 'amenity:fast_food' => 'food_fastfood',
200 'amenity:cafe' => 'food_cafe',
201 'tourism:guest_house' => 'accommodation_bed_and_breakfast',
202 'amenity:pharmacy' => 'health_pharmacy_dispensing',
203 'amenity:fuel' => 'transport_fuel',
204 'natural:peak' => 'poi_peak',
205 'natural:wood' => 'landuse_coniferous_and_deciduous',
206 'shop:bicycle' => 'shopping_bicycle',
207 'shop:clothes' => 'shopping_clothes',
208 'shop:hairdresser' => 'shopping_hairdresser',
209 'shop:doityourself' => 'shopping_diy',
210 'shop:estate_agent' => 'shopping_estateagent2',
211 'shop:car' => 'shopping_car',
212 'shop:garden_centre' => 'shopping_garden_centre',
213 'shop:car_repair' => 'shopping_car_repair',
214 'shop:bakery' => 'shopping_bakery',
215 'shop:butcher' => 'shopping_butcher',
216 'shop:apparel' => 'shopping_clothes',
217 'shop:laundry' => 'shopping_laundrette',
218 'shop:beverages' => 'shopping_alcohol',
219 'shop:alcohol' => 'shopping_alcohol',
220 'shop:optician' => 'health_opticians',
221 'shop:chemist' => 'health_pharmacy',
222 'shop:gallery' => 'tourist_art_gallery2',
223 'shop:jewelry' => 'shopping_jewelry',
224 'tourism:information' => 'amenity_information',
225 'historic:ruins' => 'tourist_ruin',
226 'amenity:college' => 'education_school',
227 'historic:monument' => 'tourist_monument',
228 'historic:memorial' => 'tourist_monument',
229 'historic:mine' => 'poi_mine',
230 'tourism:caravan_site' => 'accommodation_caravan_park',
231 'amenity:bus_station' => 'transport_bus_station',
232 'amenity:atm' => 'money_atm2',
233 'tourism:viewpoint' => 'tourist_view_point',
234 'tourism:guesthouse' => 'accommodation_bed_and_breakfast',
235 'railway:tram' => 'transport_tram_stop',
236 'amenity:courthouse' => 'amenity_court',
237 'amenity:recycling' => 'amenity_recycling',
238 'amenity:dentist' => 'health_dentist',
239 'natural:beach' => 'tourist_beach',
240 'railway:tram_stop' => 'transport_tram_stop',
241 'amenity:prison' => 'amenity_prison',
242 'highway:bus_stop' => 'transport_bus_stop2'
245 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
247 return $aIcons[$sClassPlace] ?? null;
251 * Get an icon for the given object with its full URL.
253 function getIconFile($aPlace)
255 $sIcon = getIcon($aPlace);
257 if (!isset($sIcon)) {
261 return CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.p.20.png';
265 * Return a class importance value for the given place.
267 * @param array[] $aPlace Information about the place.
269 * @return int An importance value. The lower the value, the more
270 * important the class.
272 function getImportance($aPlace)
274 static $aWithImportance = null;
276 if ($aWithImportance === null) {
277 $aWithImportance = array_flip(array(
292 'highway:motorway_junction',
298 'highway:residential',
299 'highway:unclassified',
300 'highway:living_street',
307 'highway:pedestrian',
310 'highway:motorway_link',
311 'highway:trunk_link',
312 'highway:primary_link',
313 'landuse:industrial',
314 'landuse:residential',
316 'landuse:commercial',
320 'amenity:place_of_worship',
323 'amenity:university',
325 'amenity:arts_centre',
327 'tourism:theme_park',
328 'tourism:attraction',
329 'leisure:golf_course',
334 'amenity:public_building',
337 'amenity:community_centre',
338 'amenity:fire_station',
341 'amenity:post_office',
345 'landuse:recreation_ground',
350 'historic:archaeological_site',
352 'leisure:sports_centre',
353 'leisure:swimming_pool',
356 'amenity:restaurant',
359 'tourism:guest_house',
363 'waterway:waterfall',
368 'landuse:allotments',
380 'shop:garden_centre',
388 'shop:department_store',
412 'shop:shopping_centre',
419 'shop:travel_agency',
422 'tourism:information',
425 'place:house_number',
426 'place:country_code',
428 'highway:unsurfaced',
434 'leisure:nature_reserve',
436 'waterway:lock_gate',
442 'leisure:playground',
446 'tourism:caravan_site',
447 'amenity:bus_station',
448 'amenity:kindergarten',
449 'highway:construction',
451 'amenity:emergency_phone',
453 'waterway:riverbank',
457 'tourism:bed_and_breakfast',
461 'amenity:courthouse',
466 'amenity:grave_yard',
469 'landuse:village_green',
475 'railway:light_rail',
476 'railway:narrow_gauge',
478 'amenity:village_hall',
480 'amenity:veterinary',
481 'landuse:brownfield',
483 'railway:historic_station',
484 'landuse:construction',
488 'highway:traffic_signals',
491 'amenity:social_club',
493 'amenity:health_centre',
497 'amenity:ferry_terminal',
503 'amenity:car_rental',
506 'amenity:nursing_home',
510 'highway:mini_roundabout',
513 'amenity:bicycle_parking',
517 'natural:cave_entrance',
518 'amenity:crematorium',
519 'tourism:picnic_site',
528 'amenity:medical_centre',
529 'historic:roman_road',
531 'railway:subway_entrance',
537 'railway:level_crossing',
540 'tourism:apartments',
552 'waterway:derelict_canal',
554 'railway:disused_station',
560 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
562 return $aWithImportance[$sClassPlace] ?? null;