remove old behave osm2pgsql BDD tests

This commit is contained in:
Sarah Hoffmann
2025-04-03 10:59:54 +02:00
parent fb440f29a2
commit ee62d5e1cf
14 changed files with 7 additions and 1712 deletions

View File

@@ -7,5 +7,5 @@ extend-ignore =
per-file-ignores = per-file-ignores =
__init__.py: F401 __init__.py: F401
test/python/utils/test_json_writer.py: E131 test/python/utils/test_json_writer.py: E131
test/python/conftest.py: E402 **/conftest.py: E402
test/bdd/*: F821 test/bdd/*: F821

View File

@@ -30,6 +30,7 @@ from utils.db import DBManager
from nominatim_db.config import Configuration from nominatim_db.config import Configuration
def _strlist(inp): def _strlist(inp):
return [s.strip() for s in inp.split(',')] return [s.strip() for s in inp.split(',')]
@@ -94,7 +95,6 @@ def template_db(pytestconfig):
return template_db return template_db
@when(step_parse(r'reverse geocoding (?P<lat>[\d.-]*),(?P<lon>[\d.-]*)'), @when(step_parse(r'reverse geocoding (?P<lat>[\d.-]*),(?P<lon>[\d.-]*)'),
target_fixture='nominatim_result') target_fixture='nominatim_result')
def reverse_geocode_via_api(test_config_env, pytestconfig, datatable, lat, lon): def reverse_geocode_via_api(test_config_env, pytestconfig, datatable, lat, lon):

View File

@@ -1,32 +0,0 @@
@DB
Feature: Import of objects with broken geometries by osm2pgsql
Scenario: Import way with double nodes
When loading osm data
"""
n100 x0 y0
n101 x0 y0.1
n102 x0.1 y0.2
w1 Thighway=primary Nn100,n101,n101,n102
"""
Then place contains
| object | class | type | geometry |
| W1 | highway | primary | 0 0, 0 0.1, 0.1 0.2 |
Scenario: Import of ballon areas
When loading osm data
"""
n1 x0 y0
n2 x0 y0.0001
n3 x0.00001 y0.0001
n4 x0.00001 y0
n5 x-0.00001 y0
w1 Thighway=unclassified Nn1,n2,n3,n4,n1,n5
w2 Thighway=unclassified Nn1,n2,n3,n4,n1
w3 Thighway=unclassified Nn1,n2,n3,n4,n3
"""
Then place contains
| object | geometrytype |
| W1 | ST_LineString |
| W2 | ST_Polygon |
| W3 | ST_LineString |

View File

@@ -1,319 +0,0 @@
@DB
Feature: Import with custom styles by osm2pgsql
Tests for the example customizations given in the documentation.
Scenario: Custom main tags (set new ones)
Given the lua style file
"""
local flex = require('import-full')
flex.set_main_tags{
boundary = {administrative = 'named'},
highway = {'always', street_lamp = 'named'},
landuse = 'fallback'
}
"""
When loading osm data
"""
n10 Tboundary=administrative x0 y0
n11 Tboundary=administrative,name=Foo x0 y0
n12 Tboundary=electoral x0 y0
n13 Thighway=primary x0 y0
n14 Thighway=street_lamp x0 y0
n15 Thighway=primary,landuse=street x0 y0
"""
Then place contains exactly
| object | class | type |
| N11 | boundary | administrative |
| N13 | highway | primary |
| N15 | highway | primary |
Scenario: Custom main tags (modify existing)
Given the lua style file
"""
local flex = require('import-full')
flex.modify_main_tags{
amenity = {prison = 'delete'},
highway = {stop = 'named'},
aeroway = 'named'
}
"""
When loading osm data
"""
n10 Tamenity=hotel x0 y0
n11 Tamenity=prison x0 y0
n12 Thighway=stop x0 y0
n13 Thighway=stop,name=BigStop x0 y0
n14 Thighway=give_way x0 y0
n15 Thighway=bus_stop x0 y0
n16 Taeroway=no,name=foo x0 y0
n17 Taeroway=taxiway,name=D15 x0 y0
"""
Then place contains exactly
| object | class | type |
| N10 | amenity | hotel |
| N13 | highway | stop |
| N15 | highway | bus_stop |
| N17 | aeroway | taxiway |
Scenario: Prefiltering tags
Given the lua style file
"""
local flex = require('import-full')
flex.set_prefilters{
delete_keys = {'source', 'source:*'},
extra_tags = {amenity = {'yes', 'no'}}
}
flex.set_main_tags{
amenity = 'always',
tourism = 'always'
}
"""
When loading osm data
"""
n1 Tamenity=yes x0 y6
n2 Tamenity=hospital,source=survey x3 y6
n3 Ttourism=hotel,amenity=yes x0 y0
n4 Ttourism=hotel,amenity=telephone x0 y0
"""
Then place contains exactly
| object | extratags |
| N2:amenity | - |
| N3:tourism | 'amenity': 'yes' |
| N4:tourism | - |
| N4:amenity | - |
Scenario: Ignore some tags
Given the lua style file
"""
local flex = require('import-extratags')
flex.ignore_keys{'ref:*', 'surface'}
"""
When loading osm data
"""
n100 Thighway=residential,ref=34,ref:bodo=34,surface=gray,extra=1 x0 y0
"""
Then place contains exactly
| object | name | extratags |
| N100 | 'ref' : '34' | 'extra': '1' |
Scenario: Add for extratags
Given the lua style file
"""
local flex = require('import-full')
flex.add_for_extratags{'ref:*', 'surface'}
"""
When loading osm data
"""
n100 Thighway=residential,ref=34,ref:bodo=34,surface=gray,extra=1 x0 y0
"""
Then place contains exactly
| object | name | extratags |
| N100 | 'ref' : '34' | 'ref:bodo': '34', 'surface': 'gray' |
Scenario: Name tags
Given the lua style file
"""
local flex = require('flex-base')
flex.set_main_tags{highway = {traffic_light = 'named'}}
flex.set_name_tags{main = {'name', 'name:*'},
extra = {'ref'}
}
"""
When loading osm data
"""
n1 Thighway=stop,name=Something x0 y0
n2 Thighway=traffic_light,ref=453-4 x0 y0
n3 Thighway=traffic_light,name=Greens x0 y0
n4 Thighway=traffic_light,name=Red,ref=45 x0 y0
"""
Then place contains exactly
| object | name |
| N3:highway | 'name': 'Greens' |
| N4:highway | 'name': 'Red', 'ref': '45' |
Scenario: Modify name tags
Given the lua style file
"""
local flex = require('import-full')
flex.modify_name_tags{house = {}, extra = {'o'}}
"""
When loading osm data
"""
n1 Ttourism=hotel,ref=45,o=good
n2 Taddr:housename=Old,addr:street=Away
"""
Then place contains exactly
| object | name |
| N1:tourism | 'o': 'good' |
Scenario: Address tags
Given the lua style file
"""
local flex = require('import-full')
flex.set_address_tags{
main = {'addr:housenumber'},
extra = {'addr:*'},
postcode = {'postal_code', 'postcode', 'addr:postcode'},
country = {'country-code', 'ISO3166-1'}
}
"""
When loading osm data
"""
n1 Ttourism=hotel,addr:street=Foo x0 y0
n2 Taddr:housenumber=23,addr:street=Budd,postal_code=5567 x0 y0
n3 Taddr:street=None,addr:city=Where x0 y0
"""
Then place contains exactly
| object | type | address |
| N1:tourism | hotel | 'street': 'Foo' |
| N2:place | house | 'housenumber': '23', 'street': 'Budd', 'postcode': '5567' |
Scenario: Modify address tags
Given the lua style file
"""
local flex = require('import-full')
flex.set_address_tags{
extra = {'addr:*'},
}
"""
When loading osm data
"""
n2 Taddr:housenumber=23,addr:street=Budd,is_in:city=Faraway,postal_code=5567 x0 y0
"""
Then place contains exactly
| object | type | address |
| N2:place | house | 'housenumber': '23', 'street': 'Budd', 'postcode': '5567' |
Scenario: Unused handling (delete)
Given the lua style file
"""
local flex = require('import-full')
flex.set_address_tags{
main = {'addr:housenumber'},
extra = {'addr:*', 'tiger:county'}
}
flex.set_unused_handling{delete_keys = {'tiger:*'}}
"""
When loading osm data
"""
n1 Ttourism=hotel,tiger:county=Fargo x0 y0
n2 Ttourism=hotel,tiger:xxd=56,else=other x0 y0
"""
Then place contains exactly
| object | type | address | extratags |
| N1:tourism | hotel | 'tiger:county': 'Fargo' | - |
| N2:tourism | hotel | - | 'else': 'other' |
Scenario: Unused handling (extra)
Given the lua style file
"""
local flex = require('flex-base')
flex.set_main_tags{highway = 'always',
wikipedia = 'extra'}
flex.add_for_extratags{'wikipedia:*', 'wikidata'}
flex.set_unused_handling{extra_keys = {'surface'}}
"""
When loading osm data
"""
n100 Thighway=path,foo=bar,wikipedia=en:Path x0 y0
n234 Thighway=path,surface=rough x0 y0
n445 Thighway=path,name=something x0 y0
n446 Thighway=path,wikipedia:en=Path,wikidata=Q23 x0 y0
n567 Thighway=path,surface=dirt,wikipedia:en=Path x0 y0
"""
Then place contains exactly
| object | type | extratags |
| N100:highway | path | 'wikipedia': 'en:Path' |
| N234:highway | path | 'surface': 'rough' |
| N445:highway | path | - |
| N446:highway | path | 'wikipedia:en': 'Path', 'wikidata': 'Q23' |
| N567:highway | path | 'surface': 'dirt', 'wikipedia:en': 'Path' |
Scenario: Additional relation types
Given the lua style file
"""
local flex = require('import-full')
flex.RELATION_TYPES['site'] = flex.relation_as_multipolygon
"""
And the grid
| 1 | 2 |
| 4 | 3 |
When loading osm data
"""
n1
n2
n3
n4
w1 Nn1,n2,n3,n4,n1
r1 Ttype=multipolygon,amenity=school Mw1@
r2 Ttype=site,amenity=school Mw1@
"""
Then place contains exactly
| object | type |
| R1:amenity | school |
| R2:amenity | school |
Scenario: Exclude country relations
Given the lua style file
"""
local flex = require('import-full')
function osm2pgsql.process_relation(object)
if object.tags.boundary ~= 'administrative' or object.tags.admin_level ~= '2' then
flex.process_relation(object)
end
end
"""
And the grid
| 1 | 2 |
| 4 | 3 |
When loading osm data
"""
n1
n2
n3
n4
w1 Nn1,n2,n3,n4,n1
r1 Ttype=multipolygon,boundary=administrative,admin_level=4,name=Small Mw1@
r2 Ttype=multipolygon,boundary=administrative,admin_level=2,name=Big Mw1@
"""
Then place contains exactly
| object | type |
| R1:boundary | administrative |
Scenario: Customize processing functions
Given the lua style file
"""
local flex = require('import-full')
local original_process_tags = flex.process_tags
function flex.process_tags(o)
if o.object.tags.highway ~= nil and o.object.tags.access == 'no' then
return
end
original_process_tags(o)
end
"""
When loading osm data
"""
n1 Thighway=residential x0 y0
n2 Thighway=residential,access=no x0 y0
"""
Then place contains exactly
| object | type |
| N1:highway | residential |

View File

@@ -1,11 +0,0 @@
@DB
Feature: Import of relations by osm2pgsql
Testing specific relation problems related to members.
Scenario: Don't import empty waterways
When loading osm data
"""
n1 Tamenity=prison,name=foo
r1 Ttype=waterway,waterway=river,name=XZ Mn1@
"""
Then place has no entry for R1

View File

@@ -1,43 +0,0 @@
@DB
Feature: Import of simple objects by osm2pgsql
Testing basic tagging in osm2pgsql imports.
Scenario: Import simple objects
When loading osm data
"""
n1 Tamenity=prison,name=foo x34.3 y-23
n100 x0 y0
n101 x0 y0.1
n102 x0.1 y0.2
n200 x0 y0
n201 x0 y1
n202 x1 y1
n203 x1 y0
w1 Tshop=toys,name=tata Nn100,n101,n102
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mn1@,w2@
"""
Then place contains exactly
| object | class | type | name | geometry |
| N1 | amenity | prison | 'name' : 'foo' | 34.3 -23 |
| W1 | shop | toys | 'name' : 'tata' | 0 0, 0 0.1, 0.1 0.2 |
| R1 | tourism | hotel | 'name' : 'XZ' | (0 0, 0 1, 1 1, 1 0, 0 0) |
Scenario: Import object with two main tags
When loading osm data
"""
n1 Ttourism=hotel,amenity=restaurant,name=foo
"""
Then place contains
| object | type | name |
| N1:tourism | hotel | 'name' : 'foo' |
| N1:amenity | restaurant | 'name' : 'foo' |
Scenario: Import stand-alone house number with postcode
When loading osm data
"""
n1 Taddr:housenumber=4,addr:postcode=3345
"""
Then place contains
| object | class | type |
| N1 | place | house |

View File

@@ -1,290 +0,0 @@
@DB
Feature: Tag evaluation
Tests if tags are correctly imported into the place table
Scenario: Main tags as fallback
When loading osm data
"""
n100 Tjunction=yes,highway=bus_stop
n101 Tjunction=yes,name=Bar
n200 Tbuilding=yes,amenity=cafe
n201 Tbuilding=yes,name=Intersting
n202 Tbuilding=yes
"""
Then place contains exactly
| object | class | type |
| N100 | highway | bus_stop |
| N101 | junction | yes |
| N200 | amenity | cafe |
| N201 | building | yes |
Scenario: Name and reg tags
When loading osm data
"""
n2001 Thighway=road,name=Foo,alt_name:de=Bar,ref=45
n2002 Thighway=road,name:prefix=Pre,name:suffix=Post,ref:de=55
n2003 Thighway=yes,name:%20%de=Foo,name=real1
n2004 Thighway=yes,name:%a%de=Foo,name=real2
n2005 Thighway=yes,name:%9%de=Foo,name:\\=real3
n2006 Thighway=yes,name:%9%de=Foo,name=rea\l3
"""
Then place contains exactly
| object | class | type | name |
| N2001 | highway | road | 'name': 'Foo', 'alt_name:de': 'Bar', 'ref': '45' |
| N2002 | highway | road | - |
| N2003 | highway | yes | 'name: de': 'Foo', 'name': 'real1' |
| N2004 | highway | yes | 'name:\nde': 'Foo', 'name': 'real2' |
| N2005 | highway | yes | 'name:\tde': 'Foo', 'name:\\\\': 'real3' |
| N2006 | highway | yes | 'name:\tde': 'Foo', 'name': 'rea\\l3' |
And place contains
| object | extratags |
| N2002 | 'name:prefix': 'Pre', 'name:suffix': 'Post', 'ref:de': '55' |
Scenario: Name when using with_name flag
When loading osm data
"""
n3001 Tbridge=yes,bridge:name=GoldenGate
n3002 Tbridge=yes,bridge:name:en=Rainbow
"""
Then place contains exactly
| object | class | type | name |
| N3001 | bridge | yes | 'name': 'GoldenGate' |
| N3002 | bridge | yes | 'name:en': 'Rainbow' |
Scenario: Address tags
When loading osm data
"""
n4001 Taddr:housenumber=34,addr:city=Esmarald,addr:county=Land
n4002 Taddr:streetnumber=10,is_in:city=Rootoo,is_in=Gold
"""
Then place contains exactly
| object | class | address |
| N4001 | place | 'housenumber': '34', 'city': 'Esmarald', 'county': 'Land' |
| N4002 | place | 'streetnumber': '10', 'city': 'Rootoo' |
Scenario: Country codes
When loading osm data
"""
n5001 Tshop=yes,country_code=DE
n5002 Tshop=yes,country_code=toolong
n5003 Tshop=yes,country_code=x
n5004 Tshop=yes,addr:country=us
n5005 Tshop=yes,country=be
n5006 Tshop=yes,addr:country=France
"""
Then place contains exactly
| object | class | address |
| N5001 | shop | 'country': 'DE' |
| N5002 | shop | - |
| N5003 | shop | - |
| N5004 | shop | 'country': 'us' |
| N5005 | shop | - |
| N5006 | shop | - |
Scenario: Postcodes
When loading osm data
"""
n6001 Tshop=bank,addr:postcode=12345
n6002 Tshop=bank,tiger:zip_left=34343
n6003 Tshop=bank,is_in:postcode=9009
"""
Then place contains exactly
| object | class | address |
| N6001 | shop | 'postcode': '12345' |
| N6002 | shop | 'postcode': '34343' |
| N6003 | shop | - |
Scenario: Postcode areas
When loading osm data
"""
n1 x12.36853 y51.50618
n2 x12.36853 y51.42362
n3 x12.63666 y51.42362
n4 x12.63666 y51.50618
w1 Tboundary=postal_code,ref=3456 Nn1,n2,n3,n4,n1
"""
Then place contains exactly
| object | class | type | name |
| W1 | boundary | postal_code | 'ref': '3456' |
Scenario: Main with extra
When loading osm data
"""
n7001 Thighway=primary,bridge=yes,name=1
n7002 Thighway=primary,bridge=yes,bridge:name=1
"""
Then place contains exactly
| object | class | type | name | extratags+bridge:name |
| N7001 | highway | primary | 'name': '1' | - |
| N7002:highway | highway | primary | - | 1 |
| N7002:bridge | bridge | yes | 'name': '1' | 1 |
Scenario: Global fallback and skipping
When loading osm data
"""
n8001 Tshop=shoes,note:de=Nein,xx=yy
n8002 Tshop=shoes,natural=no,ele=234
n8003 Tshop=shoes,name:source=survey
"""
Then place contains exactly
| object | class | name | extratags |
| N8001 | shop | - | 'xx': 'yy' |
| N8002 | shop | - | 'ele': '234' |
| N8003 | shop | - | - |
Scenario: Admin levels
When loading osm data
"""
n9001 Tplace=city
n9002 Tplace=city,admin_level=16
n9003 Tplace=city,admin_level=x
n9004 Tplace=city,admin_level=1
n9005 Tplace=city,admin_level=0
n9006 Tplace=city,admin_level=2.5
"""
Then place contains exactly
| object | class | admin_level |
| N9001 | place | 15 |
| N9002 | place | 15 |
| N9003 | place | 15 |
| N9004 | place | 1 |
| N9005 | place | 15 |
| N9006 | place | 15 |
Scenario: Administrative boundaries with place tags
When loading osm data
"""
n10001 Tboundary=administrative,place=city,name=A
n10002 Tboundary=natural,place=city,name=B
n10003 Tboundary=administrative,place=island,name=C
"""
Then place contains
| object | class | type | extratags |
| N10001 | boundary | administrative | 'place': 'city' |
And place contains
| object | class | type |
| N10002:boundary | boundary | natural |
| N10002:place | place | city |
| N10003:boundary | boundary | administrative |
| N10003:place | place | island |
Scenario: Building fallbacks
When loading osm data
"""
n12001 Ttourism=hotel,building=yes
n12002 Tbuilding=house
n12003 Tbuilding=shed,addr:housenumber=1
n12004 Tbuilding=yes,name=Das-Haus
n12005 Tbuilding=yes,addr:postcode=12345
"""
Then place contains exactly
| object | class | type |
| N12001 | tourism | hotel |
| N12003 | building | shed |
| N12004 | building | yes |
| N12005 | place | postcode |
Scenario: Address interpolations
When loading osm data
"""
n13001 Taddr:interpolation=odd
n13002 Taddr:interpolation=even,place=city
"""
Then place contains exactly
| object | class | type | address |
| N13001 | place | houses | 'interpolation': 'odd' |
| N13002 | place | houses | 'interpolation': 'even' |
Scenario: Footways
When loading osm data
"""
n1 x0.0 y0.0
n2 x0 y0.0001
w1 Thighway=footway Nn1,n2
w2 Thighway=footway,name=Road Nn1,n2
w3 Thighway=footway,name=Road,footway=sidewalk Nn1,n2
w4 Thighway=footway,name=Road,footway=crossing Nn1,n2
w5 Thighway=footway,name=Road,footway=residential Nn1,n2
"""
Then place contains exactly
| object | name+name |
| W2 | Road |
| W5 | Road |
Scenario: Tourism information
When loading osm data
"""
n100 Ttourism=information
n101 Ttourism=information,name=Generic
n102 Ttourism=information,information=guidepost
n103 Thighway=information,information=house
n104 Ttourism=information,information=yes,name=Something
n105 Ttourism=information,information=route_marker,name=3
"""
Then place contains exactly
| object | type |
| N100:tourism | information |
| N101:tourism | information |
| N102:information | guidepost |
| N103:highway | information |
| N104:tourism | information |
Scenario: Water features
When loading osm data
"""
n20 Tnatural=water
n21 Tnatural=water,name=SomePond
n22 Tnatural=water,water=pond
n23 Tnatural=water,water=pond,name=Pond
n24 Tnatural=water,water=river,name=BigRiver
n25 Tnatural=water,water=yes
n26 Tnatural=water,water=yes,name=Random
"""
Then place contains exactly
| object | type |
| N21:natural | water |
| N23:water | pond |
| N26:natural | water |
Scenario: Drop name for address fallback
When loading osm data
"""
n1 Taddr:housenumber=23,name=Foo
n2 Taddr:housenumber=23,addr:housename=Foo
n3 Taddr:housenumber=23
"""
Then place contains exactly
| object | type | address | name |
| N1:place | house | 'housenumber': '23' | - |
| N2:place | house | 'housenumber': '23' | 'addr:housename': 'Foo' |
| N3:place | house | 'housenumber': '23' | - |
Scenario: Waterway locks
When loading osm data
"""
n1 Twaterway=river,lock=yes
n2 Twaterway=river,lock=yes,lock_name=LeLock
n3 Twaterway=river,lock=yes,name=LeWater
n4 Tamenity=parking,lock=yes,lock_name=Gold
"""
Then place contains exactly
| object | type | name |
| N2:lock | yes | 'name': 'LeLock' |
| N3:waterway | river | 'name': 'LeWater' |
| N4:amenity | parking | - |

View File

@@ -1,137 +0,0 @@
@DB
Feature: Updates of address interpolation objects
Test that changes to address interpolation objects are correctly
propagated.
Background:
Given the grid
| 1 | 2 |
Scenario: Adding a new interpolation
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential,name=Tao Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
When updating osm data
"""
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:place | houses |
When indexing
Then placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W33:highway | residential |
Then location_property_osmline contains exactly
| object |
| 99:5 |
Scenario: Delete an existing interpolation
When loading osm data
"""
n1 Taddr:housenumber=2
n2 Taddr:housenumber=7
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:place | houses |
When updating osm data
"""
w99 v2 dD
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
When indexing
Then placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
Then location_property_osmline contains exactly
| object | indexed_status |
Scenario: Changing an object to an interpolation
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential Nn1,n2
w99 Thighway=residential Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:highway | residential |
When updating osm data
"""
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:place | houses |
When indexing
Then placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W33:highway | residential |
And location_property_osmline contains exactly
| object |
| 99:5 |
Scenario: Changing an interpolation to something else
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:place | houses |
When updating osm data
"""
w99 Thighway=residential Nn1,n2
"""
Then place contains
| object | type |
| N1:place | house |
| N2:place | house |
| W99:highway | residential |
When indexing
Then placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W99:highway | residential |
And location_property_osmline contains exactly
| object |

View File

@@ -1,167 +0,0 @@
@DB
Feature: Update of postcode only objects
Tests that changes to objects containing only a postcode are
propagated correctly.
Scenario: Adding a postcode-only node
When loading osm data
"""
"""
Then place contains exactly
| object |
When updating osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | type |
| N34:place | postcode |
When indexing
Then placex contains exactly
| object |
Scenario: Deleting a postcode-only node
When loading osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | type |
| N34:place | postcode |
When updating osm data
"""
n34 v2 dD
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario Outline: Converting a regular object into a postcode-only node
When loading osm data
"""
n34 T<class>=<type>
"""
Then place contains exactly
| object | type |
| N34:<class> | <type> |
When updating osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | type |
| N34:place | postcode |
When indexing
Then placex contains exactly
| object |
Examples:
| class | type |
| amenity | restaurant |
| place | hamlet |
Scenario Outline: Converting a postcode-only node into a regular object
When loading osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | type |
| N34:place | postcode |
When updating osm data
"""
n34 T<class>=<type>
"""
Then place contains exactly
| object | type |
| N34:<class> | <type> |
When indexing
Then placex contains exactly
| object | type |
| N34:<class> | <type> |
Examples:
| class | type |
| amenity | restaurant |
| place | hamlet |
Scenario: Converting na interpolation into a postcode-only node
Given the grid
| 1 | 2 |
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w34 Taddr:interpolation=odd Nn1,n2
"""
Then place contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W34:place | houses |
When updating osm data
"""
w34 Tpostcode=4456 Nn1,n2
"""
Then place contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W34:place | postcode |
When indexing
Then location_property_osmline contains exactly
| object |
And placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
Scenario: Converting a postcode-only node into an interpolation
Given the grid
| 1 | 2 |
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential Nn1,n2
w34 Tpostcode=4456 Nn1,n2
"""
Then place contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W33:highway | residential |
| W34:place | postcode |
When updating osm data
"""
w34 Taddr:interpolation=odd Nn1,n2
"""
Then place contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W33:highway | residential |
| W34:place | houses |
When indexing
Then location_property_osmline contains exactly
| object |
| 34:5 |
And placex contains exactly
| object | type |
| N1:place | house |
| N2:place | house |
| W33:highway | residential |

View File

@@ -1,141 +0,0 @@
@DB
Feature: Update of relations by osm2pgsql
Testing relation update by osm2pgsql.
Scenario: Remove all members of a relation
When loading osm data
"""
n1 Tamenity=prison,name=foo
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45' Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XZ' |
When updating osm data
"""
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mn1@
"""
Then place has no entry for R1
Scenario: Change type of a relation
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XZ' |
When updating osm data
"""
r1 Ttype=multipolygon,amenity=prison,name=XZ Mw2@
"""
Then place has no entry for R1:tourism
And place contains
| object | class | type | name |
| R1 | amenity | prison | 'name' : 'XZ' |
Scenario: Change name of a relation
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=AB Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'AB' |
When updating osm data
"""
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XY' |
Scenario: Change type of a relation into something unknown
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttype=multipolygon,amenities=prison,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Type tag is removed
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttourism=hotel,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Type tag is renamed to something unknown
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttype=multipolygonn,tourism=hotel,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Country boundary names are left untouched when country_code unknown
When loading osm data
"""
n200 Tamenity=prison x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
"""
And updating osm data
"""
w1 Nn200,n201,n202,n203,n200
r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=XX,admin_level=2 Mw1@
"""
Then place contains
| object | addr+country | name |
| R1 | XX | 'name' : 'Foo' |

View File

@@ -1,49 +0,0 @@
@DB
Feature: Update of simple objects by osm2pgsql
Testing basic update functions of osm2pgsql.
Scenario: Adding a new object
When loading osm data
"""
n1 Tplace=town,name=Middletown
"""
Then place contains exactly
| object | type | name+name |
| N1:place | town | Middletown |
When updating osm data
"""
n2 Tamenity=hotel,name=Posthotel
"""
Then place contains exactly
| object | type | name+name |
| N1:place | town | Middletown |
| N2:amenity | hotel | Posthotel |
And placex contains exactly
| object | type | name+name | indexed_status |
| N1:place | town | Middletown | 0 |
| N2:amenity | hotel | Posthotel | 1 |
Scenario: Deleting an existing object
When loading osm data
"""
n1 Tplace=town,name=Middletown
n2 Tamenity=hotel,name=Posthotel
"""
Then place contains exactly
| object | type | name+name |
| N1:place | town | Middletown |
| N2:amenity | hotel | Posthotel |
When updating osm data
"""
n2 dD
"""
Then place contains exactly
| object | type | name+name |
| N1:place | town | Middletown |
And placex contains exactly
| object | type | name+name | indexed_status |
| N1:place | town | Middletown | 0 |
| N2:amenity | hotel | Posthotel | 100 |

View File

@@ -1,513 +0,0 @@
@DB
Feature: Tag evaluation
Tests if tags are correctly updated in the place table
Background:
Given the grid
| 1 | 2 | 3 |
| 10 | 11 | |
| 45 | 46 | |
Scenario: Main tag deleted
When loading osm data
"""
n1 Tamenity=restaurant
n2 Thighway=bus_stop,railway=stop,name=X
n3 Tamenity=prison
"""
Then place contains exactly
| object | class | type |
| N1 | amenity | restaurant |
| N2:highway | highway | bus_stop |
| N2:railway | railway | stop |
| N3 | amenity | prison |
When updating osm data
"""
n1 Tnot_a=restaurant
n2 Thighway=bus_stop,name=X
"""
Then place contains exactly
| object | class | type |
| N2:highway | highway | bus_stop |
| N3 | amenity | prison |
And placex contains
| object | indexed_status |
| N3:amenity | 0 |
When indexing
Then placex contains exactly
| object | type | name |
| N2:highway | bus_stop | 'name': 'X' |
| N3:amenity | prison | - |
Scenario: Main tag added
When loading osm data
"""
n1 Tatity=restaurant
n2 Thighway=bus_stop,name=X
"""
Then place contains exactly
| object | class | type |
| N2:highway | highway | bus_stop |
When updating osm data
"""
n1 Tamenity=restaurant
n2 Thighway=bus_stop,railway=stop,name=X
"""
Then place contains exactly
| object | class | type |
| N1 | amenity | restaurant |
| N2:highway | highway | bus_stop |
| N2:railway | railway | stop |
When indexing
Then placex contains exactly
| object | type | name |
| N1:amenity | restaurant | - |
| N2:highway | bus_stop | 'name': 'X' |
| N2:railway | stop | 'name': 'X' |
Scenario: Main tag modified
When loading osm data
"""
n10 Thighway=footway,name=X
n11 Tamenity=atm
"""
Then place contains exactly
| object | class | type |
| N10 | highway | footway |
| N11 | amenity | atm |
When updating osm data
"""
n10 Thighway=path,name=X
n11 Thighway=primary
"""
Then place contains exactly
| object | class | type |
| N10 | highway | path |
| N11 | highway | primary |
When indexing
Then placex contains exactly
| object | type | name |
| N10:highway | path | 'name': 'X' |
| N11:highway | primary | - |
Scenario: Main tags with name, name added
When loading osm data
"""
n45 Tlanduse=cemetry
n46 Tbuilding=yes
"""
Then place contains exactly
| object | class | type |
When updating osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type |
| N45 | landuse | cemetry |
| N46 | building| yes |
When indexing
Then placex contains exactly
| object | type | name | address |
| N45:landuse | cemetry | 'name': 'TODO' | - |
| N46:building| yes | - | 'housenumber': '1' |
Scenario: Main tags with name, name removed
When loading osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type |
| N45 | landuse | cemetry |
| N46 | building| yes |
When updating osm data
"""
n45 Tlanduse=cemetry
n46 Tbuilding=yes
"""
Then place contains exactly
| object | class | type |
When indexing
Then placex contains exactly
| object |
Scenario: Main tags with name, name modified
When loading osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type | name | address |
| N45 | landuse | cemetry | 'name' : 'TODO' | - |
| N46 | building| yes | - | 'housenumber': '1'|
When updating osm data
"""
n45 Tlanduse=cemetry,name=DONE
n46 Tbuilding=yes,addr:housenumber=10
"""
Then place contains exactly
| object | class | type | name | address |
| N45 | landuse | cemetry | 'name' : 'DONE' | - |
| N46 | building| yes | - | 'housenumber': '10'|
When indexing
Then placex contains exactly
| object | class | type | name | address |
| N45 | landuse | cemetry | 'name' : 'DONE' | - |
| N46 | building| yes | - | 'housenumber': '10'|
Scenario: Main tag added to address only node
When loading osm data
"""
n1 Taddr:housenumber=345
"""
Then place contains exactly
| object | class | type | address |
| N1 | place | house | 'housenumber': '345'|
When updating osm data
"""
n1 Taddr:housenumber=345,building=yes
"""
Then place contains exactly
| object | class | type | address |
| N1 | building | yes | 'housenumber': '345'|
When indexing
Then placex contains exactly
| object | class | type | address |
| N1 | building | yes | 'housenumber': '345'|
Scenario: Main tag removed from address only node
When loading osm data
"""
n1 Taddr:housenumber=345,building=yes
"""
Then place contains exactly
| object | class | type | address |
| N1 | building | yes | 'housenumber': '345'|
When updating osm data
"""
n1 Taddr:housenumber=345
"""
Then place contains exactly
| object | class | type | address |
| N1 | place | house | 'housenumber': '345'|
When indexing
Then placex contains exactly
| object | class | type | address |
| N1 | place | house | 'housenumber': '345'|
Scenario: Main tags with name key, adding key name
When loading osm data
"""
n2 Tbridge=yes
"""
Then place contains exactly
| object | class | type |
When updating osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name': 'high' |
When indexing
Then placex contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name': 'high' |
Scenario: Main tags with name key, deleting key name
When loading osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name': 'high' |
When updating osm data
"""
n2 Tbridge=yes
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario: Main tags with name key, changing key name
When loading osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name': 'high' |
When updating osm data
"""
n2 Tbridge=yes,bridge:name:en=high
"""
Then place contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name:en': 'high' |
When indexing
Then placex contains exactly
| object | class | type | name |
| N2 | bridge | yes | 'name:en': 'high' |
Scenario: Downgrading a highway to one that is dropped without name
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=residential Nn100,n101
"""
Then place contains exactly
| object |
| W1:highway |
When updating osm data
"""
w1 Thighway=service Nn100,n101
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario: Upgrading a highway to one that is not dropped without name
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=service Nn100,n101
"""
Then place contains exactly
| object |
When updating osm data
"""
w1 Thighway=unclassified Nn100,n101
"""
Then place contains exactly
| object |
| W1:highway |
When indexing
Then placex contains exactly
| object |
| W1:highway |
Scenario: Downgrading a highway when a second tag is present
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=residential,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | type |
| W1:highway | residential |
| W1:tourism | hotel |
When updating osm data
"""
w1 Thighway=service,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | type |
| W1:tourism | hotel |
When indexing
Then placex contains exactly
| object | type |
| W1:tourism | hotel |
Scenario: Upgrading a highway when a second tag is present
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=service,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | type |
| W1:tourism | hotel |
When updating osm data
"""
w1 Thighway=residential,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | type |
| W1:highway | residential |
| W1:tourism | hotel |
When indexing
Then placex contains exactly
| object | type |
| W1:highway | residential |
| W1:tourism | hotel |
Scenario: Replay on administrative boundary
When loading osm data
"""
n10 x34.0 y-4.23
n11 x34.1 y-4.23
n12 x34.2 y-4.13
w10 Tboundary=administrative,waterway=river,name=Border,admin_level=2 Nn12,n11,n10
"""
Then place contains exactly
| object | type | admin_level | name |
| W10:waterway | river | 2 | 'name': 'Border' |
| W10:boundary | administrative | 2 | 'name': 'Border' |
When updating osm data
"""
w10 Tboundary=administrative,waterway=river,name=Border,admin_level=2 Nn12,n11,n10
"""
Then place contains exactly
| object | type | admin_level | name |
| W10:waterway | river | 2 | 'name': 'Border' |
| W10:boundary | administrative | 2 | 'name': 'Border' |
When indexing
Then placex contains exactly
| object | type | admin_level | name |
| W10:waterway | river | 2 | 'name': 'Border' |
Scenario: Change admin_level on administrative boundary
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=2 Mw10@
"""
Then place contains exactly
| object | admin_level |
| R10:boundary | 2 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | type | admin_level |
| R10:boundary | administrative | 4 |
When indexing
Then placex contains exactly
| object | type | admin_level |
| R10:boundary | administrative | 4 |
Scenario: Change boundary to administrative
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=informal,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | type | admin_level |
| R10:boundary | informal | 4 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | type | admin_level |
| R10:boundary | administrative | 4 |
When indexing
Then placex contains exactly
| object | type | admin_level |
| R10:boundary | administrative | 4 |
Scenario: Change boundary away from administrative
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | type | admin_level |
| R10:boundary | administrative | 4 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=informal,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | type | admin_level |
| R10:boundary | informal | 4 |
When indexing
Then placex contains exactly
| object | type | admin_level |
| R10:boundary | informal | 4 |
Scenario: Main tag and geometry is changed
When loading osm data
"""
n1 x40 y40
n2 x40.0001 y40
n3 x40.0001 y40.0001
n4 x40 y40.0001
w5 Tbuilding=house,name=Foo Nn1,n2,n3,n4,n1
"""
Then place contains exactly
| object | type |
| W5:building | house |
When updating osm data
"""
n1 x39.999 y40
w5 Tbuilding=terrace,name=Bar Nn1,n2,n3,n4,n1
"""
Then place contains exactly
| object | type |
| W5:building | terrace |

View File

@@ -10,7 +10,6 @@ Helper functions to compare expected values.
import json import json
import re import re
import math import math
import itertools
from psycopg import sql as pysql from psycopg import sql as pysql
from psycopg.rows import dict_row, tuple_row from psycopg.rows import dict_row, tuple_row
@@ -152,18 +151,16 @@ class ResultAttr:
ccode = geom[8:].upper() ccode = geom[8:].upper()
assert ccode in ALIASES, f"Geometry error: unknown country {ccode}" assert ccode in ALIASES, f"Geometry error: unknown country {ccode}"
return m[1] == 'POINT' and \ return m[1] == 'POINT' and \
all(math.isclose(p1, p2) for p1, p2 in all(math.isclose(p1, p2) for p1, p2 in zip(converted[0], ALIASES[ccode]))
zip(converted[0], ALIASES[ccode]))
if ',' not in expected: if ',' not in expected:
return m[1] == 'POINT' and \ return m[1] == 'POINT' and \
all(math.isclose(p1, p2) for p1, p2 in all(math.isclose(p1, p2) for p1, p2 in zip(converted[0], self.get_point(expected)))
zip(converted[0], self.get_point(expected)))
if '(' not in expected: if '(' not in expected:
return m[1] == 'LINESTRING' and \ return m[1] == 'LINESTRING' and \
all(math.isclose(p1[0], p2[0]) and math.isclose(p1[1], p2[1]) for p1, p2 in all(math.isclose(p1[0], p2[0]) and math.isclose(p1[1], p2[1]) for p1, p2 in
zip(converted, (self.get_point(p) for p in expected.split(',')))) zip(converted, (self.get_point(p) for p in expected.split(','))))
if m[1] != 'POLYGON': if m[1] != 'POLYGON':
return False return False

View File

@@ -18,6 +18,7 @@ from nominatim_db.tools.refresh import create_functions, load_address_levels_fro
from nominatim_db.tools.exec_utils import run_osm2pgsql from nominatim_db.tools.exec_utils import run_osm2pgsql
from nominatim_db.tokenizer import factory as tokenizer_factory from nominatim_db.tokenizer import factory as tokenizer_factory
class DBManager: class DBManager:
def __init__(self, purge=False): def __init__(self, purge=False):
@@ -98,4 +99,3 @@ class DBManager:
asyncio.run(create_search_indices(conn, config)) asyncio.run(create_search_indices(conn, config))
tokenizer_factory.create_tokenizer(config) tokenizer_factory.create_tokenizer(config)