I'm using nettopologysuite in c# to build a nettopology geometry object, and then save it as a geometry object in SQL. Generally this works fine, except i recent came up with (from a shapefile) the WKT:
POINT Z(3.59140026404647 50.7568317130073 0)
which broke everything. Both if i do it in code:
var tmp = SqlGeometry.Parse(new SqlString(geometryObject.AsText()));
or if i do it in the SQL procedure itself:
declare @tmpGeom as Geometry = null;
if (@GeometryObj is not null)
Begin
set @tmpGeom=geometry::STGeomFromText(@GeometryObj ,4326)
if (@tmpGeom.STIsValid() = 0)
Begin
set @tmpGeom = @tmpGeom.MakeValid()
end
end
neither work. I get an error similar to:
24142: Expected "(" at position 6. The input has "Z". System.FormatException Source = Microsoft.SqlServer.Types at Microsoft.SqlServer.Types.WellKnownTextReader.RecognizeToken(Char token) at Microsoft.SqlServer.Types.WellKnownTextReader.ParsePointText(Boolean parseParentheses) at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type) at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid) at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid) at Microsoft.SqlServer.Types.SqlGeometry.Parse(SqlString s)
Any ideas how to convert the POINT WKT (which does read as 'IsValid' in nettopology) into something SQL can use?