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',
99 if (isset($aBoundaryList[$sCountry])
100 && isset($aBoundaryList[$sCountry][$iAdminLevel])
102 return $aBoundaryList[$sCountry][$iAdminLevel];
105 return $aBoundaryList['default'][$iAdminLevel] ?? $sFallback;
109 * Return an estimated radius of how far the object node extends.
111 * @param array[] $aPlace Information about the place. This must be a node
114 * @return float The radius around the feature in degrees.
116 function getDefRadius($aPlace)
118 $aSpecialRadius = array(
119 'place:continent' => 25,
120 'place:country' => 7,
121 'place:state' => 2.6,
122 'place:province' => 2.6,
123 'place:region' => 1.0,
124 'place:county' => 0.7,
125 'place:city' => 0.16,
126 'place:municipality' => 0.16,
127 'place:island' => 0.32,
128 'place:postcode' => 0.16,
129 'place:town' => 0.04,
130 'place:village' => 0.02,
131 'place:hamlet' => 0.02,
132 'place:district' => 0.02,
133 'place:borough' => 0.02,
134 'place:suburb' => 0.02,
135 'place:locality' => 0.01,
136 'place:neighbourhood'=> 0.01,
137 'place:quarter' => 0.01,
138 'place:city_block' => 0.01,
139 'landuse:farm' => 0.01,
140 'place:farm' => 0.01,
141 'place:airport' => 0.015,
142 'aeroway:aerodrome' => 0.015,
143 'railway:station' => 0.005
146 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
148 return $aSpecialRadius[$sClassPlace] ?? 0.00005;
152 * Get the icon to use with the given object.
154 function getIcon($aPlace)
157 'boundary:administrative' => 'poi_boundary_administrative',
158 'place:city' => 'poi_place_city',
159 'place:town' => 'poi_place_town',
160 'place:village' => 'poi_place_village',
161 'place:hamlet' => 'poi_place_village',
162 'place:suburb' => 'poi_place_village',
163 'place:locality' => 'poi_place_village',
164 'place:airport' => 'transport_airport2',
165 'aeroway:aerodrome' => 'transport_airport2',
166 'railway:station' => 'transport_train_station2',
167 'amenity:place_of_worship' => 'place_of_worship_unknown3',
168 'amenity:pub' => 'food_pub',
169 'amenity:bar' => 'food_bar',
170 'amenity:university' => 'education_university',
171 'tourism:museum' => 'tourist_museum',
172 'amenity:arts_centre' => 'tourist_art_gallery2',
173 'tourism:zoo' => 'tourist_zoo',
174 'tourism:theme_park' => 'poi_point_of_interest',
175 'tourism:attraction' => 'poi_point_of_interest',
176 'leisure:golf_course' => 'sport_golf',
177 'historic:castle' => 'tourist_castle',
178 'amenity:hospital' => 'health_hospital',
179 'amenity:school' => 'education_school',
180 'amenity:theatre' => 'tourist_theatre',
181 'amenity:library' => 'amenity_library',
182 'amenity:fire_station' => 'amenity_firestation3',
183 'amenity:police' => 'amenity_police2',
184 'amenity:bank' => 'money_bank2',
185 'amenity:post_office' => 'amenity_post_office',
186 'tourism:hotel' => 'accommodation_hotel2',
187 'amenity:cinema' => 'tourist_cinema',
188 'tourism:artwork' => 'tourist_art_gallery2',
189 'historic:archaeological_site' => 'tourist_archaeological2',
190 'amenity:doctors' => 'health_doctors',
191 'leisure:sports_centre' => 'sport_leisure_centre',
192 'leisure:swimming_pool' => 'sport_swimming_outdoor',
193 'shop:supermarket' => 'shopping_supermarket',
194 'shop:convenience' => 'shopping_convenience',
195 'amenity:restaurant' => 'food_restaurant',
196 'amenity:fast_food' => 'food_fastfood',
197 'amenity:cafe' => 'food_cafe',
198 'tourism:guest_house' => 'accommodation_bed_and_breakfast',
199 'amenity:pharmacy' => 'health_pharmacy_dispensing',
200 'amenity:fuel' => 'transport_fuel',
201 'natural:peak' => 'poi_peak',
202 'natural:wood' => 'landuse_coniferous_and_deciduous',
203 'shop:bicycle' => 'shopping_bicycle',
204 'shop:clothes' => 'shopping_clothes',
205 'shop:hairdresser' => 'shopping_hairdresser',
206 'shop:doityourself' => 'shopping_diy',
207 'shop:estate_agent' => 'shopping_estateagent2',
208 'shop:car' => 'shopping_car',
209 'shop:garden_centre' => 'shopping_garden_centre',
210 'shop:car_repair' => 'shopping_car_repair',
211 'shop:bakery' => 'shopping_bakery',
212 'shop:butcher' => 'shopping_butcher',
213 'shop:apparel' => 'shopping_clothes',
214 'shop:laundry' => 'shopping_laundrette',
215 'shop:beverages' => 'shopping_alcohol',
216 'shop:alcohol' => 'shopping_alcohol',
217 'shop:optician' => 'health_opticians',
218 'shop:chemist' => 'health_pharmacy',
219 'shop:gallery' => 'tourist_art_gallery2',
220 'shop:jewelry' => 'shopping_jewelry',
221 'tourism:information' => 'amenity_information',
222 'historic:ruins' => 'tourist_ruin',
223 'amenity:college' => 'education_school',
224 'historic:monument' => 'tourist_monument',
225 'historic:memorial' => 'tourist_monument',
226 'historic:mine' => 'poi_mine',
227 'tourism:caravan_site' => 'accommodation_caravan_park',
228 'amenity:bus_station' => 'transport_bus_station',
229 'amenity:atm' => 'money_atm2',
230 'tourism:viewpoint' => 'tourist_view_point',
231 'tourism:guesthouse' => 'accommodation_bed_and_breakfast',
232 'railway:tram' => 'transport_tram_stop',
233 'amenity:courthouse' => 'amenity_court',
234 'amenity:recycling' => 'amenity_recycling',
235 'amenity:dentist' => 'health_dentist',
236 'natural:beach' => 'tourist_beach',
237 'railway:tram_stop' => 'transport_tram_stop',
238 'amenity:prison' => 'amenity_prison',
239 'highway:bus_stop' => 'transport_bus_stop2'
242 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
244 return $aIcons[$sClassPlace] ?? null;
248 * Get an icon for the given object with its full URL.
250 function getIconFile($aPlace)
252 $sIcon = getIcon($aPlace);
254 if (!isset($sIcon)) {
258 return CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.p.20.png';
262 * Return a class importance value for the given place.
264 * @param array[] $aPlace Information about the place.
266 * @return int An importance value. The lower the value, the more
267 * important the class.
269 function getImportance($aPlace)
271 static $aWithImportance = null;
273 if ($aWithImportance === null) {
274 $aWithImportance = array_flip(array(
289 'highway:motorway_junction',
295 'highway:residential',
296 'highway:unclassified',
297 'highway:living_street',
304 'highway:pedestrian',
307 'highway:motorway_link',
308 'highway:trunk_link',
309 'highway:primary_link',
310 'landuse:industrial',
311 'landuse:residential',
313 'landuse:commercial',
317 'amenity:place_of_worship',
320 'amenity:university',
322 'amenity:arts_centre',
324 'tourism:theme_park',
325 'tourism:attraction',
326 'leisure:golf_course',
331 'amenity:public_building',
334 'amenity:community_centre',
335 'amenity:fire_station',
338 'amenity:post_office',
342 'landuse:recreation_ground',
347 'historic:archaeological_site',
349 'leisure:sports_centre',
350 'leisure:swimming_pool',
353 'amenity:restaurant',
356 'tourism:guest_house',
360 'waterway:waterfall',
365 'landuse:allotments',
377 'shop:garden_centre',
385 'shop:department_store',
409 'shop:shopping_centre',
416 'shop:travel_agency',
419 'tourism:information',
422 'place:house_number',
423 'place:country_code',
425 'highway:unsurfaced',
431 'leisure:nature_reserve',
433 'waterway:lock_gate',
439 'leisure:playground',
443 'tourism:caravan_site',
444 'amenity:bus_station',
445 'amenity:kindergarten',
446 'highway:construction',
448 'amenity:emergency_phone',
450 'waterway:riverbank',
454 'tourism:bed_and_breakfast',
458 'amenity:courthouse',
463 'amenity:grave_yard',
466 'landuse:village_green',
472 'railway:light_rail',
473 'railway:narrow_gauge',
475 'amenity:village_hall',
477 'amenity:veterinary',
478 'landuse:brownfield',
480 'railway:historic_station',
481 'landuse:construction',
485 'highway:traffic_signals',
488 'amenity:social_club',
490 'amenity:health_centre',
494 'amenity:ferry_terminal',
500 'amenity:car_rental',
503 'amenity:nursing_home',
507 'highway:mini_roundabout',
510 'amenity:bicycle_parking',
514 'natural:cave_entrance',
515 'amenity:crematorium',
516 'tourism:picnic_site',
525 'amenity:medical_centre',
526 'historic:roman_road',
528 'railway:subway_entrance',
534 'railway:level_crossing',
537 'tourism:apartments',
549 'waterway:derelict_canal',
551 'railway:disused_station',
557 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
559 return $aWithImportance[$sClassPlace] ?? null;