I'm going to apologize up front for being a nood.

 

I have been trying to create a user function that I can call as needed
by passing in bbox coordinates. I have the standard SQL working as show
below;

 

SELECT *

FROM "MyTable" t

WHERE WITHIN(

GeomFromText('POLYGON((5 1, 8 4, 7 3, 6 2, 5 1))'),t.geom);

 

The above runs fine, they are not valid values based on the geom column
is based on lat/lon.

 

When I place it in a PostgreSQL function it keeps telling me "type
"geomfromtext" does not exist".

I have run out of ideas and can't find a lot on the net about PostgreSQL
function similar to this. Below is my last attempt:

 

CREATE OR REPLACE FUNCTION fn_Poly(double precision, double precision,
double precision, double precision, double precision, double precision,
double precision, double precision)

RETURNS SETOF " MyTable" AS

'SELECT *

FROM " MyTable" t

WHERE WITHIN(

GeomFromText('' || '''''''' || ''''POLYGON(('' ||

                $5 || '' '' || $1 || '', '' ||

                $8 || '' '' || $4 || '', '' ||

                $7 || '' '' || $3 || '', '' ||

                $6 || '' '' || $2 || '', '' ||

                $5 || '' '' || $1 ||

                ''))'')'''' || '''',t.geom)'

 

LANGUAGE sql;

 

Any help would be greatly appreciated. 

 

Charlie

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to