mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-18 10:32:08 +03:00
Merge pull request #2722 from lonvia/fix-relinking-on-updates
Fix bug with keeping linking on updates
This commit is contained in:
commit
6ca6725f6e
@ -278,7 +278,7 @@ BEGIN
|
||||
OR position(bnd_name in lower(name->'name')) > 0)
|
||||
AND placex.class = 'place' AND placex.type = bnd.extratags->'place'
|
||||
AND placex.osm_type = 'N'
|
||||
AND placex.linked_place_id is null
|
||||
AND (placex.linked_place_id is null or placex.linked_place_id = bnd.place_id)
|
||||
AND placex.rank_search < 26 -- needed to select the right index
|
||||
AND placex.type != 'postcode'
|
||||
AND ST_Covers(bnd.geometry, placex.geometry)
|
||||
@ -294,7 +294,7 @@ BEGIN
|
||||
WHERE placex.class = 'place' AND placex.osm_type = 'N'
|
||||
AND placex.extratags ? 'wikidata' -- needed to select right index
|
||||
AND placex.extratags->'wikidata' = bnd.extratags->'wikidata'
|
||||
AND placex.linked_place_id is null
|
||||
AND (placex.linked_place_id is null or placex.linked_place_id = bnd.place_id)
|
||||
AND placex.rank_search < 26
|
||||
AND _st_covers(bnd.geometry, placex.geometry)
|
||||
ORDER BY lower(name->'name') = bnd_name desc
|
||||
@ -318,7 +318,7 @@ BEGIN
|
||||
OR (bnd.rank_address = 0 and placex.rank_search = bnd.rank_search))
|
||||
AND placex.osm_type = 'N'
|
||||
AND placex.class = 'place'
|
||||
AND placex.linked_place_id is null
|
||||
AND (placex.linked_place_id is null or placex.linked_place_id = bnd.place_id)
|
||||
AND placex.rank_search < 26 -- needed to select the right index
|
||||
AND placex.type != 'postcode'
|
||||
AND ST_Covers(bnd.geometry, placex.geometry)
|
||||
@ -759,9 +759,6 @@ BEGIN
|
||||
DELETE FROM place_addressline WHERE place_id = NEW.place_id;
|
||||
result := deleteRoad(NEW.partition, NEW.place_id);
|
||||
result := deleteLocationArea(NEW.partition, NEW.place_id, NEW.rank_search);
|
||||
UPDATE placex set linked_place_id = null, indexed_status = 2
|
||||
where linked_place_id = NEW.place_id;
|
||||
-- update not necessary for osmline, cause linked_place_id does not exist
|
||||
|
||||
NEW.extratags := NEW.extratags - 'linked_place'::TEXT;
|
||||
|
||||
@ -770,6 +767,12 @@ BEGIN
|
||||
linked_place := NEW.linked_place_id;
|
||||
NEW.linked_place_id := OLD.linked_place_id;
|
||||
|
||||
-- Remove linkage, if we have computed a different new linkee.
|
||||
UPDATE placex SET linked_place_id = null, indexed_status = 2
|
||||
WHERE linked_place_id = NEW.place_id
|
||||
and (linked_place is null or linked_place_id != linked_place);
|
||||
-- update not necessary for osmline, cause linked_place_id does not exist
|
||||
|
||||
IF NEW.linked_place_id is not null THEN
|
||||
NEW.token_info := null;
|
||||
{% if debug %}RAISE WARNING 'place already linked to %', OLD.linked_place_id;{% endif %}
|
||||
|
@ -2,6 +2,25 @@
|
||||
Feature: Updates of linked places
|
||||
Tests that linked places are correctly added and deleted.
|
||||
|
||||
Scenario: Linking is kept when boundary is updated
|
||||
Given the places
|
||||
| osm | class | type | name | geometry |
|
||||
| N1 | place | city | foo | 0 0 |
|
||||
And the places
|
||||
| osm | class | type | name | admin | geometry |
|
||||
| R1 | boundary | administrative | foo | 8 | poly-area:0.1 |
|
||||
When importing
|
||||
Then placex contains
|
||||
| object | linked_place_id |
|
||||
| N1 | R1 |
|
||||
When updating places
|
||||
| osm | class | type | name | name+name:de | admin | geometry |
|
||||
| R1 | boundary | administrative | foo | Dingens | 8 | poly-area:0.1 |
|
||||
Then placex contains
|
||||
| object | linked_place_id |
|
||||
| N1 | R1 |
|
||||
|
||||
|
||||
Scenario: Add linked place when linking relation is renamed
|
||||
Given the places
|
||||
| osm | class | type | name | geometry |
|
||||
|
Loading…
Reference in New Issue
Block a user