[postgis-users] ERROR: couldnt parse object in GEOMETRY
Paul Ramsey
pramsey at refractions.net
Sun Dec 22 17:12:22 PST 2002
The problem is you are treating the $ variables like perl variables. You
cannot just dump them into a string and expect them to evaluate. You
need to explicitly concatenate them into a string. So for example, to
create a WKT representation of a point from two inputs, do this:
'POINT(' || $1 || ' ' || $2 || ')'
Michael O'Sullivan wrote:
> Hi all,
>
> I am trying to create a function which takes two points as arguments and
> calls length_spheroid using the two points as LINESTRING data.
>
> Can someone explain why
>
> CREATE FUNCTION get_length (numeric, numeric, numeric, numeric) RETURNS
> double precision AS '
> SELECT length_spheroid(\'LINESTRING(-88.8869323730469
> 30.4190692901611,-95.3706970214844 28.9613304138184)\',
> \'SPHEROID("GRS_1980",6378137,298.257222101)\');
> ' LANGUAGE SQL;
>
> works, but
>
> CREATE FUNCTION get_length (numeric, numeric, numeric, numeric) RETURNS
> numeric AS '
> SELECT length_spheroid(\'LINESTRING($1 $2, $3 $4)\',
> \'SPHEROID("GRS_1980",6378137,298.257222101)\');
> ' LANGUAGE SQL;
>
> does not?
>
> When I try and use function arguments as the values to the LINESTRING
> definition, I get
>
> "ERROR: couldnt parse object in GEOMETRY"
>
> I have tried enclosing the LINESTRING($1 $2, $3 $4) call with a
> GeometryFromText call, but I still get GEOMETRY parse errors.
>
> I have searched the mailing list archive and found a mail from a while
> back indicating you couldn't create the LINESTRING objects in the server
> - is that what is going on here?
>
> > The $60000 question: at the moment, you cannot do so within the
> > database. I think a better bet would be for us to get a
> > distance(<geometry>,<geometry>) function in there ASAP. What say you,
> > Dave?
>
> >Ted Rolle wrote:
> >>
> >> How do I make a LINESTRING from two POINTs? What I want to do is
> get the
> >> {length2d|length3d} of this LINESTRING to determine the distance
> between
> >> two points.
> >>
> >> Ted
>
>
>
> thanks,
>
>
> Michael
>
More information about the postgis-users
mailing list