X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/405482ede41e22764d531f67ea409c2c7f71e2ef..c611d49941e8a097116dfb6f6d08e5491a85dcee:/sql/functions/placex_triggers.sql?ds=sidebyside diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index 0fd0c3bc..c04aef28 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -220,6 +220,21 @@ BEGIN END LOOP; END IF; + IF bnd.extratags ? 'wikidata' THEN + FOR linked_placex IN + SELECT * FROM placex + 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.rank_search < 26 + AND _st_covers(bnd.geometry, placex.geometry) + ORDER BY make_standard_name(name->'name') = bnd_name desc + LOOP + --DEBUG: RAISE WARNING 'Found wikidata-matching place node %', linked_placex.osm_id; + RETURN linked_placex; + END LOOP; + END IF; + -- Name searches can be done for ways as well as relations IF bnd_name is not null THEN --DEBUG: RAISE WARNING 'Looking for nodes with matching names'; @@ -700,7 +715,9 @@ BEGIN and ( relation_members[i+1] != 'side_stream' or NEW.name->'name' = name->'name') LOOP UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = linked_node_id; - DELETE FROM search_name WHERE place_id = linked_node_id; + IF NOT %REVERSE-ONLY% THEN + DELETE FROM search_name WHERE place_id = linked_node_id; + END IF; END LOOP; END IF; END LOOP; @@ -843,7 +860,9 @@ BEGIN UPDATE placex set linked_place_id = NEW.place_id WHERE place_id = location.place_id; -- ensure that those places are not found anymore - DELETE FROM search_name WHERE place_id = location.place_id; + IF NOT %REVERSE-ONLY% THEN + DELETE FROM search_name WHERE place_id = location.place_id; + END IF; SELECT wikipedia, importance FROM compute_importance(location.extratags, NEW.country_code,