24114 error when creating Geometry from SQLChar

897 Views Asked by At

I am calling a web service in my C# code. The service returns Geometry in WKT (well known text).

When printing out the returned WKT in a message box, it looks as follows:

POINT(-9206304.681343028 5363253.767605823)

However when I attempt to create an SQLChar from this string and invoke STGeomFromText to create a point, I get the following error

{"24114: The label ???POINT(-9206304.68 in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only)."}

I am not sure why the entire string till the coordinate separator is perceived as the label in this case instead of the actual "POINT" label.

Here is my C# code:

// Call the webservice.
byte[] responseBody = webClient.UploadData(uri, requestMethod, requestBodyBytes);

string ProjectedWKTString = Encoding.ASCII.GetString(responseBody);

SqlString anSQLString = new SqlString(ProjectedWKTString);
SqlChars anSQLChar = new SqlChars(anSQLString);

SqlGeometry projectedPoint = SqlGeometry.STGeomFromText(anSQLChar, 3857);

I have been investigating this for a while. Any help is very much appreciated

0

There are 0 best solutions below