Hi,
I have a question about using the MsSQL2008FeatureLayer. I'm encountoring an unhandled exception and wondered if it is something that I'm doing wrong or possibly a code issue. The layer appears to connect to the database and work correctly except when the user pans the map to the north or south extent of the map. At that point Map Suite will throw a SQL exception indicating that SQL Server is expecting latitude values between 90 and -90 degrees (full details at end of post below.) I ran a trace on the SQL server and this is the query coming from Map Suite that is triggering the error:
exec sp_executesql N'SELECT GeographySpatial.STAsBinary() as GeographySpatial,ID FROM GeoTable WHERE (geometry::STGeomFromWKB(GeographySpatial.STAsBinary(),4326).STIsValid()=1 AND geography::STGeomFromText(@geography,4326).STIntersects(GeographySpatial)=1) OR geometry::STGeomFromWKB(geography::STGeomFromText(@geography,4326).STAsBinary() ,4326).STIntersects(geometry::STGeomFromWKB(GeographySpatial.STAsBinary(),4326).MakeValid())=1;',N'@Geography varchar(141)',@Geography='POLYGON((-139.297265625 122.8359375,-139.297265625 76.4296875,-74.258203125 76.4296875,-74.258203125 122.8359375,-139.297265625 122.8359375))'
When I first create the layer I set the current extent with the code
WinformsMap1.CurrentExtent = New RectangleShape(-90.2, 42, -80, 30)
The full error details are below. Please let me know if you need any other information. Any help or suggestions are appreciated.
Thanks,
Mark
System.Data.SqlClient.SqlException was unhandled
Class=16
ErrorCode=-2146232060
LineNumber=1
Message="A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.FormatException: 24201: Latitude values must be between -90 and 90 degrees. System.FormatException: at Microsoft.SqlServer.Types.GeographyValidator.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.CoordinateReversingGeoDataSink.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.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid) ."
Number=6522
Procedure=""
Server="SERVERSQL\SQL2008"
Source=".Net SqlClient Data Provider"
State=1
StackTrace:
at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x742ba885258f6c2c(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x88c2a2d6d754e692(IEnumerable`1 xa6f0db4f183189f1)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xe3cee4adb9c72451()
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x4eb49068e137ed8f(InteractionArguments x195facd4ef5d753d)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xfeca3317d3c75bbb(Object xd9272088e65bd176, x6a8380ab1a7ebb4c xc2fd4c0ed406cdb7)
at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.OnMouseEvent(x6a8380ab1a7ebb4c e)
at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.AnalyseMouseUp(Double screenX, Double screenY, Double worldX, Double worldY, MapMouseButton mouseButton)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xd1e58e0ca2447b93(Object xd9272088e65bd176, MouseEventArgs xc2fd4c0ed406cdb7)
at System.Windows.Forms.Control.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at VBSampleApps.VBSampleApps.Samples.Main() in C:\SSIWorkCopies\ResearchProjects\ThinkGeo\MapSuiteDesktopEval\Samples\VB Winforms How Do I Samples\Samples.Designer.vb:line 2
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: