+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;
+
+