]> git.openstreetmap.org Git - nominatim.git/blob - lib-lua/themes/nominatim/presets.lua
exclude more tourism=information types
[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                    yes = 'delete',
195                    route_marker = 'never',
196                    trail_blaze = 'never'},
197     junction = {'fallback',
198                 no = group},
199     leisure = {'always',
200                nature_reserve = 'fallback',
201                swimming_pool = 'named',
202                no = group},
203     lock = {yes = lock_transform},
204     man_made = {pier = 'always',
205                 tower = 'always',
206                 bridge = 'always',
207                 works = 'named',
208                 water_tower = 'always',
209                 dyke = 'named',
210                 adit = 'named',
211                 lighthouse = 'always',
212                 watermill = 'always',
213                 tunnel = 'always'},
214     military = {'always',
215                 yes = group,
216                 no = group},
217     office = {'always',
218               no = group},
219     railway = {'named',
220                rail = group,
221                no = group,
222                abandoned = group,
223                disused = group,
224                razed = group,
225                level_crossing = group,
226                switch = group,
227                signal = group,
228                buffer_stop = group},
229     shop = {'always',
230             no = group},
231     tourism = {'always',
232                no = group,
233                yes = group,
234                information = exclude_when_key_present('information')},
235     tunnel = {'named_with_key',
236               no = group}
237 } end
238
239 module.MAIN_TAGS_STREETS = {}
240
241 module.MAIN_TAGS_STREETS.default = {
242     place = {square = 'always'},
243     highway = {motorway = 'always',
244                trunk = 'always',
245                primary = 'always',
246                secondary = 'always',
247                tertiary = 'always',
248                unclassified = 'always',
249                residential = 'always',
250                road = 'always',
251                living_street = 'always',
252                pedestrian = 'always',
253                service = 'named',
254                cycleway = 'named',
255                path = 'named',
256                footway = filter_footways,
257                steps = 'named',
258                bridleway = 'named',
259                track = 'named',
260                motorway_link = 'named',
261                trunk_link = 'named',
262                primary_link = 'named',
263                secondary_link = 'named',
264                tertiary_link = 'named'}
265 }
266
267 module.MAIN_TAGS_STREETS.car = {
268     place = {square = 'always'},
269     highway = {motorway = 'always',
270                trunk = 'always',
271                primary = 'always',
272                secondary = 'always',
273                tertiary = 'always',
274                unclassified = 'always',
275                residential = 'always',
276                road = 'always',
277                living_street = 'always',
278                service = 'always',
279                track = 'always',
280                motorway_link = 'always',
281                trunk_link = 'always',
282                primary_link = 'always',
283                secondary_link = 'always',
284                tertiary_link = 'always'}
285 }
286
287 module.MAIN_TAGS_STREETS.all = {
288     place = {square = 'always'},
289     highway = {motorway = 'always',
290                trunk = 'always',
291                primary = 'always',
292                secondary = 'always',
293                tertiary = 'always',
294                unclassified = 'always',
295                residential = 'always',
296                road = 'always',
297                living_street = 'always',
298                pedestrian = 'always',
299                service = 'always',
300                cycleway = 'always',
301                path = 'always',
302                footway = 'always',
303                steps = 'always',
304                bridleway = 'always',
305                track = 'always',
306                motorway_link = 'always',
307                trunk_link = 'always',
308                primary_link = 'always',
309                secondary_link = 'always',
310                tertiary_link = 'always'}
311 }
312
313
314 -- name tags
315
316 module.NAME_TAGS = {}
317
318 module.NAME_TAGS.core = {main = {'name', 'name:*',
319                                  'int_name', 'int_name:*',
320                                  'nat_name', 'nat_name:*',
321                                  'reg_name', 'reg_name:*',
322                                  'loc_name', 'loc_name:*',
323                                  'old_name', 'old_name:*',
324                                  'alt_name', 'alt_name:*', 'alt_name_*',
325                                  'official_name', 'official_name:*',
326                                  'place_name', 'place_name:*',
327                                  'short_name', 'short_name:*'},
328                          extra = {'ref', 'int_ref', 'nat_ref', 'reg_ref',
329                                   'loc_ref', 'old_ref', 'ISO3166-2'}
330                         }
331 module.NAME_TAGS.address = {house = {'addr:housename'}}
332 module.NAME_TAGS.poi = group_merge({main = {'brand'},
333                                     extra = {'iata', 'icao'}},
334                                    module.NAME_TAGS.core)
335
336 -- Address tagging
337
338 module.ADDRESS_TAGS = {}
339
340 module.ADDRESS_TAGS.core = { extra = {'addr:*', 'is_in:*', 'tiger:county'},
341                              postcode = {'postal_code', 'postcode', 'addr:postcode',
342                                          'tiger:zip_left', 'tiger:zip_right'},
343                              country = {'country_code', 'ISO3166-1',
344                                         'addr:country_code', 'is_in:country_code',
345                                         'addr:country', 'is_in:country'}
346                            }
347
348 module.ADDRESS_TAGS.houses = { main = {'addr:housenumber',
349                                        'addr:conscriptionnumber',
350                                        'addr:streetnumber'},
351                                interpolation = {'addr:interpolation'}
352                              }
353
354 -- Ignored tags (prefiltered away)
355
356 module.IGNORE_KEYS = {}
357
358 module.IGNORE_KEYS.metatags = {'note', 'note:*', 'source', 'source:*', '*source',
359                                'attribution', 'comment', 'fixme', 'created_by',
360                                'tiger:cfcc', 'tiger:reviewed', 'nysgissam:*',
361                                'NHD:*', 'nhd:*', 'gnis:*', 'geobase:*', 'yh:*',
362                                'osak:*', 'naptan:*', 'CLC:*', 'import', 'it:fvg:*',
363                                'lacounty:*', 'ref:linz:*',
364                                'ref:bygningsnr', 'ref:ruian:*', 'building:ruian:type',
365                                'type',
366                                'is_in:postcode'}
367 module.IGNORE_KEYS.name = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*',
368                            'name:etymology', 'name:etymology:*',
369                            'name:signed', 'name:botanical'}
370 module.IGNORE_KEYS.address = {'addr:street:*', 'addr:city:*', 'addr:district:*',
371                               'addr:province:*', 'addr:subdistrict:*', 'addr:place:*',
372                               'addr:TW:dataset'}
373
374 -- Extra tags (prefiltered away)
375
376 module.EXTRATAGS = {}
377
378 module.EXTRATAGS.required = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital'}
379
380 return module