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 if (CONST_MapIcon_URL === false) {
259 $sIcon = getIcon($aPlace);
261 if (!isset($sIcon)) {
265 return CONST_MapIcon_URL.'/'.$sIcon.'.p.20.png';
269 * Return a class importance value for the given place.
271 * @param array[] $aPlace Information about the place.
273 * @return int An importance value. The lower the value, the more
274 * important the class.
276 function getImportance($aPlace)
278 static $aWithImportance = null;
280 if ($aWithImportance === null) {
281 $aWithImportance = array_flip(array(
282 'boundary:administrative',
297 'highway:motorway_junction',
303 'highway:residential',
304 'highway:unclassified',
305 'highway:living_street',
312 'highway:pedestrian',
315 'highway:motorway_link',
316 'highway:trunk_link',
317 'highway:primary_link',
318 'landuse:industrial',
319 'landuse:residential',
321 'landuse:commercial',
325 'amenity:place_of_worship',
328 'amenity:university',
330 'amenity:arts_centre',
332 'tourism:theme_park',
333 'tourism:attraction',
334 'leisure:golf_course',
339 'amenity:public_building',
342 'amenity:community_centre',
343 'amenity:fire_station',
346 'amenity:post_office',
350 'landuse:recreation_ground',
355 'historic:archaeological_site',
357 'leisure:sports_centre',
358 'leisure:swimming_pool',
361 'amenity:restaurant',
364 'tourism:guest_house',
368 'waterway:waterfall',
373 'landuse:allotments',
385 'shop:garden_centre',
393 'shop:department_store',
417 'shop:shopping_centre',
424 'shop:travel_agency',
427 'tourism:information',
430 'place:house_number',
431 'place:country_code',
433 'highway:unsurfaced',
439 'leisure:nature_reserve',
441 'waterway:lock_gate',
447 'leisure:playground',
451 'tourism:caravan_site',
452 'amenity:bus_station',
453 'amenity:kindergarten',
454 'highway:construction',
456 'amenity:emergency_phone',
458 'waterway:riverbank',
462 'tourism:bed_and_breakfast',
466 'amenity:courthouse',
471 'amenity:grave_yard',
474 'landuse:village_green',
480 'railway:light_rail',
481 'railway:narrow_gauge',
483 'amenity:village_hall',
485 'amenity:veterinary',
486 'landuse:brownfield',
488 'railway:historic_station',
489 'landuse:construction',
493 'highway:traffic_signals',
496 'amenity:social_club',
498 'amenity:health_centre',
502 'amenity:ferry_terminal',
508 'amenity:car_rental',
511 'amenity:nursing_home',
515 'highway:mini_roundabout',
518 'amenity:bicycle_parking',
522 'natural:cave_entrance',
523 'amenity:crematorium',
524 'tourism:picnic_site',
533 'amenity:medical_centre',
534 'historic:roman_road',
536 'railway:subway_entrance',
542 'railway:level_crossing',
545 'tourism:apartments',
557 'waterway:derelict_canal',
559 'railway:disused_station',
565 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
567 return $aWithImportance[$sClassPlace] ?? null;