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