]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-lua/themes/nominatim/presets.lua
switch to subtags for tourism=information and natural=water
[nominatim.git] / lib-lua / themes / nominatim / presets.lua
index 01932812515795b8627a4a2a64ff258ea88d039c..f230433e80b03f8a2129bf47b4a8a35912f5c01f 100644 (file)
@@ -2,6 +2,57 @@
 
 local module = {}
 
+-- Customized main tag filter functions
+
+local EXCLUDED_FOOTWAYS = { sidewalk = 1, crossing = 1, link = 1, traffic_aisle }
+
+local function filter_footways(place)
+    if place.has_name then
+        local footway = place.object.tags.footway
+        if footway == nil or EXCLUDED_FOOTWAYS[footway] ~= 1 then
+            return place
+        end
+    end
+    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
+
 -- Main tag definition
 
 module.MAIN_TAGS = {}
@@ -51,9 +102,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)
@@ -100,6 +163,7 @@ module.MAIN_TAGS_POIS = function (group)
     historic = {'always',
                 yes = group,
                 no = group},
+    information = {include_when_tag_present('tourism', 'information')},
     junction = {'fallback',
                 no = group},
     leisure = {'always',
@@ -134,7 +198,8 @@ module.MAIN_TAGS_POIS = function (group)
             no = group},
     tourism = {'always',
                no = group,
-               yes = group},
+               yes = group,
+               information = 'fallback'},
     tunnel = {'named_with_key',
               no = group}
 } end
@@ -156,7 +221,7 @@ module.MAIN_TAGS_STREETS.default = {
                service = 'named',
                cycleway = 'named',
                path = 'named',
-               footway = 'named',
+               footway = filter_footways,
                steps = 'named',
                bridleway = 'named',
                track = 'named',
@@ -270,7 +335,9 @@ module.IGNORE_KEYS.metatags = {'note', 'note:*', 'source', 'source:*', '*source'
                                'is_in:postcode'}
 module.IGNORE_KEYS.name = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*',
                            'name:etymology', 'name:signed', 'name:botanical'}
-module.IGNORE_KEYS.address = {'addr:street:*', 'addr:TW:dataset'}
+module.IGNORE_KEYS.address = {'addr:street:*', 'addr:city:*', 'addr:district:*',
+                              'addr:province:*', 'addr:subdistrict:*', 'addr:place:*',
+                              'addr:TW:dataset'}
 
 -- Extra tags (prefiltered away)