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',
101 if (isset($aBoundaryList[$sCountry])
102 && isset($aBoundaryList[$sCountry][$iAdminLevel])
104 return $aBoundaryList[$sCountry][$iAdminLevel];
107 return $aBoundaryList['default'][$iAdminLevel] ?? $sFallback;
111 * Return an estimated radius of how far the object node extends.
113 * @param array[] $aPlace Information about the place. This must be a node
116 * @return float The radius around the feature in degrees.
118 function getDefRadius($aPlace)
120 $aSpecialRadius = array(
121 'place:continent' => 25,
122 'place:country' => 7,
123 'place:state' => 2.6,
124 'place:province' => 2.6,
125 'place:region' => 1.0,
126 'place:county' => 0.7,
127 'place:city' => 0.16,
128 'place:municipality' => 0.16,
129 'place:island' => 0.32,
130 'place:postcode' => 0.16,
131 'place:town' => 0.04,
132 'place:village' => 0.02,
133 'place:hamlet' => 0.02,
134 'place:district' => 0.02,
135 'place:borough' => 0.02,
136 'place:suburb' => 0.02,
137 'place:locality' => 0.01,
138 'place:neighbourhood'=> 0.01,
139 'place:quarter' => 0.01,
140 'place:city_block' => 0.01,
141 'landuse:farm' => 0.01,
142 'place:farm' => 0.01,
143 'place:airport' => 0.015,
144 'aeroway:aerodrome' => 0.015,
145 'railway:station' => 0.005
148 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
150 return $aSpecialRadius[$sClassPlace] ?? 0.00005;
154 * Get the icon to use with the given object.
156 function getIcon($aPlace)
159 'boundary:administrative' => 'poi_boundary_administrative',
160 'place:city' => 'poi_place_city',
161 'place:town' => 'poi_place_town',
162 'place:village' => 'poi_place_village',
163 'place:hamlet' => 'poi_place_village',
164 'place:suburb' => 'poi_place_village',
165 'place:locality' => 'poi_place_village',
166 'place:airport' => 'transport_airport2',
167 'aeroway:aerodrome' => 'transport_airport2',
168 'railway:station' => 'transport_train_station2',
169 'amenity:place_of_worship' => 'place_of_worship_unknown3',
170 'amenity:pub' => 'food_pub',
171 'amenity:bar' => 'food_bar',
172 'amenity:university' => 'education_university',
173 'tourism:museum' => 'tourist_museum',
174 'amenity:arts_centre' => 'tourist_art_gallery2',
175 'tourism:zoo' => 'tourist_zoo',
176 'tourism:theme_park' => 'poi_point_of_interest',
177 'tourism:attraction' => 'poi_point_of_interest',
178 'leisure:golf_course' => 'sport_golf',
179 'historic:castle' => 'tourist_castle',
180 'amenity:hospital' => 'health_hospital',
181 'amenity:school' => 'education_school',
182 'amenity:theatre' => 'tourist_theatre',
183 'amenity:library' => 'amenity_library',
184 'amenity:fire_station' => 'amenity_firestation3',
185 'amenity:police' => 'amenity_police2',
186 'amenity:bank' => 'money_bank2',
187 'amenity:post_office' => 'amenity_post_office',
188 'tourism:hotel' => 'accommodation_hotel2',
189 'amenity:cinema' => 'tourist_cinema',
190 'tourism:artwork' => 'tourist_art_gallery2',
191 'historic:archaeological_site' => 'tourist_archaeological2',
192 'amenity:doctors' => 'health_doctors',
193 'leisure:sports_centre' => 'sport_leisure_centre',
194 'leisure:swimming_pool' => 'sport_swimming_outdoor',
195 'shop:supermarket' => 'shopping_supermarket',
196 'shop:convenience' => 'shopping_convenience',
197 'amenity:restaurant' => 'food_restaurant',
198 'amenity:fast_food' => 'food_fastfood',
199 'amenity:cafe' => 'food_cafe',
200 'tourism:guest_house' => 'accommodation_bed_and_breakfast',
201 'amenity:pharmacy' => 'health_pharmacy_dispensing',
202 'amenity:fuel' => 'transport_fuel',
203 'natural:peak' => 'poi_peak',
204 'natural:wood' => 'landuse_coniferous_and_deciduous',
205 'shop:bicycle' => 'shopping_bicycle',
206 'shop:clothes' => 'shopping_clothes',
207 'shop:hairdresser' => 'shopping_hairdresser',
208 'shop:doityourself' => 'shopping_diy',
209 'shop:estate_agent' => 'shopping_estateagent2',
210 'shop:car' => 'shopping_car',
211 'shop:garden_centre' => 'shopping_garden_centre',
212 'shop:car_repair' => 'shopping_car_repair',
213 'shop:bakery' => 'shopping_bakery',
214 'shop:butcher' => 'shopping_butcher',
215 'shop:apparel' => 'shopping_clothes',
216 'shop:laundry' => 'shopping_laundrette',
217 'shop:beverages' => 'shopping_alcohol',
218 'shop:alcohol' => 'shopping_alcohol',
219 'shop:optician' => 'health_opticians',
220 'shop:chemist' => 'health_pharmacy',
221 'shop:gallery' => 'tourist_art_gallery2',
222 'shop:jewelry' => 'shopping_jewelry',
223 'tourism:information' => 'amenity_information',
224 'historic:ruins' => 'tourist_ruin',
225 'amenity:college' => 'education_school',
226 'historic:monument' => 'tourist_monument',
227 'historic:memorial' => 'tourist_monument',
228 'historic:mine' => 'poi_mine',
229 'tourism:caravan_site' => 'accommodation_caravan_park',
230 'amenity:bus_station' => 'transport_bus_station',
231 'amenity:atm' => 'money_atm2',
232 'tourism:viewpoint' => 'tourist_view_point',
233 'tourism:guesthouse' => 'accommodation_bed_and_breakfast',
234 'railway:tram' => 'transport_tram_stop',
235 'amenity:courthouse' => 'amenity_court',
236 'amenity:recycling' => 'amenity_recycling',
237 'amenity:dentist' => 'health_dentist',
238 'natural:beach' => 'tourist_beach',
239 'railway:tram_stop' => 'transport_tram_stop',
240 'amenity:prison' => 'amenity_prison',
241 'highway:bus_stop' => 'transport_bus_stop2'
244 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
246 return $aIcons[$sClassPlace] ?? null;
250 * Get an icon for the given object with its full URL.
252 function getIconFile($aPlace)
254 $sIcon = getIcon($aPlace);
256 if (!isset($sIcon)) {
260 return CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.p.20.png';
264 * Return a class importance value for the given place.
266 * @param array[] $aPlace Information about the place.
268 * @return int An importance value. The lower the value, the more
269 * important the class.
271 function getImportance($aPlace)
273 static $aWithImportance = null;
275 if ($aWithImportance === null) {
276 $aWithImportance = array_flip(array(
291 'highway:motorway_junction',
297 'highway:residential',
298 'highway:unclassified',
299 'highway:living_street',
306 'highway:pedestrian',
309 'highway:motorway_link',
310 'highway:trunk_link',
311 'highway:primary_link',
312 'landuse:industrial',
313 'landuse:residential',
315 'landuse:commercial',
319 'amenity:place_of_worship',
322 'amenity:university',
324 'amenity:arts_centre',
326 'tourism:theme_park',
327 'tourism:attraction',
328 'leisure:golf_course',
333 'amenity:public_building',
336 'amenity:community_centre',
337 'amenity:fire_station',
340 'amenity:post_office',
344 'landuse:recreation_ground',
349 'historic:archaeological_site',
351 'leisure:sports_centre',
352 'leisure:swimming_pool',
355 'amenity:restaurant',
358 'tourism:guest_house',
362 'waterway:waterfall',
367 'landuse:allotments',
379 'shop:garden_centre',
387 'shop:department_store',
411 'shop:shopping_centre',
418 'shop:travel_agency',
421 'tourism:information',
424 'place:house_number',
425 'place:country_code',
427 'highway:unsurfaced',
433 'leisure:nature_reserve',
435 'waterway:lock_gate',
441 'leisure:playground',
445 'tourism:caravan_site',
446 'amenity:bus_station',
447 'amenity:kindergarten',
448 'highway:construction',
450 'amenity:emergency_phone',
452 'waterway:riverbank',
456 'tourism:bed_and_breakfast',
460 'amenity:courthouse',
465 'amenity:grave_yard',
468 'landuse:village_green',
474 'railway:light_rail',
475 'railway:narrow_gauge',
477 'amenity:village_hall',
479 'amenity:veterinary',
480 'landuse:brownfield',
482 'railway:historic_station',
483 'landuse:construction',
487 'highway:traffic_signals',
490 'amenity:social_club',
492 'amenity:health_centre',
496 'amenity:ferry_terminal',
502 'amenity:car_rental',
505 'amenity:nursing_home',
509 'highway:mini_roundabout',
512 'amenity:bicycle_parking',
516 'natural:cave_entrance',
517 'amenity:crematorium',
518 'tourism:picnic_site',
527 'amenity:medical_centre',
528 'historic:roman_road',
530 'railway:subway_entrance',
536 'railway:level_crossing',
539 'tourism:apartments',
551 'waterway:derelict_canal',
553 'railway:disused_station',
559 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
561 return $aWithImportance[$sClassPlace] ?? null;