]> git.openstreetmap.org Git - nominatim.git/blob - lib-lua/themes/nominatim/presets.lua
reintroduce brand and remove etymology
[nominatim.git] / lib-lua / themes / nominatim / presets.lua
1 -- Defines defaults used in the topic definitions.
2
3 local module = {}
4
5 -- Helper functions
6
7 local function group_merge(group1, group2)
8     for name, values in pairs(group2) do
9         if group1[name] == nil then
10             group1[name] = values
11         else
12             for _, v in pairs(values) do
13                 table.insert(group1[name], v)
14             end
15         end
16     end
17
18     return group1
19 end
20
21 -- Customized main tag filter functions
22
23 local EXCLUDED_FOOTWAYS = { sidewalk = 1, crossing = 1, link = 1, traffic_aisle }
24
25 local function filter_footways(place)
26     if place.has_name then
27         local footway = place.object.tags.footway
28         if footway == nil or EXCLUDED_FOOTWAYS[footway] ~= 1 then
29             return place
30         end
31     end
32     return false
33 end
34
35 local function include_when_tag_present(key, value, named)
36     if named then
37         return function(place)
38                    if place.has_name and place.intags[key] == value then
39                        return place
40                    end
41                    return false
42                end
43     else
44         return function(place)
45                    if place.intags[key] == value then
46                        return place
47                    end
48                    return false
49                end
50     end
51 end
52
53 local function exclude_when_key_present(key, named)
54     if named then
55         return function(place)
56                    if place.has_name and place.intags[key] == nil then
57                        return place
58                    end
59                    return false
60                end
61     else
62         return function(place)
63                    if place.intags[key] == nil then
64                        return place
65                    end
66                    return false
67                end
68
69     end
70 end
71
72 local function lock_transform(place)
73     if place.object.tags.waterway ~= nil then
74         local name = place.object.tags.lock_name
75         if name ~= nil then
76             return place:clone{names={name=name, ref=place.object.tags.lock_ref}}
77         end
78     end
79
80     return false
81 end
82
83 -- Main tag definition
84
85 module.MAIN_TAGS = {}
86
87 module.MAIN_TAGS.admin = {
88     boundary = {administrative = 'named'},
89     landuse = {residential = 'fallback',
90                farm = 'fallback',
91                farmyard = 'fallback',
92                industrial = 'fallback',
93                commercial = 'fallback',
94                allotments = 'fallback',
95                retail = 'fallback'},
96     place = {county = 'always',
97              district = 'always',
98              municipality = 'always',
99              city = 'always',
100              town = 'always',
101              borough = 'always',
102              village = 'always',
103              suburb = 'always',
104              hamlet = 'always',
105              croft = 'always',
106              subdivision = 'always',
107              allotments = 'always',
108              neighbourhood = 'always',
109              quarter = 'always',
110              isolated_dwelling = 'always',
111              farm = 'always',
112              city_block = 'always',
113              locality = 'always'}
114 }
115
116 module.MAIN_TAGS.all_boundaries = {
117     boundary = {'named',
118                 place = 'delete',
119                 land_area = 'delete',
120                 postal_code = 'always'},
121     landuse = 'fallback',
122     place = 'always'
123 }
124
125 module.MAIN_TAGS.natural = {
126     waterway = {'named',
127                 riverbank = 'delete'},
128     natural = {'named',
129                yes = 'delete',
130                no = 'delete',
131                coastline = 'delete',
132                saddle = 'fallback',
133                water = exclude_when_key_present('water', true)},
134     mountain_pass = {'always',
135                      no = 'delete'},
136     water = {include_when_tag_present('natural', 'water', true),
137              river = 'never',
138              stream = 'never',
139              canal = 'never',
140              ditch = 'never',
141              drain = 'never',
142              fish_pass = 'never',
143              yes = 'delete',
144              intermittent = 'delete',
145              tidal = 'delete'
146              }
147 }
148
149 module.MAIN_TAGS_POIS = function (group)
150     group = group or 'delete'
151     return {
152     aerialway = {'always',
153                  no = group,
154                  pylon = group},
155     aeroway = {'always',
156                no = group},
157     amenity = {'always',
158                no = group,
159                parking_space = group,
160                parking_entrance = group,
161                waste_disposal = group,
162                hunting_stand = group},
163     building = {'fallback',
164                 no = group},
165     bridge = {'named_with_key',
166               no = group},
167     club = {'always',
168             no = group},
169     craft = {'always',
170              no = group},
171     emergency = {'always',
172                  no = group,
173                  yes = group,
174                  fire_hydrant = group},
175     healthcare = {'fallback',
176                   yes = group,
177                   no = group},
178     highway = {'always',
179                no = group,
180                turning_circle = group,
181                mini_roundabout = group,
182                noexit = group,
183                crossing = group,
184                give_way = group,
185                stop = group,
186                turning_loop = group,
187                passing_place = group,
188                street_lamp = 'named',
189                traffic_signals = 'named'},
190     historic = {'always',
191                 yes = group,
192                 no = group},
193     information = {include_when_tag_present('tourism', 'information')},
194     junction = {'fallback',
195                 no = group},
196     leisure = {'always',
197                nature_reserve = 'fallback',
198                swimming_pool = 'named',
199                no = group},
200     lock = {yes = lock_transform},
201     man_made = {pier = 'always',
202                 tower = 'always',
203                 bridge = 'always',
204                 works = 'named',
205                 water_tower = 'always',
206                 dyke = 'named',
207                 adit = 'named',
208                 lighthouse = 'always',
209                 watermill = 'always',
210                 tunnel = 'always'},
211     military = {'always',
212                 yes = group,
213                 no = group},
214     office = {'always',
215               no = group},
216     railway = {'named',
217                rail = group,
218                no = group,
219                abandoned = group,
220                disused = group,
221                razed = group,
222                level_crossing = group,
223                switch = group,
224                signal = group,
225                buffer_stop = group},
226     shop = {'always',
227             no = group},
228     tourism = {'always',
229                no = group,
230                yes = group,
231                information = 'fallback'},
232     tunnel = {'named_with_key',
233               no = group}
234 } end
235
236 module.MAIN_TAGS_STREETS = {}
237
238 module.MAIN_TAGS_STREETS.default = {
239     place = {square = 'always'},
240     highway = {motorway = 'always',
241                trunk = 'always',
242                primary = 'always',
243                secondary = 'always',
244                tertiary = 'always',
245                unclassified = 'always',
246                residential = 'always',
247                road = 'always',
248                living_street = 'always',
249                pedestrian = 'always',
250                service = 'named',
251                cycleway = 'named',
252                path = 'named',
253                footway = filter_footways,
254                steps = 'named',
255                bridleway = 'named',
256                track = 'named',
257                motorway_link = 'named',
258                trunk_link = 'named',
259                primary_link = 'named',
260                secondary_link = 'named',
261                tertiary_link = 'named'}
262 }
263
264 module.MAIN_TAGS_STREETS.car = {
265     place = {square = 'always'},
266     highway = {motorway = 'always',
267                trunk = 'always',
268                primary = 'always',
269                secondary = 'always',
270                tertiary = 'always',
271                unclassified = 'always',
272                residential = 'always',
273                road = 'always',
274                living_street = 'always',
275                service = 'always',
276                track = 'always',
277                motorway_link = 'always',
278                trunk_link = 'always',
279                primary_link = 'always',
280                secondary_link = 'always',
281                tertiary_link = 'always'}
282 }
283
284 module.MAIN_TAGS_STREETS.all = {
285     place = {square = 'always'},
286     highway = {motorway = 'always',
287                trunk = 'always',
288                primary = 'always',
289                secondary = 'always',
290                tertiary = 'always',
291                unclassified = 'always',
292                residential = 'always',
293                road = 'always',
294                living_street = 'always',
295                pedestrian = 'always',
296                service = 'always',
297                cycleway = 'always',
298                path = 'always',
299                footway = 'always',
300                steps = 'always',
301                bridleway = 'always',
302                track = 'always',
303                motorway_link = 'always',
304                trunk_link = 'always',
305                primary_link = 'always',
306                secondary_link = 'always',
307                tertiary_link = 'always'}
308 }
309
310
311 -- name tags
312
313 module.NAME_TAGS = {}
314
315 module.NAME_TAGS.core = {main = {'name', 'name:*',
316                                  'int_name', 'int_name:*',
317                                  'nat_name', 'nat_name:*',
318                                  'reg_name', 'reg_name:*',
319                                  'loc_name', 'loc_name:*',
320                                  'old_name', 'old_name:*',
321                                  'alt_name', 'alt_name:*', 'alt_name_*',
322                                  'official_name', 'official_name:*',
323                                  'place_name', 'place_name:*',
324                                  'short_name', 'short_name:*'},
325                          extra = {'ref', 'int_ref', 'nat_ref', 'reg_ref',
326                                   'loc_ref', 'old_ref', 'ISO3166-2'}
327                         }
328 module.NAME_TAGS.address = {house = {'addr:housename'}}
329 module.NAME_TAGS.poi = group_merge({main = {'brand'},
330                                     extra = {'iata', 'icao'}},
331                                    module.NAME_TAGS.core)
332
333 -- Address tagging
334
335 module.ADDRESS_TAGS = {}
336
337 module.ADDRESS_TAGS.core = { extra = {'addr:*', 'is_in:*', 'tiger:county'},
338                              postcode = {'postal_code', 'postcode', 'addr:postcode',
339                                          'tiger:zip_left', 'tiger:zip_right'},
340                              country = {'country_code', 'ISO3166-1',
341                                         'addr:country_code', 'is_in:country_code',
342                                         'addr:country', 'is_in:country'}
343                            }
344
345 module.ADDRESS_TAGS.houses = { main = {'addr:housenumber',
346                                        'addr:conscriptionnumber',
347                                        'addr:streetnumber'},
348                                interpolation = {'addr:interpolation'}
349                              }
350
351 -- Ignored tags (prefiltered away)
352
353 module.IGNORE_KEYS = {}
354
355 module.IGNORE_KEYS.metatags = {'note', 'note:*', 'source', 'source:*', '*source',
356                                'attribution', 'comment', 'fixme', 'created_by',
357                                'tiger:cfcc', 'tiger:reviewed', 'nysgissam:*',
358                                'NHD:*', 'nhd:*', 'gnis:*', 'geobase:*', 'yh:*',
359                                'osak:*', 'naptan:*', 'CLC:*', 'import', 'it:fvg:*',
360                                'lacounty:*', 'ref:linz:*',
361                                'ref:bygningsnr', 'ref:ruian:*', 'building:ruian:type',
362                                'type',
363                                'is_in:postcode'}
364 module.IGNORE_KEYS.name = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*',
365                            'name:etymology', 'name:etymology:*',
366                            'name:signed', 'name:botanical'}
367 module.IGNORE_KEYS.address = {'addr:street:*', 'addr:city:*', 'addr:district:*',
368                               'addr:province:*', 'addr:subdistrict:*', 'addr:place:*',
369                               'addr:TW:dataset'}
370
371 -- Extra tags (prefiltered away)
372
373 module.EXTRATAGS = {}
374
375 module.EXTRATAGS.required = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital'}
376
377 return module