mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
when linking places compute maximum importance
The linker and the linkee might have different wikipedia tags and thus different importances. Prefer the higher value. Fixes #562.
This commit is contained in:
@@ -1140,6 +1140,8 @@ DECLARE
|
||||
nameaddress_vector INTEGER[];
|
||||
|
||||
linked_node_id BIGINT;
|
||||
linked_importance FLOAT;
|
||||
linked_wikipedia TEXT;
|
||||
|
||||
result BOOLEAN;
|
||||
BEGIN
|
||||
@@ -1511,6 +1513,7 @@ BEGIN
|
||||
|
||||
-- keep a note of the node id in case we need it for wikipedia in a bit
|
||||
linked_node_id := linkedPlacex.osm_id;
|
||||
select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
|
||||
END LOOP;
|
||||
|
||||
END LOOP;
|
||||
@@ -1546,6 +1549,7 @@ BEGIN
|
||||
|
||||
-- keep a note of the node id in case we need it for wikipedia in a bit
|
||||
linked_node_id := linkedPlacex.osm_id;
|
||||
select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
|
||||
END IF;
|
||||
|
||||
END LOOP;
|
||||
@@ -1588,6 +1592,7 @@ BEGIN
|
||||
|
||||
-- keep a note of the node id in case we need it for wikipedia in a bit
|
||||
linked_node_id := linkedPlacex.osm_id;
|
||||
select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
|
||||
END LOOP;
|
||||
END IF;
|
||||
|
||||
@@ -1608,10 +1613,12 @@ BEGIN
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Did we gain a wikipedia tag in the process? then we need to recalculate our importance
|
||||
IF NEW.importance is null THEN
|
||||
select language||':'||title,importance from get_wikipedia_match(NEW.extratags, NEW.country_code) INTO NEW.wikipedia,NEW.importance;
|
||||
-- Use the maximum importance if a one could be computed from the linked object.
|
||||
IF linked_importance is not null AND
|
||||
(NEW.importance is null or NEW.importance < linked_importance) THEN
|
||||
NEW.importance = linked_importance;
|
||||
END IF;
|
||||
|
||||
-- Still null? how about looking it up by the node id
|
||||
IF NEW.importance IS NULL THEN
|
||||
select language||':'||title,importance from wikipedia_article where osm_type = 'N'::char(1) and osm_id = linked_node_id order by importance desc limit 1 INTO NEW.wikipedia,NEW.importance;
|
||||
|
||||
Reference in New Issue
Block a user