]> git.openstreetmap.org Git - nominatim.git/commitdiff
use computed centroid for location_area_large
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 15 Oct 2020 15:30:52 +0000 (17:30 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 15 Oct 2020 15:30:52 +0000 (17:30 +0200)
The new address computation assumes that the centroid is inside
the area. Therefore we cannot use the centroid function. Use the
pre-computed centroid instead which has already been corrected to
be inside the area.

sql/functions/placex_triggers.sql
sql/functions/utils.sql

index 27fa3643b0b9ce2f61f76a9b7c984f576830e03c..a888fee869991753786ff191a4961f4334f9a67d 100644 (file)
@@ -801,7 +801,8 @@ BEGIN
           IF NEW.rank_search <= 25 and NEW.rank_address > 0 THEN
             result := add_location(NEW.place_id, NEW.country_code, NEW.partition,
                                    name_vector, NEW.rank_search, NEW.rank_address,
-                                   upper(trim(NEW.address->'postcode')), NEW.geometry);
+                                   upper(trim(NEW.address->'postcode')), NEW.geometry,
+                                   NEW.centroid);
             --DEBUG: RAISE WARNING 'Place added to location table';
           END IF;
 
@@ -932,7 +933,7 @@ BEGIN
   IF NEW.name IS NOT NULL THEN
 
     IF NEW.rank_search <= 25 and NEW.rank_address > 0 THEN
-      result := add_location(NEW.place_id, NEW.country_code, NEW.partition, name_vector, NEW.rank_search, NEW.rank_address, upper(trim(NEW.address->'postcode')), NEW.geometry);
+      result := add_location(NEW.place_id, NEW.country_code, NEW.partition, name_vector, NEW.rank_search, NEW.rank_address, upper(trim(NEW.address->'postcode')), NEW.geometry, NEW.centroid);
       --DEBUG: RAISE WARNING 'added to location (full)';
     END IF;
 
index 08e82c5be671d4e8b37b89424d30b77fdc491d98..0a49eef52fc16ee1068642e73ac337880e2d1ed1 100644 (file)
@@ -301,12 +301,12 @@ LANGUAGE plpgsql IMMUTABLE;
 CREATE OR REPLACE FUNCTION add_location(place_id BIGINT, country_code varchar(2),
                                         partition INTEGER, keywords INTEGER[],
                                         rank_search INTEGER, rank_address INTEGER,
-                                        in_postcode TEXT, geometry GEOMETRY)
+                                        in_postcode TEXT, geometry GEOMETRY,
+                                        centroid GEOMETRY)
   RETURNS BOOLEAN
   AS $$
 DECLARE
   locationid INTEGER;
-  centroid GEOMETRY;
   secgeo GEOMETRY;
   postcode TEXT;
 BEGIN
@@ -319,15 +319,13 @@ BEGIN
   END IF;
 
   IF ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') THEN
-    centroid := ST_Centroid(geometry);
-
     FOR secgeo IN select split_geometry(geometry) AS geom LOOP
       PERFORM insertLocationAreaLarge(partition, place_id, country_code, keywords, rank_search, rank_address, false, postcode, centroid, secgeo);
     END LOOP;
 
   ELSEIF ST_GeometryType(geometry) = 'ST_Point' THEN
     secgeo := place_node_fuzzy_area(geometry, rank_search);
-    PERFORM insertLocationAreaLarge(partition, place_id, country_code, keywords, rank_search, rank_address, true, postcode, geometry, secgeo);
+    PERFORM insertLocationAreaLarge(partition, place_id, country_code, keywords, rank_search, rank_address, true, postcode, centroid, secgeo);
 
   END IF;