change distance computation between place and address part

Instead of computing the distance to the centroid of the area
compute the distance of the area to the centroid of the feature.
This means we give preference to the area that covers the centroid.
It's still a heuristics but one that is a bit less random.
This commit is contained in:
Sarah Hoffmann
2022-04-21 21:56:59 +02:00
parent 403e6f7e5c
commit 784dad866f
3 changed files with 10 additions and 5 deletions

View File

@@ -449,6 +449,7 @@ CREATE OR REPLACE FUNCTION insert_addresslines(obj_place_id BIGINT,
maxrank SMALLINT,
token_info JSONB,
geometry GEOMETRY,
centroid GEOMETRY,
country TEXT,
OUT parent_place_id BIGINT,
OUT postcode TEXT,
@@ -511,7 +512,7 @@ BEGIN
END LOOP;
FOR location IN
SELECT * FROM getNearFeatures(partition, geometry, maxrank)
SELECT * FROM getNearFeatures(partition, geometry, centroid, maxrank)
WHERE not addr_place_ids @> ARRAY[place_id]
ORDER BY rank_address, isguess asc,
distance *
@@ -1106,7 +1107,8 @@ BEGIN
END IF;
SELECT * FROM insert_addresslines(NEW.place_id, NEW.partition, max_rank,
NEW.token_info, geom, NEW.country_code)
NEW.token_info, geom, NEW.centroid,
NEW.country_code)
INTO NEW.parent_place_id, NEW.postcode, nameaddress_vector;
{% if debug %}RAISE WARNING 'RETURN insert_addresslines: %, %, %', NEW.parent_place_id, NEW.postcode, nameaddress_vector;{% endif %}