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 ($iRank < 26) {
22 $sLabel = $aPlace['type'];
23 } elseif ($iRank < 28) {
25 } elseif ($aPlace['class'] == 'place'
26 && ($aPlace['type'] == 'house_number' ||
27 $aPlace['type'] == 'house_name' ||
28 $aPlace['type'] == 'country_code')
30 $sLabel = $aPlace['type'];
32 $sLabel = $aPlace['class'];
35 return strtolower(str_replace(' ', '_', $sLabel));
39 * Create a label for the given place.
41 * @param array[] $aPlace Information about the place to label.
43 function getLabel($aPlace, $sCountry = null)
45 if (isset($aPlace['place_type'])) {
46 return ucwords(str_replace('_', ' ', $aPlace['place_type']));
49 if ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
50 return getBoundaryLabel(($aPlace['rank_address'] ?? 30)/2, $sCountry ?? null);
53 // Return a label only for 'important' class/type combinations
54 if (getImportance($aPlace) !== null) {
55 return ucwords(str_replace('_', ' ', $aPlace['type']));
63 * Return a simple label for an administrative boundary for the given country.
65 * @param int $iAdminLevel Content of admin_level tag.
66 * @param string $sCountry Country code of the country where the object is
67 * in. May be null, in which case a world-wide
69 * @param string $sFallback String to return if no explicit string is listed.
73 function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative')
75 static $aBoundaryList = array (
81 5 => 'State District',
91 if (isset($aBoundaryList[$sCountry])
92 && isset($aBoundaryList[$sCountry][$iAdminLevel])
94 return $aBoundaryList[$sCountry][$iAdminLevel];
97 return $aBoundaryList['default'][$iAdminLevel] ?? $sFallback;
101 * Return an estimated radius of how far the object node extends.
103 * @param array[] $aPlace Information about the place. This must be a node
106 * @return float The radius around the feature in degrees.
108 function getDefRadius($aPlace)
110 $aSpecialRadius = array(
111 'place:continent' => 25,
112 'place:country' => 7,
113 'place:state' => 2.6,
114 'place:province' => 2.6,
115 'place:region' => 1.0,
116 'place:county' => 0.7,
117 'place:city' => 0.16,
118 'place:municipality' => 0.16,
119 'place:island' => 0.32,
120 'place:postcode' => 0.16,
121 'place:town' => 0.04,
122 'place:village' => 0.02,
123 'place:hamlet' => 0.02,
124 'place:district' => 0.02,
125 'place:borough' => 0.02,
126 'place:suburb' => 0.02,
127 'place:locality' => 0.01,
128 'place:neighbourhood'=> 0.01,
129 'place:quarter' => 0.01,
130 'place:city_block' => 0.01,
131 'landuse:farm' => 0.01,
132 'place:farm' => 0.01,
133 'place:airport' => 0.015,
134 'aeroway:aerodrome' => 0.015,
135 'railway:station' => 0.005
138 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
140 return $aSpecialRadius[$sClassPlace] ?? 0.00005;
144 * Get the icon to use with the given object.
146 function getIcon($aPlace)
149 'boundary:administrative' => 'poi_boundary_administrative',
150 'place:city' => 'poi_place_city',
151 'place:town' => 'poi_place_town',
152 'place:village' => 'poi_place_village',
153 'place:hamlet' => 'poi_place_village',
154 'place:suburb' => 'poi_place_village',
155 'place:locality' => 'poi_place_village',
156 'place:airport' => 'transport_airport2',
157 'aeroway:aerodrome' => 'transport_airport2',
158 'railway:station' => 'transport_train_station2',
159 'amenity:place_of_worship' => 'place_of_worship_unknown3',
160 'amenity:pub' => 'food_pub',
161 'amenity:bar' => 'food_bar',
162 'amenity:university' => 'education_university',
163 'tourism:museum' => 'tourist_museum',
164 'amenity:arts_centre' => 'tourist_art_gallery2',
165 'tourism:zoo' => 'tourist_zoo',
166 'tourism:theme_park' => 'poi_point_of_interest',
167 'tourism:attraction' => 'poi_point_of_interest',
168 'leisure:golf_course' => 'sport_golf',
169 'historic:castle' => 'tourist_castle',
170 'amenity:hospital' => 'health_hospital',
171 'amenity:school' => 'education_school',
172 'amenity:theatre' => 'tourist_theatre',
173 'amenity:library' => 'amenity_library',
174 'amenity:fire_station' => 'amenity_firestation3',
175 'amenity:police' => 'amenity_police2',
176 'amenity:bank' => 'money_bank2',
177 'amenity:post_office' => 'amenity_post_office',
178 'tourism:hotel' => 'accommodation_hotel2',
179 'amenity:cinema' => 'tourist_cinema',
180 'tourism:artwork' => 'tourist_art_gallery2',
181 'historic:archaeological_site' => 'tourist_archaeological2',
182 'amenity:doctors' => 'health_doctors',
183 'leisure:sports_centre' => 'sport_leisure_centre',
184 'leisure:swimming_pool' => 'sport_swimming_outdoor',
185 'shop:supermarket' => 'shopping_supermarket',
186 'shop:convenience' => 'shopping_convenience',
187 'amenity:restaurant' => 'food_restaurant',
188 'amenity:fast_food' => 'food_fastfood',
189 'amenity:cafe' => 'food_cafe',
190 'tourism:guest_house' => 'accommodation_bed_and_breakfast',
191 'amenity:pharmacy' => 'health_pharmacy_dispensing',
192 'amenity:fuel' => 'transport_fuel',
193 'natural:peak' => 'poi_peak',
194 'natural:wood' => 'landuse_coniferous_and_deciduous',
195 'shop:bicycle' => 'shopping_bicycle',
196 'shop:clothes' => 'shopping_clothes',
197 'shop:hairdresser' => 'shopping_hairdresser',
198 'shop:doityourself' => 'shopping_diy',
199 'shop:estate_agent' => 'shopping_estateagent2',
200 'shop:car' => 'shopping_car',
201 'shop:garden_centre' => 'shopping_garden_centre',
202 'shop:car_repair' => 'shopping_car_repair',
203 'shop:bakery' => 'shopping_bakery',
204 'shop:butcher' => 'shopping_butcher',
205 'shop:apparel' => 'shopping_clothes',
206 'shop:laundry' => 'shopping_laundrette',
207 'shop:beverages' => 'shopping_alcohol',
208 'shop:alcohol' => 'shopping_alcohol',
209 'shop:optician' => 'health_opticians',
210 'shop:chemist' => 'health_pharmacy',
211 'shop:gallery' => 'tourist_art_gallery2',
212 'shop:jewelry' => 'shopping_jewelry',
213 'tourism:information' => 'amenity_information',
214 'historic:ruins' => 'tourist_ruin',
215 'amenity:college' => 'education_school',
216 'historic:monument' => 'tourist_monument',
217 'historic:memorial' => 'tourist_monument',
218 'historic:mine' => 'poi_mine',
219 'tourism:caravan_site' => 'accommodation_caravan_park',
220 'amenity:bus_station' => 'transport_bus_station',
221 'amenity:atm' => 'money_atm2',
222 'tourism:viewpoint' => 'tourist_view_point',
223 'tourism:guesthouse' => 'accommodation_bed_and_breakfast',
224 'railway:tram' => 'transport_tram_stop',
225 'amenity:courthouse' => 'amenity_court',
226 'amenity:recycling' => 'amenity_recycling',
227 'amenity:dentist' => 'health_dentist',
228 'natural:beach' => 'tourist_beach',
229 'railway:tram_stop' => 'transport_tram_stop',
230 'amenity:prison' => 'amenity_prison',
231 'highway:bus_stop' => 'transport_bus_stop2'
234 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
236 return $aIcons[$sClassPlace] ?? null;
240 * Get an icon for the given object with its full URL.
242 function getIconFile($aPlace)
244 $sIcon = getIcon($aPlace);
246 if (!isset($sIcon)) {
250 return CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.p.20.png';
254 * Return a class importance value for the given place.
256 * @param array[] $aPlace Information about the place.
258 * @return int An importance value. The lower the value, the more
259 * important the class.
261 function getImportance($aPlace)
263 static $aWithImportance = null;
265 if ($aWithImportance === null) {
266 $aWithImportance = array_flip(array(
281 'highway:motorway_junction',
287 'highway:residential',
288 'highway:unclassified',
289 'highway:living_street',
296 'highway:pedestrian',
299 'highway:motorway_link',
300 'highway:trunk_link',
301 'highway:primary_link',
302 'landuse:industrial',
303 'landuse:residential',
305 'landuse:commercial',
309 'amenity:place_of_worship',
312 'amenity:university',
314 'amenity:arts_centre',
316 'tourism:theme_park',
317 'tourism:attraction',
318 'leisure:golf_course',
323 'amenity:public_building',
326 'amenity:community_centre',
327 'amenity:fire_station',
330 'amenity:post_office',
334 'landuse:recreation_ground',
339 'historic:archaeological_site',
341 'leisure:sports_centre',
342 'leisure:swimming_pool',
345 'amenity:restaurant',
348 'tourism:guest_house',
352 'waterway:waterfall',
357 'landuse:allotments',
369 'shop:garden_centre',
377 'shop:department_store',
401 'shop:shopping_centre',
408 'shop:travel_agency',
411 'tourism:information',
414 'place:house_number',
415 'place:country_code',
417 'highway:unsurfaced',
423 'leisure:nature_reserve',
425 'waterway:lock_gate',
431 'leisure:playground',
435 'tourism:caravan_site',
436 'amenity:bus_station',
437 'amenity:kindergarten',
438 'highway:construction',
440 'amenity:emergency_phone',
442 'waterway:riverbank',
446 'tourism:bed_and_breakfast',
450 'amenity:courthouse',
455 'amenity:grave_yard',
458 'landuse:village_green',
464 'railway:light_rail',
465 'railway:narrow_gauge',
467 'amenity:village_hall',
469 'amenity:veterinary',
470 'landuse:brownfield',
472 'railway:historic_station',
473 'landuse:construction',
477 'highway:traffic_signals',
480 'amenity:social_club',
482 'amenity:health_centre',
486 'amenity:ferry_terminal',
492 'amenity:car_rental',
495 'amenity:nursing_home',
499 'highway:mini_roundabout',
502 'amenity:bicycle_parking',
506 'natural:cave_entrance',
507 'amenity:crematorium',
508 'tourism:picnic_site',
517 'amenity:medical_centre',
518 'historic:roman_road',
520 'railway:subway_entrance',
526 'railway:level_crossing',
529 'tourism:apartments',
541 'waterway:derelict_canal',
543 'railway:disused_station',
549 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
551 return $aWithImportance[$sClassPlace] ?? null;