I have the following code that is attempting to define a Rectangle in SQL Server 2008 from a Rectangle I've drawn on the map.
cGeographyInitQuery = string.Format(@" DECLARE @Rectangle geography; SET @Rectangle = geography::STGeomFromText('{0}', 4269);", RectangleSelected.GetWellKnownText());
Which formats as follows:
DECLARE @Rectangle geography;
SET @Rectangle = geography::STGeomFromText('POLYGON(( -74.933063234375 40.5839042578125, -74.3233220234375 40.5839042578125, -74.3233220234375 40.13895796875, -74.933063234375 40.13895796875, -74.933063234375 40.5839042578125))', 4269);
However when I run the query, I get the following error in SQL Server:
Msg 6522, Level 16, State 1, Line 2 A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": Microsoft.SqlServer.Types.GLArgumentException: 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation.
Since we aren't crossing any hemisphere's it appears as if the "GetWellKnowText()" function is not using the correct ring orientation. How do I correct this? It seems funny that the function wouldn't produce the correctly formated polygon.
Bob