From 2dda9079f0d3e02fd8ea9bb2b99bb9bb7bff0e73 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Fri, 24 Oct 2025 10:52:25 +0200 Subject: [PATCH] add BDD tests for importing into the new place_entrance table --- lib-lua/themes/nominatim/init.lua | 2 +- test/bdd/features/db/query/postcodes.feature | 2 +- .../osm2pgsql/import/entrances.feature | 124 ++++++++++++++++++ .../osm2pgsql/update/entrances.feature | 106 +++++++++++++++ 4 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 test/bdd/features/osm2pgsql/import/entrances.feature create mode 100644 test/bdd/features/osm2pgsql/update/entrances.feature diff --git a/lib-lua/themes/nominatim/init.lua b/lib-lua/themes/nominatim/init.lua index e43bdf66..228e5c55 100644 --- a/lib-lua/themes/nominatim/init.lua +++ b/lib-lua/themes/nominatim/init.lua @@ -953,7 +953,7 @@ function module.set_entrance_filter(data) ENTRANCE_FUNCTION = data and data.func - if data.main_tags ~= nil and next(data.main_tags) ~= nil then + if data ~= nil and 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) diff --git a/test/bdd/features/db/query/postcodes.feature b/test/bdd/features/db/query/postcodes.feature index f5ffcd00..819ea061 100644 --- a/test/bdd/features/db/query/postcodes.feature +++ b/test/bdd/features/db/query/postcodes.feature @@ -18,7 +18,7 @@ Feature: Querying fo postcode variants | 10 | | | | 11 | And the places | osm | class | type | name | addr+postcode | geometry | - | W1 | highway | path | De Weide | 3993 DX | 10,11 | + | W1 | highway | path | De Weide | | 10,11 | When importing When geocoding "3993 DX" Then result 0 contains diff --git a/test/bdd/features/osm2pgsql/import/entrances.feature b/test/bdd/features/osm2pgsql/import/entrances.feature new file mode 100644 index 00000000..3999743b --- /dev/null +++ b/test/bdd/features/osm2pgsql/import/entrances.feature @@ -0,0 +1,124 @@ +Feature: Import of entrance objects by osm2pgsql + Testing of correct setup of the entrance table + + Scenario: Import simple entrance + When loading osm data + """ + n1 Tshop=sweets,entrance=yes,access=public x4.5 y-4 + n2 Trouting:entrance=main x66.1 y0.1 + n3 Tentrance=main,routing:entrance=foot x1 y2 + n4 Thighway=bus_stop + """ + Then place contains exactly + | object | class | type | + | N1 | shop | sweets | + | N4 | highway | bus_stop | + And place_entrance contains exactly + | osm_id | type | extratags!dict | geometry!wkt | + | 1 | yes | 'shop': 'sweets', 'access': 'public' | 4.5 -4 | + | 2 | main | - | 66.1 0.1 | + | 3 | main | - | 1 2 | + + Scenario: Addresses and entrance information can exist on the same node + When loading osm data + """ + n1 Taddr:housenumber=10,addr:street=North,entrance=main + """ + Then place contains exactly + | object | class | type | address+housenumber | + | N1 | place | house | 10 | + And place_entrance contains exactly + | osm_id | type | + | 1 | main | + Scenario Outline: Entrance import can be disabled + Given the lua style file + """ + local flex = require('import-full') + flex.set_entrance_filter + """ + When loading osm data + """ + n1 Tentrance=yes,access=public + n2 Trouting:entrance=main + """ + Then place contains exactly + | object | + And place_entrance contains exactly + | osm_id | + + Examples: + | param | + | () | + | (nil) | + | {} | + | {include={'access'}} | + | {main_tags={}} | + + Scenario: Entrance import can have custom main tags + Given the lua style file + """ + local flex = require('import-full') + flex.set_entrance_filter{main_tags = {'door'}} + """ + When loading osm data + """ + n1 Tentrance=yes,access=public + n2 Tdoor=foot,entrance=yes + """ + Then place contains exactly + | object | + And place_entrance contains exactly + | osm_id | type | extratags!dict | + | 2 | foot | 'entrance': 'yes' | + + Scenario: Entrance import can have custom extra tags included + Given the lua style file + """ + local flex = require('import-full') + flex.set_entrance_filter{main_tags = {'entrance'}, + extra_include = {'access'}} + """ + When loading osm data + """ + n1 Tentrance=yes,access=public,shop=newspaper + n2 Tentrance=yes,shop=sweets + """ + Then place_entrance contains exactly + | osm_id | type | extratags!dict | + | 1 | yes | 'access': 'public' | + | 2 | yes | - | + + Scenario: Entrance import can have custom extra tags excluded + Given the lua style file + """ + local flex = require('import-full') + flex.set_entrance_filter{main_tags = {'entrance', 'door'}, + extra_exclude = {'shop'}} + """ + When loading osm data + """ + n1 Tentrance=yes,access=public,shop=newspaper + n2 Tentrance=yes,door=yes,shop=sweets + """ + Then place_entrance contains exactly + | osm_id | type | extratags!dict | + | 1 | yes | 'access': 'public' | + | 2 | yes | - | + + Scenario: Entrance import can have a custom function + Given the lua style file + """ + local flex = require('import-full') + flex.set_entrance_filter{func = function(object) + return {entrance='always', extratags = {ref = '1'}} + end} + """ + When loading osm data + """ + n1 Tentrance=yes,access=public,shop=newspaper + n2 Tshop=sweets + """ + Then place_entrance contains exactly + | osm_id | type | extratags!dict | + | 1 | always | 'ref': '1' | + | 2 | always | 'ref': '1' | diff --git a/test/bdd/features/osm2pgsql/update/entrances.feature b/test/bdd/features/osm2pgsql/update/entrances.feature new file mode 100644 index 00000000..44ec977d --- /dev/null +++ b/test/bdd/features/osm2pgsql/update/entrances.feature @@ -0,0 +1,106 @@ +Feature: Update of entrance objects by osm2pgsql + Testing of correct update of the entrance table + + Scenario: A new entrance is added + When loading osm data + """ + n1 Tshop=shoes + """ + Then place_entrance contains exactly + | osm_id | + When updating osm data + """ + n2 Tentrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | + | 2 | yes | + + Scenario: An existing entrance is deleted + When loading osm data + """ + n1 Tentrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | + | 1 | yes | + When updating osm data + """ + n1 dD + """ + Then place_entrance contains exactly + | osm_id | + + Scenario: An existing node becomes an entrance + When loading osm data + """ + n1 Tshop=sweets + """ + Then place_entrance contains exactly + | osm_id | type | + And place contains exactly + | object | class | + | N1 | shop | + When updating osm data + """ + n1 Tshop=sweets,entrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | + | 1 | yes | + And place contains exactly + | object | class | + | N1 | shop | + + Scenario: An existing entrance tag is removed + When loading osm data + """ + n1 Tshop=sweets,entrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | + | 1 | yes | + And place contains exactly + | object | class | + | N1 | shop | + When updating osm data + """ + n1 Tshop=sweets + """ + Then place_entrance contains exactly + | osm_id | type | + And place contains exactly + | object | class | + | N1 | shop | + + Scenario: Extratags are added to an entrance + When loading osm data + """ + n1 Tentrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | extratags | + | 1 | yes | - | + When updating osm data + """ + n1 Tentrance=yes,access=yes + """ + Then place_entrance contains exactly + | osm_id | type | extratags!dict | + | 1 | yes | 'access': 'yes' | + + Scenario: Extratags are deleted from an entrance + When loading osm data + """ + n1 Tentrance=yes,access=yes + """ + Then place_entrance contains exactly + | osm_id | type | extratags!dict | + | 1 | yes | 'access': 'yes' | + When updating osm data + """ + n1 Tentrance=yes + """ + Then place_entrance contains exactly + | osm_id | type | extratags | + | 1 | yes | - | -- 2.39.5