Infinite BoundingBox in SqlServer2008 Provider in SharpMap v0.9

Topics: Data Access, SharpMap v0.9 / v1.x
Apr 11, 2010 at 12:52 AM

Hi,

I had been using the GeometryFeatureProvider until now. But recently I thought of migrating to SQL Server Geometry data types to take advantage of the Spatial Indexing provided out of the box in SQL Server 2008.

However, I get a feeling that the SqlServer2008.cs in the v0.9 trunk is not stable. I have created an instance of the provider and provided both the Geometry column name and the OIDColumn name. For my test I have also included a definition query which should return 24 rows. But for some strange reason the map object's envelope seems to be whacky, when the VectorLayer's Render method is called! Here is the envelope value I get: {-8.98846567431158E+307,-Infinity 8.98846567431158E+307,Infinity}

Naturally, as a result, the call to ExecuteIntersectionQuery method in line 214 of VectorLayer.cs is failing and throws the following exception:

 

A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": 
System.FormatException: 24126: Point coordinates cannot be infinite or not a number (NaN).
System.FormatException: 
   at Microsoft.SqlServer.Types.Validator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)
   at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)
   at Microsoft.SqlServer.Types.ForwardingGeoDataSink.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)
   at Microsoft.SqlServer.Types.OpenGisWktReader.ParseLineStringText()
   at Microsoft.SqlServer.Types.OpenGisWktReader.ParsePolygonText()
   at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type)
   at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid)
   at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)
.

A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": 

System.FormatException: 24126: Point coordinates cannot be infinite or not a number (NaN).

System.FormatException: 

   at Microsoft.SqlServer.Types.Validator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)

   at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)

   at Microsoft.SqlServer.Types.ForwardingGeoDataSink.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)

   at Microsoft.SqlServer.Types.OpenGisWktReader.ParseLineStringText()

   at Microsoft.SqlServer.Types.OpenGisWktReader.ParsePolygonText()

   at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type)

   at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid)

   at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)

.

 

I am not sure if I am doing anything wrong. Both the VectorLayer and SqlServer2008 SRIDs have been set. I am totally stuck and unable to move forward.

Raghu

 

Apr 11, 2010 at 10:50 AM

I have nailed down the error. I've put a call to Refresh method of the map in the resize event of the container control. The container form actually has a tab control which host as many MapImage controls as needed. So initially when the new tab is created and the MapImage control is added to the tab (Docked to Fill), the container's Resize event is fired at which point either the height or width of the map is zero. Which is what seems to be resulting in the invalid BoundingBox.

Just added a check to see if both height and width of the control are greater than zero before refreshing the map. This is working for now. But there are a couple of other problems I am investigating.

Cheers,

Raghu