[postgis-users] ST_transform in PostGis 1.4.0 gives error

Mike Toews mwtoews at sfu.ca
Mon Jan 18 08:40:20 PST 2010


On 2010-01-17 23:32, Ahlmark Johan wrote:
>
> Hi,
>
> We recently updated PostGis to version 1.4.0 and after that we have a 
> problem when transforming projections. The problem I am facing is that 
> I want the ST-transform to return null if a projection is unable to be 
> transform and not and error.
>

Hi,

One quick workaround is to define a wrapper function or directly use 
PL/pgSQL (if you need this in a function).

CREATE OR REPLACE FUNCTION st_transform_null(geometry, integer)
   RETURNS geometry AS
$BODY$BEGIN
   RETURN st_transform($1, $2);
EXCEPTION WHEN internal_error THEN
   RETURN NULL;
END;$BODY$
   LANGUAGE 'plpgsql' IMMUTABLE STRICT
   COST 100;


-- Then try
select st_transform_null(PointFromText('POINT(-117.157 
32.7153)',4326),3021);

See the section "Trapping Errors" in 
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html 
for details.

-Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100118/cd9a58a0/attachment.html>


More information about the postgis-users mailing list