[postgis-users] Fast access to PostGIS from c/c++
Markus Schaber
schabi at logix-tt.com
Tue Dec 12 05:44:21 PST 2006
Hi, Andreas,
"Boehm, Andreas" <boehm at rif.fuedo.de> schrieb:
> myData[1] = "GeometryFromText('POINT(" + to_string(x) + " "
> + to_string(y) + ")', -1)";
[...]
> The error message is:
> SQL error: ERROR: parse error - invalid geometry
> CONTEXT: COPY points, line 1, column geom:
> "GeometryFromText('POINT(122.072
> 9172.53)', -1)"
The problem here is that you insert the GeometryFromText call as String
parameter.
The PostgreSQL serser prepares the COPY command semantically equal to
the following INSERT statement: "INSERT INTO points VALUES ($1,$2)"
and $2 is the text "GeometryFromText('POINT(122.072 9172.53)', -1)"
which is not a valid geometry representation.
PostgreSQL tries to parse the contents of a COPY datastream directly
into the data columns, it does not handle function calls like
GeometryFromText inside of a copy stream.
Try the following change in your code:
myData[1] = "POINT(" + to_string(x) + " " + to_string(y) + ")";
> Running "INSERT INTO points VALUES (1, GeometryFromText('POINT(122.072
> 9172.53)', -1));" in pgAdmin was sucsessful.
Yes, that's what expected, but not equivalent to what you did above,
which equals to:
"INSERT INTO points VALUES (1, 'GeometryFromText(''POINT(122.072
9172.53)'', -1)' );"
HTH,
Markus
More information about the postgis-users
mailing list