From: Sarah Hoffmann Date: Tue, 28 Sep 2021 07:45:15 +0000 (+0200) Subject: Merge pull request #2454 from lonvia/sort-out-token-assignment-in-sql X-Git-Tag: v4.0.0~25 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/40f9d52ad8b48e0dc6b1ac89305c1e4ef1c43884?hp=09c9fad6c31733065492306c9ee3c052e50ac115 Merge pull request #2454 from lonvia/sort-out-token-assignment-in-sql ICU tokenizer: switch match method to using partial terms --- diff --git a/lib-sql/functions/place_triggers.sql b/lib-sql/functions/place_triggers.sql index 014c8cd7..ca16871a 100644 --- a/lib-sql/functions/place_triggers.sql +++ b/lib-sql/functions/place_triggers.sql @@ -247,6 +247,7 @@ BEGIN indexed_status = 2, geometry = NEW.geometry where place_id = existingplacex.place_id; + -- if a node(=>house), which is part of a interpolation line, changes (e.g. the street attribute) => mark this line for reparenting -- (already here, because interpolation lines are reindexed before nodes, so in the second call it would be too late) IF NEW.osm_type='N' @@ -270,6 +271,26 @@ BEGIN and x.class = p.class; END IF; + IF coalesce(existing.name::text, '') != coalesce(NEW.name::text, '') + THEN + IF existingplacex.rank_address between 26 and 27 THEN + -- When streets change their name, this may have an effect on POI objects + -- with addr:street tags. + UPDATE placex SET indexed_status = 2 + WHERE indexed_status = 0 and address ? 'street' + and parent_place_id = existingplacex.place_id; + UPDATE placex SET indexed_status = 2 + WHERE indexed_status = 0 and rank_search = 30 and address ? 'street' + and ST_DWithin(NEW.geometry, geometry, 0.002); + ELSEIF existingplacex.rank_address between 16 and 25 THEN + -- When places change their name, this may have an effect on POI objects + -- with addr:place tags. + UPDATE placex SET indexed_status = 2 + WHERE indexed_status = 0 and address ? 'place' and rank_search = 30 + and parent_place_id = existingplacex.place_id; + -- No update of surrounding objects, potentially too expensive. + END IF; + END IF; END IF; -- Abort the add (we modified the existing place instead) diff --git a/test/bdd/db/update/parenting.feature b/test/bdd/db/update/parenting.feature index 99199de4..c962fc7e 100644 --- a/test/bdd/db/update/parenting.feature +++ b/test/bdd/db/update/parenting.feature @@ -1,7 +1,7 @@ @DB Feature: Update parenting of objects -Scenario: POI inside building inherits addr:street change + Scenario: POI inside building inherits addr:street change Given the scene building-on-street-corner And the named places | osm | class | type | geometry | @@ -34,3 +34,132 @@ Scenario: POI inside building inherits addr:street change | N1 | W3 | 3 | | N2 | W3 | 3 | | N3 | W3 | 3 | + + + Scenario: Housenumber is reparented when street gets name matching addr:street + Given the grid + | 1 | | | 2 | + | | 10 | | | + | | | | | + | 3 | | | 4 | + And the places + | osm | class | type | name | geometry | + | W1 | highway | residential | A street | 1,2 | + | W2 | highway | residential | B street | 3,4 | + And the places + | osm | class | type | housenr | street | geometry | + | N1 | building | yes | 3 | X street | 10 | + When importing + Then placex contains + | object | parent_place_id | + | N1 | W1 | + When updating places + | osm | class | type | name | geometry | + | W2 | highway | residential | X street | 3,4 | + Then placex contains + | object | parent_place_id | + | N1 | W2 | + + + Scenario: Housenumber is reparented when street looses name matching addr:street + Given the grid + | 1 | | | 2 | + | | 10 | | | + | | | | | + | 3 | | | 4 | + And the places + | osm | class | type | name | geometry | + | W1 | highway | residential | A street | 1,2 | + | W2 | highway | residential | X street | 3,4 | + And the places + | osm | class | type | housenr | street | geometry | + | N1 | building | yes | 3 | X street | 10 | + When importing + Then placex contains + | object | parent_place_id | + | N1 | W2 | + When updating places + | osm | class | type | name | geometry | + | W2 | highway | residential | B street | 3,4 | + Then placex contains + | object | parent_place_id | + | N1 | W1 | + + + Scenario: Housenumber is reparented when street gets name matching addr:street + Given the grid + | 1 | | | 2 | + | | 10 | | | + | | | | | + | 3 | | | 4 | + And the places + | osm | class | type | name | geometry | + | W1 | highway | residential | A street | 1,2 | + | W2 | highway | residential | B street | 3,4 | + And the places + | osm | class | type | housenr | street | geometry | + | N1 | building | yes | 3 | X street | 10 | + When importing + Then placex contains + | object | parent_place_id | + | N1 | W1 | + When updating places + | osm | class | type | name | geometry | + | W2 | highway | residential | X street | 3,4 | + Then placex contains + | object | parent_place_id | + | N1 | W2 | + + + # Invalidation of geometries currently disabled for addr:place matches. + @Fail + Scenario: Housenumber is reparented when place is renamed to matching addr:place + Given the grid + | 1 | | | 2 | + | | 10 | 4 | | + | | | | | + | | | 5 | | + And the places + | osm | class | type | name | geometry | + | W1 | highway | residential | A street | 1,2 | + | N5 | place | village | Bdorf | 5 | + | N4 | place | village | Other | 4 | + And the places + | osm | class | type | housenr | addr_place | geometry | + | N1 | building | yes | 3 | Cdorf | 10 | + When importing + Then placex contains + | object | parent_place_id | + | N1 | N4 | + When updating places + | osm | class | type | name | geometry | + | N5 | place | village | Cdorf | 5 | + Then placex contains + | object | parent_place_id | + | N1 | N5 | + + + Scenario: Housenumber is reparented when it looses a matching addr:place + Given the grid + | 1 | | | 2 | + | | 10 | 4 | | + | | | | | + | | | 5 | | + And the places + | osm | class | type | name | geometry | + | W1 | highway | residential | A street | 1,2 | + | N5 | place | village | Bdorf | 5 | + | N4 | place | village | Other | 4 | + And the places + | osm | class | type | housenr | addr_place | geometry | + | N1 | building | yes | 3 | Bdorf | 10 | + When importing + Then placex contains + | object | parent_place_id | + | N1 | N5 | + When updating places + | osm | class | type | name | geometry | + | N5 | place | village | Cdorf | 5 | + Then placex contains + | object | parent_place_id | + | N1 | N4 |