[postgis-users] GeomFromText in a user function.

Paragon Corporation lr at pcorp.us
Tue Apr 26 12:37:50 PDT 2011


Charles,
 
Which version of PostGIS are you using?
 
If you are using trunk (PostGIS 2.0), those won't work since they were
removed.  Use ST_GeomFromText and ST_Within instead.  Though I don't think
that is the problem based on your error.
 
 
It's  hard to read you code.  Please use $$ $$ quoting instead of ' that way
you don't have to escape out your inner quotes.
 
Leo
http://www.postgis.us

  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Charles
E. Deaton
Sent: Tuesday, April 26, 2011 1:46 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] GeomFromText in a user function.



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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110426/6ca71f43/attachment.html>


More information about the postgis-users mailing list