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
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to