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