[postgis-users] Create LINESTRING with a LOOP
paallen at attglobal.net
paallen at attglobal.net
Sat Apr 21 04:23:46 PDT 2007
Hi all,
I am writing a function that returns a linestring
(4D). I am creating this linestring within a
loop. But it doesn't work because the first two
times through the linestring is null or empty.
What is the most efficent way to create a
linestring within a LOOP?
Below is a simplified example of what I am trying
to do.
thanks,
Phillip Allen
CREATE OR REPLACE FUNCTION mc_test2( )
RETURNS geometry AS
$BODY$
DECLARE
gline geometry;
gpt geometry;
x integer;
str text;
BEGIN
x := 1;
gline := LINESTRING(EMPTY);
WHILE (x <= 5) LOOP
str := $$SRID=32717;POINT($$ || 400000 + x ||
$$ $$ || 900000 + x || $$ $$ || 3500 + x || $$ $$
|| x || $$)$$;
gline := AddPoint(gline, GeomFromEWKT(str));
x := x+1;
END LOOP;
RETURN gline;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
More information about the postgis-users
mailing list