[postgis-users] Problem with pgsql function

Bruce Rindahl rindahl at lrcwe.com
Fri Sep 22 07:47:21 PDT 2006


Have you considered using the translate() function?  I would do exactly what
you are coding and it will work on all geometries.
Bruce Rindahl

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
palmerj at xtra.co.nz
Sent: Thursday, September 21, 2006 6:43 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Problem with pgsql function

Hi,

I have had problems with creating a pgsql function:

CREATE OR REPLACE FUNCTION bde.shift_point(shape geometry)
  RETURNS GEOMETRY AS
$BODY$
    DECLARE
        x        DOUBLE PRECISION;
        y        DOUBLE PRECISION;
        z        DOUBLE PRECISION;
        srid     INTEGER;
        new      GEOMETRY;
    BEGIN
        IF ( geometrytype(shape) <> 'POINT' ) THEN
             RETURN NULL;
        END IF;
        x    := x(shape);
        y    := y(shape);
        z    := z(shape);
        srid := srid(shape);
        
        --RAISE NOTICE 'x=%, y=%, z=%, srid=%', x, y, z, srid;
        x   := x - 160;
        IF ( x  < -180 ) THEN
            x := x + 360;
        END IF;

        new := MakePoint( x, y, z);
        IF srid THEN
            new := SetSRID(new, srid);
        END IF;
        RETURN new;
    END;
$BODY$
  LANGUAGE 'plpgsql' IMMUTABLE;

I get the following error: 

ERROR:  syntax error at or near "(" at character 13
QUERY:  SELECT   $1 ( $2 )
CONTEXT:  SQL statement in PL/PgSQL function "shift_point" near line 11
LINE 1: SELECT   $1 ( $2 )

If I prefix the postgis x, y, z, setsrid functions with the schema 'public'.
The function parses ok. 

My search path environment variables are:

public, bde, bdewtn, comp_test, unloads, gdbcrs, crsrpt, audit

my postgis version is:

POSTGIS="1.1.2CVS" GEOS="2.2.1-CAPI-1.0.1" PROJ="Rel. 4.4.9, 29 Oct 2004"
USE_STATS

postgresql server version = 8.1.2 linux redhat 9.0

Thanks
Jeremy


_______________________________________________
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