]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-lua/themes/nominatim/presets.lua
exclude more tourism=information types
[nominatim.git] / lib-lua / themes / nominatim / presets.lua
index d8aa75340251f1c583e3a3906829d4f6976eea41..aa51ac14c70a192cdf7dd93b577f6715b04c3bdc 100644 (file)
@@ -2,6 +2,22 @@
 
 local module = {}
 
+-- Helper functions
+
+local function group_merge(group1, group2)
+    for name, values in pairs(group2) do
+        if group1[name] == nil then
+            group1[name] = values
+        else
+            for _, v in pairs(values) do
+                table.insert(group1[name], v)
+            end
+        end
+    end
+
+    return group1
+end
+
 -- Customized main tag filter functions
 
 local EXCLUDED_FOOTWAYS = { sidewalk = 1, crossing = 1, link = 1, traffic_aisle }
@@ -16,6 +32,54 @@ local function filter_footways(place)
     return false
 end
 
+local function include_when_tag_present(key, value, named)
+    if named then
+        return function(place)
+                   if place.has_name and place.intags[key] == value then
+                       return place
+                   end
+                   return false
+               end
+    else
+        return function(place)
+                   if place.intags[key] == value then
+                       return place
+                   end
+                   return false
+               end
+    end
+end
+
+local function exclude_when_key_present(key, named)
+    if named then
+        return function(place)
+                   if place.has_name and place.intags[key] == nil then
+                       return place
+                   end
+                   return false
+               end
+    else
+        return function(place)
+                   if place.intags[key] == nil then
+                       return place
+                   end
+                   return false
+               end
+
+    end
+end
+
+local function lock_transform(place)
+    if place.object.tags.waterway ~= nil then
+        local name = place.object.tags.lock_name
+        if name ~= nil then
+            return place:clone{names={name=name, ref=place.object.tags.lock_ref}}
+        end
+    end
+
+    return false
+end
+
 -- Main tag definition
 
 module.MAIN_TAGS = {}
@@ -65,9 +129,21 @@ module.MAIN_TAGS.natural = {
                yes = 'delete',
                no = 'delete',
                coastline = 'delete',
-               saddle = 'fallback'},
+               saddle = 'fallback',
+               water = exclude_when_key_present('water', true)},
     mountain_pass = {'always',
-                     no = 'delete'}
+                     no = 'delete'},
+    water = {include_when_tag_present('natural', 'water', true),
+             river = 'never',
+             stream = 'never',
+             canal = 'never',
+             ditch = 'never',
+             drain = 'never',
+             fish_pass = 'never',
+             yes = 'delete',
+             intermittent = 'delete',
+             tidal = 'delete'
+             }
 }
 
 module.MAIN_TAGS_POIS = function (group)
@@ -114,11 +190,17 @@ module.MAIN_TAGS_POIS = function (group)
     historic = {'always',
                 yes = group,
                 no = group},
+    information = {include_when_tag_present('tourism', 'information'),
+                   yes = 'delete',
+                   route_marker = 'never',
+                   trail_blaze = 'never'},
     junction = {'fallback',
                 no = group},
     leisure = {'always',
                nature_reserve = 'fallback',
+               swimming_pool = 'named',
                no = group},
+    lock = {yes = lock_transform},
     man_made = {pier = 'always',
                 tower = 'always',
                 bridge = 'always',
@@ -148,7 +230,8 @@ module.MAIN_TAGS_POIS = function (group)
             no = group},
     tourism = {'always',
                no = group,
-               yes = group},
+               yes = group,
+               information = exclude_when_key_present('information')},
     tunnel = {'named_with_key',
               no = group}
 } end
@@ -246,10 +329,9 @@ module.NAME_TAGS.core = {main = {'name', 'name:*',
                                   'loc_ref', 'old_ref', 'ISO3166-2'}
                         }
 module.NAME_TAGS.address = {house = {'addr:housename'}}
-module.NAME_TAGS.poi = {extra = {'ref', 'int_ref', 'nat_ref', 'reg_ref',
-                                       'loc_ref', 'old_ref',
-                                       'iata', 'icao',
-                                       'ISO3166-2'}}
+module.NAME_TAGS.poi = group_merge({main = {'brand'},
+                                    extra = {'iata', 'icao'}},
+                                   module.NAME_TAGS.core)
 
 -- Address tagging
 
@@ -283,7 +365,8 @@ module.IGNORE_KEYS.metatags = {'note', 'note:*', 'source', 'source:*', '*source'
                                'type',
                                'is_in:postcode'}
 module.IGNORE_KEYS.name = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*',
-                           'name:etymology', 'name:signed', 'name:botanical'}
+                           'name:etymology', 'name:etymology:*',
+                           'name:signed', 'name:botanical'}
 module.IGNORE_KEYS.address = {'addr:street:*', 'addr:city:*', 'addr:district:*',
                               'addr:province:*', 'addr:subdistrict:*', 'addr:place:*',
                               'addr:TW:dataset'}