reduce precision of computed centroids to 7 digits

This commit is contained in:
Sarah Hoffmann
2025-07-29 21:25:14 +02:00
parent 866e6bade9
commit 1111597db5
2 changed files with 5 additions and 5 deletions

View File

@@ -780,7 +780,7 @@ BEGIN
SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO result; SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO result;
IF result THEN IF result THEN
EXECUTE 'INSERT INTO ' || classtable::regclass || ' (place_id, centroid) VALUES ($1,$2)' EXECUTE 'INSERT INTO ' || classtable::regclass || ' (place_id, centroid) VALUES ($1,$2)'
USING NEW.place_id, ST_Centroid(NEW.geometry); USING NEW.place_id, NEW.centroid;
END IF; END IF;
{% endif %} -- not disable_diff_updates {% endif %} -- not disable_diff_updates

View File

@@ -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) 2025 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.
-- Assorted helper functions for the triggers. -- Assorted helper functions for the triggers.
@@ -14,14 +14,14 @@ DECLARE
geom_type TEXT; geom_type TEXT;
BEGIN BEGIN
geom_type := ST_GeometryType(place); geom_type := ST_GeometryType(place);
IF geom_type = ' ST_Point' THEN IF geom_type = 'ST_Point' THEN
RETURN place; RETURN place;
END IF; END IF;
IF geom_type = 'ST_LineString' THEN IF geom_type = 'ST_LineString' THEN
RETURN ST_LineInterpolatePoint(place, 0.5); RETURN ST_ReducePrecision(ST_LineInterpolatePoint(place, 0.5), 0.0000001);
END IF; END IF;
RETURN ST_PointOnSurface(place); RETURN ST_ReducePrecision(ST_PointOnSurface(place), 0.0000001);
END; END;
$$ $$
LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE; LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE;