X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b9e4563bebaf2b2bfba5440001b4b5750eaebe43..ad50016c498098d0f0850c3a9de60623a3bd7e1f:/lib-sql/functions/utils.sql?ds=inline 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 $$