0

Hi i am trying to create an geography area our of North-West lat & long, South-east lat&long But i get this exception when i run query with these co-ordinates.

Select (geography::STGeomFromText('POLYGON((-0.534717 0.524190,0.426951 0.524190,0.426951 -0.578706,-0.534717 -0.578706,-0.534717 0.524190))', 4326))

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. To create a larger than hemisphere geography instance, upgrade the version of SQL Server and change the database compatibility level to at least 110.
Microsoft.SqlServer.Types.GLArgumentException: 
   at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoData& g, Double eccentricity, Boolean forceKatmai)
   at Microsoft.SqlServer.Types.SqlGeography.IsValidExpensive(Boolean forceKatmai)
   at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid)
   at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
.
Amrit
  • 423
  • 6
  • 22
  • 2
    I know nothing about the geography data type, but the error message itself gives several specific suggestions about the cause of the error. Have you checked all of them? And since the error mentions DB compatibility levels, what version of SQL Server are you using? – Pondlife Aug 14 '12 at 20:28
  • 1
    @Pondlife - I know a lot about the geography datatype, and your common-sense answer was pretty much correct ;) – Alastair Aitchison Aug 15 '12 at 14:27
  • @AlastairAitchison That's good to know :) I wish all error messages were that informative! – Pondlife Aug 15 '12 at 19:22

1 Answers1

1

You've got the incorrect ring orientation, so your polygon is "inside-out". You should use this instead:

SELECT geography::STGeomFromText('POLYGON ((0.426951 0.52419, -0.534717 0.52419, -0.534717 -0.578706, 0.426951 -0.578706, 0.426951 0.52419))', 4326);
Alastair Aitchison
  • 3,532
  • 1
  • 16
  • 15
  • so It was supposed to be anti-clock orientation? – Amrit Aug 15 '12 at 15:32
  • as yours points go from (+x,+y) - > (-x,+y) - > (-x,-y) - > (+x,-y) - > (+x,+y) – Amrit Aug 15 '12 at 15:34
  • I did the same but get same exception for this query! `SELECT geography::STGeomFromText('POLYGON((179.000000 64.072036,-45.000000 64.072036,-45.000000 -89.9,179.000000 -89.9,179.000000 64.072036))', 4326);` – Amrit Aug 15 '12 at 15:43