[postgis-users] GeomFromText in a user function.

Mike Toews mwtoews at gmail.com
Tue Apr 26 12:38:52 PDT 2011


On 27 April 2011 05:46, Charles E. Deaton <CDeaton at corp.realcomp.com> wrote:
> I have been trying to create a user function that I can call as needed by
> passing in bbox coordinates.

Are you trying to select items in a box-shaped geometry? There are a
few better ideas to construct a simple box polygon that use fewer than
eight parameters:

-- Three numeric parameters, using a box centre (x,y) and "expand"
distance of 1:
SELECT ST_AsEWKT(ST_Expand(ST_MakePoint(15,25), 1));

-- One parameter, using the bounding box from a geometry
SELECT ST_AsEWKT(Box2D('POLYGON ((10 40, 30 20, 40 50, 10
40))'::geometry)::geometry);

Your problem is due to a misinterpretation of the messy concatenation.
Try using dollar-quote literals e.g.: $BODY$This "text" doesn't do
much$BODY$. Postgres thinks you are trying to use a type named
geomfromtext, which is not your intent. I generally try to avoid
constructing geometries into text using string concatenation as they
are subject to fail if one of the parameters is null, and they are
extra overhead (float -> string -> parse to float) with possible loss
of precision.

-Mike



More information about the postgis-users mailing list