Exception when converting SharpMap geometry to SQL Server geometry

Topics: Algorithms, CompactFramework, Data Access, General Topics, Italiano, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, Web Controls, WinForms Controls
Feb 24, 2011 at 4:13 PM

I am getting an exception when I try to convert sharpmap geometry to sql server geometry. I am using SharpMap ver 0.9.

                FeatureDataRow fdr = dataTable.Rows[i] as FeatureDataRow;
                Geometry geometry = fdr.Geometry;
                SqlGeometry geom = SqlGeometryConverter.ToSqlGeometry(geometry); //offending line


24305: The Polygon input is not valid because the ring does not have enough distinct points. Each ring of a polygon must contain at least three distinct points.
   at Microsoft.SqlServer.Types.Validator.Execute(Transition transition)
   at Microsoft.SqlServer.Types.Validator.EndFigure()
   at Microsoft.SqlServer.Types.SqlGeometryBuilder.EndFigure()
   at SharpMap.Converters.SqlServer2008SpatialObjects.SqlGeometryConverter.AddRing(SqlGeometryBuilder builder, LinearRing linearRing)
   at SharpMap.Converters.SqlServer2008SpatialObjects.SqlGeometryConverter.SharpMapPolygonToSqlGeometry(SqlGeometryBuilder geomBuilder, Polygon polygon)
   at SharpMap.Converters.SqlServer2008SpatialObjects.SqlGeometryConverter.SharpMapMultiPolygonToSqlGeometry(SqlGeometryBuilder geomBuilder, MultiPolygon multiPolygon)
   at SharpMap.Converters.SqlServer2008SpatialObjects.SqlGeometryConverter.SharpMapGeometryToSqlGeometry(SqlGeometryBuilder geomBuilder, Geometry smGeometry)
   at SharpMap.Converters.SqlServer2008SpatialObjects.SqlGeometryConverter.ToSqlGeometry(Geometry smGeometry)
   at MyApp.Shapefile.Shape2Sql.ShapeFile.SaveShapeFile2DB(String conStr, String tableName, String[] columnsRequired, Dictionary`2 customColName) in D:\Projects\MyApp\Trunk\Shape Import Prototype\MyApp.Shapefile.Shape2Sql\Shapefile.cs:line 245

Any idea will be very much appreicated.
Feb 24, 2011 at 4:45 PM

Hello kingofwebguru,

Could you post the WKT of the SharpMap geometry (geometry.AsText())?

Cheers FObermaier

Feb 24, 2011 at 8:16 PM


Can I email you the shape file via your email address on your profile?