这是SQL Server 2012吗;“超过单半球”;错误实际上是一个SRID错误?
我正在尝试将多边形插入SQL Server 2012中的地理类型字段中这是SQL Server 2012吗;“超过单半球”;错误实际上是一个SRID错误?,sql,sql-server,spatial,Sql,Sql Server,Spatial,我正在尝试将多边形插入SQL Server 2012中的地理类型字段中 UPDATE tblProjects SET tblProjects.Boundary = geography::STGeomFromText( 'POLYGON ((-93.30388806760311 27.994401411046173, -94.62224744260311 33.37641235124676, -79.70281384885311 31.80289258670676, -93.30388806760
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.
因此,似乎环的方向确实是个问题。显然,我的web映射器输出的顶点顺序与SQL Server希望的相反。我按照建议更改了第二个和第三个顶点的顺序(第一个和最后一个顶点始终相同,以确保形状是一个完整的多边形),并且
UPDATE
语句没有出现任何问题
现在,有趣的部分是找出如何以编程方式解决这个问题