I am wondering if it is at all possible to create trigger that populates the X and Y of a created point into 2 separate fields called 'easting' and 'northing'?
It is an update trigger on a table which contains point geometries.
It has fields called 'easting' and 'northing'. These fields need to converted from integer to double precision due to this error code on saving of the table.
PostGIS error while adding features: ERROR: invalid input syntax for integer: "387733.568253859" CONTEXT: PL/pgSQL function "tf_xy_27700" line 5 at assignment'*
So I have converted them to double precision. I now need to get these fields to update with the x/y on update.
See below for my code so far:
CREATE OR REPLACE FUNCTION tf_xy_27700() RETURNS trigger AS $BODY$ BEGIN IF TG_OP = 'UPDATE' OR TG_OP = 'INSERT' THEN new.easting := ST_X(new.wkb_geometry); RETURN NEW; END IF; END; $BODY$ LANGUAGE plpgsql;