[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: Re: [postgis-users] ERROR: couldnt parse object in GEOMETRY
From: Paul Ramsey <pramsey () refractions ! net>
Date: 2002-12-23 1:12:22
Message-ID: 3E0662F6.2080108 () refractions ! net
[Download RAW message or body]
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
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic