harmonize use of callback with set_entrance_filter

All other functions except a simple function, so do this here as well.
This commit is contained in:
Sarah Hoffmann
2025-10-28 14:33:45 +01:00
parent 353c985b9f
commit f1fbc04f33
4 changed files with 19 additions and 14 deletions

View File

@@ -943,17 +943,22 @@ function module.set_relation_types(data)
end
function module.set_entrance_filter(data)
if data == nil or type(data) == 'function' then
ENTRANCE_FUNCTION = data
return nil
end
if type(data) == 'string' then
local preset = data
data = PRESETS.ENTRACE_TABLE[data]
data = PRESETS.ENTRANCE_TABLE[data]
if data == nil then
error('Unknown preset for entrance table: ' .. preset)
end
end
ENTRANCE_FUNCTION = data and data.func
ENTRANCE_FUNCTION = nil
if data ~= nil and data.main_tags ~= nil and next(data.main_tags) ~= nil then
if data.main_tags ~= nil and next(data.main_tags) ~= nil then
if data.extra_include ~= nil and next(data.extra_include) == nil then
-- shortcut: no extra tags requested
ENTRANCE_FUNCTION = function(o)

View File

@@ -383,9 +383,9 @@ module.EXTRATAGS.required = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital'}
-- Defaults for the entrance table
module.ENTRACE_TABLE = {}
module.ENTRANCE_TABLE = {}
module.ENTRACE_TABLE.default = {main_tags = {'entrance', 'routing:entrance'},
extra_exclude = module.IGNORE_KEYS.metatags}
module.ENTRANCE_TABLE.default = {main_tags = {'entrance', 'routing:entrance'},
extra_exclude = module.IGNORE_KEYS.metatags}
return module