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 * Return a class importance value for the given place.
242 * @param array[] $aPlace Information about the place.
244 * @return int An importance value. The lower the value, the more
245 * important the class.
247 function getImportance($aPlace)
249 static $aWithImportance = null;
251 if ($aWithImportance === null) {
252 $aWithImportance = array_flip(array(
267 'highway:motorway_junction',
273 'highway:residential',
274 'highway:unclassified',
275 'highway:living_street',
282 'highway:pedestrian',
285 'highway:motorway_link',
286 'highway:trunk_link',
287 'highway:primary_link',
288 'landuse:industrial',
289 'landuse:residential',
291 'landuse:commercial',
295 'amenity:place_of_worship',
298 'amenity:university',
300 'amenity:arts_centre',
302 'tourism:theme_park',
303 'tourism:attraction',
304 'leisure:golf_course',
309 'amenity:public_building',
312 'amenity:community_centre',
313 'amenity:fire_station',
316 'amenity:post_office',
320 'landuse:recreation_ground',
325 'historic:archaeological_site',
327 'leisure:sports_centre',
328 'leisure:swimming_pool',
331 'amenity:restaurant',
334 'tourism:guest_house',
338 'waterway:waterfall',
343 'landuse:allotments',
355 'shop:garden_centre',
363 'shop:department_store',
387 'shop:shopping_centre',
394 'shop:travel_agency',
397 'tourism:information',
400 'place:house_number',
401 'place:country_code',
403 'highway:unsurfaced',
409 'leisure:nature_reserve',
411 'waterway:lock_gate',
417 'leisure:playground',
421 'tourism:caravan_site',
422 'amenity:bus_station',
423 'amenity:kindergarten',
424 'highway:construction',
426 'amenity:emergency_phone',
428 'waterway:riverbank',
432 'tourism:bed_and_breakfast',
436 'amenity:courthouse',
441 'amenity:grave_yard',
444 'landuse:village_green',
450 'railway:light_rail',
451 'railway:narrow_gauge',
453 'amenity:village_hall',
455 'amenity:veterinary',
456 'landuse:brownfield',
458 'railway:historic_station',
459 'landuse:construction',
463 'highway:traffic_signals',
466 'amenity:social_club',
468 'amenity:health_centre',
472 'amenity:ferry_terminal',
478 'amenity:car_rental',
481 'amenity:nursing_home',
485 'highway:mini_roundabout',
488 'amenity:bicycle_parking',
492 'natural:cave_entrance',
493 'amenity:crematorium',
494 'tourism:picnic_site',
503 'amenity:medical_centre',
504 'historic:roman_road',
506 'railway:subway_entrance',
512 'railway:level_crossing',
515 'tourism:apartments',
527 'waterway:derelict_canal',
529 'railway:disused_station',
535 $sClassPlace = $aPlace['class'].':'.$aPlace['type'];
537 return $aWithImportance[$sClassPlace] ?? null;