X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/fdb3fc2f7b3620d9c80c9b70a37907aa850610e6..ad50016c498098d0f0850c3a9de60623a3bd7e1f:/lib-sql/functions/utils.sql

diff --git a/lib-sql/functions/utils.sql b/lib-sql/functions/utils.sql
index 50116566..d15ebe43 100644
--- a/lib-sql/functions/utils.sql
+++ b/lib-sql/functions/utils.sql
@@ -7,6 +7,26 @@
 
 -- Assorted helper functions for the triggers.
 
+CREATE OR REPLACE FUNCTION get_center_point(place GEOMETRY)
+  RETURNS GEOMETRY
+  AS $$
+DECLARE
+  geom_type TEXT;
+BEGIN
+  geom_type := ST_GeometryType(place);
+  IF geom_type = ' ST_Point' THEN
+    RETURN place;
+  END IF;
+  IF geom_type = 'ST_LineString' THEN
+    RETURN ST_LineInterpolatePoint(place, 0.5);
+  END IF;
+
+  RETURN ST_PointOnSurface(place);
+END;
+$$
+LANGUAGE plpgsql IMMUTABLE;
+
+
 CREATE OR REPLACE FUNCTION geometry_sector(partition INTEGER, place geometry)
   RETURNS INTEGER
   AS $$
@@ -21,6 +41,7 @@ $$
 LANGUAGE plpgsql IMMUTABLE;
 
 
+
 CREATE OR REPLACE FUNCTION array_merge(a INTEGER[], b INTEGER[])
   RETURNS INTEGER[]
   AS $$
