forked from hans/Nominatim
make sure that importance is always set to a non-null value
Secondary importance might return invalid values in some cases.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
-- This file is part of Nominatim. (https://nominatim.org)
|
-- This file is part of Nominatim. (https://nominatim.org)
|
||||||
--
|
--
|
||||||
-- Copyright (C) 2022 by the Nominatim developer community.
|
-- Copyright (C) 2026 by the Nominatim developer community.
|
||||||
-- For a full list of authors see the git log.
|
-- For a full list of authors see the git log.
|
||||||
|
|
||||||
-- Functions for interpreting wkipedia/wikidata tags and computing importance.
|
-- Functions for interpreting wkipedia/wikidata tags and computing importance.
|
||||||
@@ -166,7 +166,7 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
-- Nothing? Then try with the wikidata tag.
|
-- Nothing? Then try with the wikidata tag.
|
||||||
IF result.importance is null AND extratags ? 'wikidata' THEN
|
IF extratags ? 'wikidata' THEN
|
||||||
FOR match IN
|
FOR match IN
|
||||||
{% if 'wikimedia_importance' in db.tables %}
|
{% if 'wikimedia_importance' in db.tables %}
|
||||||
SELECT * FROM wikimedia_importance
|
SELECT * FROM wikimedia_importance
|
||||||
@@ -185,18 +185,18 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Still nothing? Fall back to a default.
|
-- Still nothing? Fall back to a default.
|
||||||
IF result.importance is null THEN
|
result.importance := 0.40001 - (rank_search::float / 75);
|
||||||
result.importance := 0.40001 - (rank_search::float / 75);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
{% if 'secondary_importance' in db.tables %}
|
{% if 'secondary_importance' in db.tables %}
|
||||||
FOR match IN
|
FOR match IN
|
||||||
SELECT ST_Value(rast, centroid) as importance
|
SELECT ST_Value(rast, centroid) as importance
|
||||||
FROM secondary_importance
|
FROM secondary_importance
|
||||||
WHERE ST_Intersects(ST_ConvexHull(rast), centroid) LIMIT 1
|
WHERE ST_Intersects(ST_ConvexHull(rast), centroid) LIMIT 1
|
||||||
LOOP
|
LOOP
|
||||||
-- Secondary importance as tie breaker with 0.0001 weight.
|
IF match.importance is not NULL THEN
|
||||||
result.importance := result.importance + match.importance::float / 655350000;
|
-- Secondary importance as tie breaker with 0.0001 weight.
|
||||||
|
result.importance := result.importance + match.importance::float / 655350000;
|
||||||
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -1196,7 +1196,7 @@ BEGIN
|
|||||||
IF linked_importance is not null AND
|
IF linked_importance is not null AND
|
||||||
(NEW.importance is null or NEW.importance < linked_importance)
|
(NEW.importance is null or NEW.importance < linked_importance)
|
||||||
THEN
|
THEN
|
||||||
NEW.importance = linked_importance;
|
NEW.importance := linked_importance;
|
||||||
END IF;
|
END IF;
|
||||||
ELSE
|
ELSE
|
||||||
-- No linked place? As a last resort check if the boundary is tagged with
|
-- No linked place? As a last resort check if the boundary is tagged with
|
||||||
|
|||||||
Reference in New Issue
Block a user