[postgis-users] GeometryFromText Problem
Carl Anderson
carl.anderson at vadose.org
Thu Dec 9 16:12:19 PST 2004
Gustavo Oliveira wrote:
>Hi all!
>
>I am trying to do a function that tranform some data into a geometry and
>update a table.
>
>It seems like that:
>
>CREATE OR REPLACE FUNCTION atualiza_posicao()
> RETURNS trigger AS
>'
> BEGIN
>
> IF NEW.idviatura IS NULL THEN
> RAISE EXCEPTION \'Campo viatura nao pode ser nulo\';
> END IF;
>
> IF NEW.datahora IS NULL THEN
> RAISE EXCEPTION \'Viatura % sem timestamp\', NEW.idviatura;
> END IF;
>
> UPDATE historico_viatura
> SET
> localizacaoutm = select
>transform(geometryfromtext(\'POINT(-NEW.latitude
>-NEW.longitude)\',4326),40000)
> WHERE
> idhistorico = NEW.idhistorico;
>
>
>
UPDATE historico_viatura
SET
localizacaoutm = transform(geometryfromtext(\'POINT(\'||
(-1 * NEW.latitude)||\' \'||(-1 * NEW.longitude)||\')\',4326),40000)
WHERE
idhistorico = NEW.idhistorico;
or maybe
NEW.the_geom =
transform(geometryfromtext(\'POINT(\'||
(-1 * NEW.latitude)||\' \'||(-1 * NEW.longitude)||\')\',4326),40000);
if the trigger acts on the historico_viatura table
inside PLPGSQL the select() is not necessary or things that evaluate
as the correct datatype.
More information about the postgis-users
mailing list