[postgis-users] Error on updating geometry column from two columns value
Firman Hadi
jalmiburung at gmail.com
Thu Dec 1 18:49:34 PST 2011
Dear Mike,
Thank you for the solutions. I will try it.
Thanks again.
Cheers,
Firman.
On 12/2/11 5:16 AM, Mike Toews wrote:
> ST_GeomFromText turns WKT into a geometry, not SQL. You can either
> format WKT (text) using:
>
> ST_GeomFromText('POINT(' || NEW.koordinat_x || ', ' || NEW.koordinat_y
> || ')', 32748)
>
> Or, a simpler/faster/lossless geometry constructor would be to pass
> the floating point values directly to a point geometry:
>
> ST_SetSRID(ST_MakePoint(NEW.koordinat_x, NEW.koordinat_y), 32748)
>
> Note: you had your X/Y coordinates the other way around. PostGIS
> coordinates are always ordered X/Y or long/lat.
>
> -Mike
>
> On 1 December 2011 20:31, Firman Hadi<jalmiburung at gmail.com> wrote:
>> Dear all,
>>
>> I want to create one table with 3 columns (x, y, geom). I want to input the
>> x and y using form with PHP.
>> When I submit the form, it will trigger the new row.
>>
>> I use this step below but when I insert the data I get the error as in
>> attachment.
>>
>> I hope that anyone can help me to solve the problem.
>>
>> Thank you in advance.
>>
>> Kind regards,
>>
>> Firman Hadi
>> Center for Remote Sensing - ITB
>> Indonesia
>>
>>
>>
>>
>> CREATE TABLE try_geometry (
>> koordinat_y integer,
>> koordinat_x integer,
>> geom geometry PRIMARY KEY
>> );
>> ========================
>>
>> CREATE FUNCTION try_geometry_func () RETURNS trigger AS '
>> BEGIN
>> NEW.geometri = ST_GeomFromText('POINT(NEW.koordinat_y,
>> NEW.koordinat_x)',32748);
>> RETURN NEW;
>> END;
>> ' LANGUAGE plpgsql;
>>
>> =======================================
>>
>> CREATE TRIGGER try_geom_trg BEFORE INSERT OR UPDATE
>> ON coba FOR EACH ROW
>> EXECUTE PROCEDURE try_geometry_func ();
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
More information about the postgis-users
mailing list