From: Sarah Hoffmann Date: Sun, 9 Feb 2020 21:26:53 +0000 (+0100) Subject: move linked place type into linked_place extratags X-Git-Tag: v3.5.0~70^2~5 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/00ca493f33e9f2fd3b0be79cbbb3e814a5891a07 move linked place type into linked_place extratags Using linked_place means that we don't overwrite any place tags on the boundary. This is important when we wanto to use the information for linking. --- diff --git a/sql/functions/address_lookup.sql b/sql/functions/address_lookup.sql index b1b4c4da..8436fdb1 100644 --- a/sql/functions/address_lookup.sql +++ b/sql/functions/address_lookup.sql @@ -202,8 +202,9 @@ BEGIN FOR location IN SELECT placex.place_id, osm_type, osm_id, name, - CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class, - CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type, + CASE WHEN extratags ? 'place' or extratags ? 'linked_place' + THEN 'place' ELSE class END as class, + coalesce(extratags->'place', extratags->'linked_place', type) as type, admin_level, fromarea, isaddress, CASE WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address, distance, country_code, postcode diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index ffc83fa3..f301f424 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -818,7 +818,7 @@ BEGIN --DEBUG: RAISE WARNING 'Using full index mode for % %', NEW.osm_type, NEW.osm_id; SELECT * INTO location FROM find_linked_place(NEW); IF location.place_id is not null THEN - --DEBUG: RAISE WARNING 'Linked %', location; + --DEBUG: RAISE WARNING 'Linked %', location; -- Use this as the centre point of the geometry NEW.centroid := coalesce(location.centroid, @@ -830,7 +830,7 @@ BEGIN END IF; -- merge in extra tags - NEW.extratags := hstore(location.class, location.type) + NEW.extratags := hstore('linked_' || location.class, location.type) || coalesce(location.extratags, ''::hstore) || coalesce(NEW.extratags, ''::hstore); diff --git a/test/bdd/db/import/linking.feature b/test/bdd/db/import/linking.feature index ceb45586..c6381792 100644 --- a/test/bdd/db/import/linking.feature +++ b/test/bdd/db/import/linking.feature @@ -127,3 +127,19 @@ Feature: Linking of places | N3:natural | - | | N3:place | R1 | + Scenario: Nodes with 'role' label are always linked + Given the places + | osm | class | type | admin | name | geometry | + | R13 | boundary | administrative | 6 | Garbo | poly-area:0.1 | + | N2 | place | hamlet | 15 | Vario | 0.006 0.00001 | + And the relations + | id | members | tags+type | + | 13 | N2:label | boundary | + When importing + Then placex contains + | object | linked_place_id | + | N2 | R13 | + And placex contains + | object | centroid | name+name | extratags+linked_place | + | R13 | 0.006 0.00001 | Garbo | hamlet | + diff --git a/test/bdd/db/update/linked_places.feature b/test/bdd/db/update/linked_places.feature index 6c31bd89..647d5eaf 100644 --- a/test/bdd/db/update/linked_places.feature +++ b/test/bdd/db/update/linked_places.feature @@ -125,11 +125,11 @@ Feature: Updates of linked places When importing Then placex contains | object | extratags | - | R1 | 'wikidata' : '34', 'place' : 'city' | + | R1 | 'wikidata' : '34', 'linked_place' : 'city' | When updating places | osm | class | type | name | extra+oneway | admin | geometry | | N3 | place | city | newname | yes | 30 | 0.00001 0 | Then placex contains | object | extratags | - | R1 | 'wikidata' : '34', 'oneway' : 'yes', 'place' : 'city' | + | R1 | 'wikidata' : '34', 'oneway' : 'yes', 'linked_place' : 'city' |