From 1111597db5303a066441ceb4dd9046d135a9f552 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 29 Jul 2025 21:25:14 +0200 Subject: [PATCH] reduce precision of computed centroids to 7 digits --- lib-sql/functions/placex_triggers.sql | 2 +- lib-sql/functions/utils.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 170b8a3f..b13741d2 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -780,7 +780,7 @@ BEGIN SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO result; IF result THEN 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; {% endif %} -- not disable_diff_updates diff --git a/lib-sql/functions/utils.sql b/lib-sql/functions/utils.sql index 30f94080..250d38c1 100644 --- a/lib-sql/functions/utils.sql +++ b/lib-sql/functions/utils.sql @@ -2,7 +2,7 @@ -- -- 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. -- Assorted helper functions for the triggers. @@ -14,14 +14,14 @@ DECLARE geom_type TEXT; BEGIN geom_type := ST_GeometryType(place); - IF geom_type = ' ST_Point' THEN + IF geom_type = 'ST_Point' THEN RETURN place; END IF; IF geom_type = 'ST_LineString' THEN - RETURN ST_LineInterpolatePoint(place, 0.5); + RETURN ST_ReducePrecision(ST_LineInterpolatePoint(place, 0.5), 0.0000001); END IF; - RETURN ST_PointOnSurface(place); + RETURN ST_ReducePrecision(ST_PointOnSurface(place), 0.0000001); END; $$ LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE;