1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2023 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Hard-coded information about tag catagories.
10 These tables have been copied verbatim from the old PHP code. For future
11 version a more flexible formatting is required.
13 from typing import Tuple, Optional, Mapping
15 def get_label_tag(category: Tuple[str, str], extratags: Optional[Mapping[str, str]],
16 rank: int, country: Optional[str]) -> str:
17 """ Create a label tag for the given place that can be used as an XML name.
19 if rank < 26 and extratags and 'place'in extratags:
20 label = extratags['place']
21 elif category == ('boundary', 'administrative'):
22 label = ADMIN_LABELS.get((country or '', int(rank/2)))\
23 or ADMIN_LABELS.get(('', int(rank/2)))\
25 elif category[1] == 'postal_code':
28 label = category[1] if category[1] != 'yes' else category[0]
31 elif category[0] == 'place'\
32 and category[1] in ('house_number', 'house_name', 'country_code'):
37 return label.lower().replace(' ', '_')
45 ('', 5): 'State District',
47 ('', 7): 'Municipality',
49 ('', 9): 'City District',
51 ('', 11): 'Neighbourhood',
52 ('', 12): 'City Block',
61 ('boundary', 'administrative'): 'poi_boundary_administrative',
62 ('place', 'city'): 'poi_place_city',
63 ('place', 'town'): 'poi_place_town',
64 ('place', 'village'): 'poi_place_village',
65 ('place', 'hamlet'): 'poi_place_village',
66 ('place', 'suburb'): 'poi_place_village',
67 ('place', 'locality'): 'poi_place_village',
68 ('place', 'airport'): 'transport_airport2',
69 ('aeroway', 'aerodrome'): 'transport_airport2',
70 ('railway', 'station'): 'transport_train_station2',
71 ('amenity', 'place_of_worship'): 'place_of_worship_unknown3',
72 ('amenity', 'pub'): 'food_pub',
73 ('amenity', 'bar'): 'food_bar',
74 ('amenity', 'university'): 'education_university',
75 ('tourism', 'museum'): 'tourist_museum',
76 ('amenity', 'arts_centre'): 'tourist_art_gallery2',
77 ('tourism', 'zoo'): 'tourist_zoo',
78 ('tourism', 'theme_park'): 'poi_point_of_interest',
79 ('tourism', 'attraction'): 'poi_point_of_interest',
80 ('leisure', 'golf_course'): 'sport_golf',
81 ('historic', 'castle'): 'tourist_castle',
82 ('amenity', 'hospital'): 'health_hospital',
83 ('amenity', 'school'): 'education_school',
84 ('amenity', 'theatre'): 'tourist_theatre',
85 ('amenity', 'library'): 'amenity_library',
86 ('amenity', 'fire_station'): 'amenity_firestation3',
87 ('amenity', 'police'): 'amenity_police2',
88 ('amenity', 'bank'): 'money_bank2',
89 ('amenity', 'post_office'): 'amenity_post_office',
90 ('tourism', 'hotel'): 'accommodation_hotel2',
91 ('amenity', 'cinema'): 'tourist_cinema',
92 ('tourism', 'artwork'): 'tourist_art_gallery2',
93 ('historic', 'archaeological_site'): 'tourist_archaeological2',
94 ('amenity', 'doctors'): 'health_doctors',
95 ('leisure', 'sports_centre'): 'sport_leisure_centre',
96 ('leisure', 'swimming_pool'): 'sport_swimming_outdoor',
97 ('shop', 'supermarket'): 'shopping_supermarket',
98 ('shop', 'convenience'): 'shopping_convenience',
99 ('amenity', 'restaurant'): 'food_restaurant',
100 ('amenity', 'fast_food'): 'food_fastfood',
101 ('amenity', 'cafe'): 'food_cafe',
102 ('tourism', 'guest_house'): 'accommodation_bed_and_breakfast',
103 ('amenity', 'pharmacy'): 'health_pharmacy_dispensing',
104 ('amenity', 'fuel'): 'transport_fuel',
105 ('natural', 'peak'): 'poi_peak',
106 ('natural', 'wood'): 'landuse_coniferous_and_deciduous',
107 ('shop', 'bicycle'): 'shopping_bicycle',
108 ('shop', 'clothes'): 'shopping_clothes',
109 ('shop', 'hairdresser'): 'shopping_hairdresser',
110 ('shop', 'doityourself'): 'shopping_diy',
111 ('shop', 'estate_agent'): 'shopping_estateagent2',
112 ('shop', 'car'): 'shopping_car',
113 ('shop', 'garden_centre'): 'shopping_garden_centre',
114 ('shop', 'car_repair'): 'shopping_car_repair',
115 ('shop', 'bakery'): 'shopping_bakery',
116 ('shop', 'butcher'): 'shopping_butcher',
117 ('shop', 'apparel'): 'shopping_clothes',
118 ('shop', 'laundry'): 'shopping_laundrette',
119 ('shop', 'beverages'): 'shopping_alcohol',
120 ('shop', 'alcohol'): 'shopping_alcohol',
121 ('shop', 'optician'): 'health_opticians',
122 ('shop', 'chemist'): 'health_pharmacy',
123 ('shop', 'gallery'): 'tourist_art_gallery2',
124 ('shop', 'jewelry'): 'shopping_jewelry',
125 ('tourism', 'information'): 'amenity_information',
126 ('historic', 'ruins'): 'tourist_ruin',
127 ('amenity', 'college'): 'education_school',
128 ('historic', 'monument'): 'tourist_monument',
129 ('historic', 'memorial'): 'tourist_monument',
130 ('historic', 'mine'): 'poi_mine',
131 ('tourism', 'caravan_site'): 'accommodation_caravan_park',
132 ('amenity', 'bus_station'): 'transport_bus_station',
133 ('amenity', 'atm'): 'money_atm2',
134 ('tourism', 'viewpoint'): 'tourist_view_point',
135 ('tourism', 'guesthouse'): 'accommodation_bed_and_breakfast',
136 ('railway', 'tram'): 'transport_tram_stop',
137 ('amenity', 'courthouse'): 'amenity_court',
138 ('amenity', 'recycling'): 'amenity_recycling',
139 ('amenity', 'dentist'): 'health_dentist',
140 ('natural', 'beach'): 'tourist_beach',
141 ('railway', 'tram_stop'): 'transport_tram_stop',
142 ('amenity', 'prison'): 'amenity_prison',
143 ('highway', 'bus_stop'): 'transport_bus_stop2'