mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
rewrite address interpolation so that planet_osm_node is not needed
This allows address interpolations to work correctly when flatnode storage
is used for node coordinates.
To fix interpolations in an existing database, follow these steps:
* invalidate all interpolations (in psql):
`UPDATE placex SET indexed_status=2 WHERE rank_search = 28`
* disable updates:
./utils/setup.php --create-functions --create-partition-functions
* reindex the whole lot:
./utils/update.php --index --index-instances <number of your cpus>
* enable updates again:
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
This commit is contained in:
329
tests/features/db/import/interpolation.feature
Normal file
329
tests/features/db/import/interpolation.feature
Normal file
@@ -0,0 +1,329 @@
|
||||
@DB
|
||||
Feature: Import of address interpolations
|
||||
Tests that interpolated addresses are added correctly
|
||||
|
||||
Scenario: Simple even two point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 6 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
| 4 | 1,1.0005
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 6 | 1,1.001
|
||||
|
||||
Scenario: Simple even two point interpolation with zero beginning
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 0 | 1 1
|
||||
| 2 | place | house | 8 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 0 | 1,1
|
||||
| 2 | 1,1.00025
|
||||
| 4 | 1,1.0005
|
||||
| 6 | 1,1.00075
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 8 | 1,1.001
|
||||
|
||||
Scenario: Backwards even two point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 6 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1.001, 1 1
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 2,1
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 4 | 1,1.0005
|
||||
| 6 | 1,1.001
|
||||
|
||||
Scenario: Even two point interpolation with odd beginning
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 11 | 1 1
|
||||
| 2 | place | house | 16 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 11 | 1,1
|
||||
| 12 | 1,1.0002
|
||||
| 14 | 1,1.0006
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 16 | 1,1.001
|
||||
|
||||
Scenario: Even two point interpolation with odd end
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 10 | 1 1
|
||||
| 2 | place | house | 15 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 10 | 1,1
|
||||
| 12 | 1,1.0004
|
||||
| 14 | 1,1.0008
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 15 | 1,1.001
|
||||
|
||||
Scenario: Reverse even two point interpolation with odd beginning
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 11 | 1 1
|
||||
| 2 | place | house | 16 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1.001, 1 1
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 2,1
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 11 | 1,1
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 12 | 1,1.0002
|
||||
| 14 | 1,1.0006
|
||||
| 16 | 1,1.001
|
||||
|
||||
Scenario: Reverse even two point interpolation with odd end
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 10 | 1 1
|
||||
| 2 | place | house | 15 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1.001, 1 1
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 2,1
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 10 | 1,1
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 12 | 1,1.0004
|
||||
| 14 | 1,1.0008
|
||||
| 15 | 1,1.001
|
||||
|
||||
Scenario: Simple odd two point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 1 | 1 1
|
||||
| 2 | place | house | 11 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | odd | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 1 | 1,1
|
||||
| 3 | 1,1.0002
|
||||
| 5 | 1,1.0004
|
||||
| 7 | 1,1.0006
|
||||
| 9 | 1,1.0008
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 11 | 1,1.001
|
||||
|
||||
Scenario: Odd two point interpolation with even beginning
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 7 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | odd | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
| 3 | 1,1.0002
|
||||
| 5 | 1,1.0006
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 7 | 1,1.001
|
||||
|
||||
Scenario: Simple all two point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 1 | 1 1
|
||||
| 2 | place | house | 3 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | all | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 1 | 1,1
|
||||
| 2 | 1,1.0005
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 3 | 1,1.001
|
||||
|
||||
Scenario: Simple numbered two point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 3 | 1 1
|
||||
| 2 | place | house | 9 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | 3 | 1 1, 1 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 3 | 1,1
|
||||
| 6 | 1,1.0005
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 9 | 1,1.001
|
||||
|
||||
Scenario: Even two point interpolation with intermediate empty node
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 10 | 1.001 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001, 1.001 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,3,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
| 4 | 1,1.0005
|
||||
| 6 | 1,1.001
|
||||
| 8 | 1.0005,1.001
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 10 | 1.001,1.001
|
||||
|
||||
|
||||
Scenario: Even two point interpolation with intermediate duplicated empty node
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 10 | 1.001 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001, 1.001 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,3,3,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
| 4 | 1,1.0005
|
||||
| 6 | 1,1.001
|
||||
| 8 | 1.0005,1.001
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 10 | 1.001,1.001
|
||||
|
||||
Scenario: Simple even three point interpolation
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 8 | 1.001 1.001
|
||||
| 3 | place | house | 4 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001, 1.001 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,3,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
Then node 3 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 4 | 1,1.001
|
||||
| 6 | 1.0005,1.001
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 8 | 1.001,1.001
|
||||
|
||||
Scenario: Even three point interpolation with odd center point
|
||||
Given the place nodes
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | house | 2 | 1 1
|
||||
| 2 | place | house | 8 | 1.001 1.001
|
||||
| 3 | place | house | 7 | 1 1.001
|
||||
And the place ways
|
||||
| osm_id | class | type | housenumber | geometry
|
||||
| 1 | place | houses | even | 1 1, 1 1.001, 1.001 1.001
|
||||
And the ways
|
||||
| id | nodes
|
||||
| 1 | 1,3,2
|
||||
When importing
|
||||
Then node 1 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 2 | 1,1
|
||||
| 4 | 1,1.0004
|
||||
| 6 | 1,1.0008
|
||||
Then node 3 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 7 | 1,1.001
|
||||
And node 2 expands to housenumbers
|
||||
| housenumber | centroid
|
||||
| 8 | 1.001,1.001
|
||||
|
||||
|
||||
@@ -110,6 +110,27 @@ def check_search_name_content(step):
|
||||
else:
|
||||
raise Exception("Cannot handle field %s in search_name table" % (k, ))
|
||||
|
||||
@step(u'node (\d+) expands to housenumbers')
|
||||
def check_interpolated_housenumbers(step, nodeid):
|
||||
"""Check that the exact set of housenumbers has been entered in
|
||||
placex for the given source node. Expected are tow columns:
|
||||
housenumber and centroid
|
||||
"""
|
||||
numbers = {}
|
||||
for line in step.hashes:
|
||||
assert line["housenumber"] not in numbers
|
||||
numbers[line["housenumber"]] = line["centroid"]
|
||||
cur = world.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||
cur.execute("""SELECT DISTINCT housenumber,
|
||||
ST_X(centroid) as clat, ST_Y(centroid) as clon
|
||||
FROM placex WHERE osm_type = 'N' and osm_id = %s""",
|
||||
(int(nodeid),))
|
||||
assert_equals(len(numbers), cur.rowcount)
|
||||
for r in cur:
|
||||
assert_in(r["housenumber"], numbers)
|
||||
world.match_geometry((r['clat'], r['clon']), numbers[r["housenumber"]])
|
||||
del numbers[r["housenumber"]]
|
||||
|
||||
|
||||
@step(u'table search_name has no entry for (.*)')
|
||||
def check_placex_missing(step, osmid):
|
||||
|
||||
Reference in New Issue
Block a user