~qeef/damn-deploy

damn-deploy/damndb/76_square_from_already_divided.sql -rw-r--r-- 605 bytes
ae02ea94Jiri Vlasak Update mappy client, server 21 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
DROP FUNCTION IF EXISTS public.st_square_from_already_divided;
CREATE OR REPLACE FUNCTION public.st_square_from_already_divided(
    sq public.geometry,
    OUT square public.geometry) RETURNS public.geometry
    LANGUAGE plpgsql IMMUTABLE STRICT
    AS $$
DECLARE
    srid INTEGER := 4326;
BEGIN
    IF ST_SRID(sq) = 0 THEN
        sq := ST_SetSRID(sq, srid);
        RAISE NOTICE'SRID Not Found.';
    ELSE
        RAISE NOTICE'SRID Found.';
    END IF;

    CASE GeometryType(sq)
    WHEN 'LINESTRING' THEN
        square := ST_Buffer(sq, 0.0001);
    ELSE
        square := sq;
    END CASE;
END; $$;