[postgis-users] Using Trigger function to manipulate coordinates

Frank Koormann frank.koormann at intevation.de
Thu Jun 21 03:11:14 PDT 2007


* Broun Uganda <tekuganda at hotmail.com> [070621 11:56]:
>    I wrote the following filter for taking coordinates from the_geom to my
>    point_x & point_y columns but it is giving errors. Could anybody be of
>    help?
>    The Trigger is thus:
>    CREATE FUNCTION calc_point() RETURNS "trigger"
>        AS 'BEGIN
>    NEW.point_x = NEW.the_geom[0];
>    NEW.point_y = NEW.the_geom[1];

This should be something like 

    NEW.point_x = ST_X(NEW.the_geom);
    NEW.point_y = ST_Y(NEW.the_geom);

or on older PostGIS installations 

    NEW.point_x = X(NEW.the_geom);
    NEW.point_y = Y(NEW.the_geom);

HTH,

        Frank

-- 
Frank Koormann  |  ++49-541-335 08 30  |  http://www.intevation.de/
Intevation GmbH, Osnabrück, DE   |   Amtsgericht Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner



More information about the postgis-users mailing list