[postgis-users] Trigger to update lines using new points
Broun Uganda
tekuganda at hotmail.com
Tue Jul 10 09:11:13 PDT 2007
Dear all,A trying to write a trigger that would automatically create lines joining points in the sequence in which i insert them.
If I insert point AA then BB then CC, i want lines drawn as AA-BB & BB-CC, Using the trigger below lines are drawn ( atleast i can see the gid in table links) without the geometry. May anyone advise me on this.
Thank you
CREATE OR REPLACE FUNCTION insert_new_links() RETURNS "trigger"
AS 'DECLAREstartpoint geometry;
endpoint geometry;
BEGIN
startpoint = asEWKT(NEW.the_geom) WHERE NEW.gid = NEW.gid;
endpoint = asEWKT(NEW.the_geom) WHERE NEW.gid = NEW.gid+1;
INSERT INTO links(the_geom)VALUES(MakeLine(startpoint, endpoint ));
RETURN NEW;
END' LANGUAGE plpgsql;
CREATE OR TRIGGER insert_new_links_insert
BEFORE INSERT ON nodes
FOR EACH ROW
EXECUTE PROCEDURE insert_new_links();Broun Uganda
_________________________________________________________________
Play free games, earn tickets, get cool prizes! Join Live Search Club.
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070710/639d2c66/attachment.html>
More information about the postgis-users
mailing list