forked from hans/Nominatim
adapt BDD tests for new address ranks
This commit is contained in:
@@ -530,6 +530,7 @@ CREATE OR REPLACE FUNCTION insert_addresslines(obj_place_id BIGINT,
|
|||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
address_havelevel BOOLEAN[];
|
address_havelevel BOOLEAN[];
|
||||||
|
place_min_distance FLOAT[];
|
||||||
|
|
||||||
location_isaddress BOOLEAN;
|
location_isaddress BOOLEAN;
|
||||||
current_boundary GEOMETRY := NULL;
|
current_boundary GEOMETRY := NULL;
|
||||||
@@ -545,6 +546,7 @@ BEGIN
|
|||||||
nameaddress_vector := '{}'::int[];
|
nameaddress_vector := '{}'::int[];
|
||||||
|
|
||||||
address_havelevel := array_fill(false, ARRAY[maxrank]);
|
address_havelevel := array_fill(false, ARRAY[maxrank]);
|
||||||
|
place_min_distance := array_fill(1.0, ARRAY[maxrank]);
|
||||||
|
|
||||||
FOR location IN
|
FOR location IN
|
||||||
SELECT apl.*, key
|
SELECT apl.*, key
|
||||||
@@ -575,6 +577,10 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF location.isguess and location.distance < place_min_distance[location.rank_address] THEN
|
||||||
|
place_min_distance[location.rank_address] := location.distance;
|
||||||
|
END IF;
|
||||||
|
|
||||||
INSERT INTO place_addressline (place_id, address_place_id, fromarea,
|
INSERT INTO place_addressline (place_id, address_place_id, fromarea,
|
||||||
isaddress, distance, cached_rank_address)
|
isaddress, distance, cached_rank_address)
|
||||||
VALUES (obj_place_id, location.place_id, not location.isguess,
|
VALUES (obj_place_id, location.place_id, not location.isguess,
|
||||||
@@ -602,6 +608,16 @@ BEGIN
|
|||||||
-- If this is the first item in the rank, then assume it is the address.
|
-- If this is the first item in the rank, then assume it is the address.
|
||||||
location_isaddress := not address_havelevel[location.rank_address];
|
location_isaddress := not address_havelevel[location.rank_address];
|
||||||
|
|
||||||
|
-- Ignore guessed places when they are too far away compared to similar closer ones.
|
||||||
|
IF location.isguess THEN
|
||||||
|
CONTINUE WHEN not location_isaddress
|
||||||
|
AND location.distance > 2 * place_min_distance[location.rank_address];
|
||||||
|
|
||||||
|
IF location.distance < place_min_distance[location.rank_address] THEN
|
||||||
|
place_min_distance[location.rank_address] := location.distance;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Further sanity checks to ensure that the address forms a sane hierarchy.
|
-- Further sanity checks to ensure that the address forms a sane hierarchy.
|
||||||
IF location_isaddress THEN
|
IF location_isaddress THEN
|
||||||
IF location.isguess and current_node_area is not NULL THEN
|
IF location.isguess and current_node_area is not NULL THEN
|
||||||
|
|||||||
@@ -135,9 +135,9 @@ Feature: Import into placex
|
|||||||
| object | rank_search | rank_address |
|
| object | rank_search | rank_address |
|
||||||
| N2 | 30 | 30 |
|
| N2 | 30 | 30 |
|
||||||
| W2 | 30 | 30 |
|
| W2 | 30 | 30 |
|
||||||
| W4 | 22 | 22 |
|
| W4 | 24 | 24 |
|
||||||
| R2 | 22 | 22 |
|
| R2 | 24 | 24 |
|
||||||
| R3 | 22 | 0 |
|
| R3 | 24 | 0 |
|
||||||
|
|
||||||
Scenario: rank and inclusion of naturals
|
Scenario: rank and inclusion of naturals
|
||||||
Given the 0.4 grid
|
Given the 0.4 grid
|
||||||
|
|||||||
@@ -114,10 +114,10 @@ Feature: Rank assignment
|
|||||||
|
|
||||||
Scenario: Admin levels must not be larger than 25
|
Scenario: Admin levels must not be larger than 25
|
||||||
Given the named places
|
Given the named places
|
||||||
| osm | class | type | admin | extra+place | geometry |
|
| osm | class | type | admin | extra+place | geometry |
|
||||||
| R20 | boundary | administrative | 6 | neighbourhood | (0 0, 0 2, 2 2, 2 0, 0 0) |
|
| R20 | boundary | administrative | 6 | quarter | (0 0, 0 2, 2 2, 2 0, 0 0) |
|
||||||
| R21 | boundary | administrative | 7 | | (0 0, 0 1, 1 1, 1 0, 0 0) |
|
| R21 | boundary | administrative | 7 | | (0 0, 0 1, 1 1, 1 0, 0 0) |
|
||||||
| R22 | boundary | administrative | 8 | | (0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0) |
|
| R22 | boundary | administrative | 8 | | (0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0) |
|
||||||
When importing
|
When importing
|
||||||
Then placex contains
|
Then placex contains
|
||||||
| object | rank_search | rank_address |
|
| object | rank_search | rank_address |
|
||||||
|
|||||||
Reference in New Issue
Block a user