【问题标题】:Is this SQL Server 2012 "exceeds single hemisphere" error actually an SRID error?这个 SQL Server 2012“超过单个半球”错误实际上是 SRID 错误吗?
【发布时间】:2014-01-17 03:08:30
【问题描述】:

我正在尝试在 SQL Server 2012 的地理类型字段中插入一个多边形。

UPDATE tblProjects
SET tblProjects.Boundary = geography::STGeomFromText( 'POLYGON ((-93.30388806760311 27.994401411046173, -94.62224744260311 33.37641235124676, -79.70281384885311 31.80289258670676, -93.30388806760311 27.994401411046173))',4326)
WHERE tblProjects.ProjectID = 1;

尽管我的多边形位于单个半球中,但我收到以下错误:

Msg 6522, Level 16, State 1, Line 1
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)

我假设这是与空间参考 ID 相关的错误,因为以下返回 NULL

SELECT distinct Boundary.STSrid AS SRID
FROM dbo.tblProjects;

我的这个假设是正确的吗?如何设置 SRID?我的尝试返回错误:

UPDATE dbo.tblProjects
SET Boundary.STSrid = 4326;

错误:

Msg 5302, Level 16, State 1, Line 1
Mutator 'STSrid' on 'Boundary' cannot be called on a null value.

【问题讨论】:

    标签: sql sql-server spatial


    【解决方案1】:

    所以看来环方向确实是问题所在。显然,我的网络映射器的输出具有与 SQL Server 想要的相反顺序的顶点。我按照建议更改了第二个和第三个顶点的顺序(第一个和最后一个始终相同,以确保形状是一个完整的多边形) hereUPDATE 声明通过没有任何问题。

    现在有趣的部分是弄清楚如何以编程方式解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-01
      • 2013-05-27
      • 2012-09-30
      • 2014-12-11
      • 1970-01-01
      相关资源
      最近更新 更多