Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server sql server空间精度问题_Sql Server_Spatial - Fatal编程技术网

Sql server sql server空间精度问题

Sql server sql server空间精度问题,sql-server,spatial,Sql Server,Spatial,我在SQL Server 2008 R2中遇到了来自STIntersects的不准确结果的问题。也许有人可以解释一下我可能做错了什么-我不相信这是SQL Server空间查询的准确性极限 --example 1 DECLARE @pt1 geography; DECLARE @pt2 geography; DECLARE @polygon geography; SET @polygon = geography::STPolyFromText('POLYGON((-172.0000000000 5

我在SQL Server 2008 R2中遇到了来自STIntersects的不准确结果的问题。也许有人可以解释一下我可能做错了什么-我不相信这是SQL Server空间查询的准确性极限

--example 1
DECLARE @pt1 geography;
DECLARE @pt2 geography;
DECLARE @polygon geography;
SET @polygon = geography::STPolyFromText('POLYGON((-172.0000000000 54.0000000000,-164.0000000000 54.0000000000,-164.0000000000 56.0000000000,-172.0000000000 56.0000000000,-172.0000000000 54.0000000000))',4326);
SET @pt1 = geography::STPointFromText('POINT(-170.0000000000 54.04)',4326);
SET @pt2 = geography::STPointFromText('POINT(-170.0000000000 56.04)',4326);
SELECT @polygon.STIntersects(@pt1); --should be 1, but returns 0 (error is .04 * 60 nautical miles per degree - something like 4.4 km) 
SELECT @polygon.STIntersects(@pt2); --should be 0, but returns 1


--example 2
DECLARE @pt1 geography;
DECLARE @pt2 geography;
DECLARE @polygon geography;
SET @polygon = geography::STPolyFromText('POLYGON((-171.0000000000 54.0000000000,-170.0000000000 54.0000000000,-170.0000000000 54.5000000000,-171.0000000000 54.5000000000,-171.0000000000 54.0000000000))',4326);
SET @pt1 = geography::STPointFromText('POINT(-170.5000000000 54.001)',4326);
SET @pt2 = geography::STPointFromText('POINT(-170.5000000000 54.01)',4326);
SELECT @polygon.STIntersects(@pt1); --should be 1, returns 0
SELECT @polygon.STIntersects(@pt2); --should be 1, returns 1 (less error than in example 1, perhaps due to smaller polygon?)

准确度没有限制,这完全取决于地理类型使用的弯曲地球。在示例1中绘制的矩形实际上具有曲线边,而不是直线(由于曲面上的距离)。北半球的水平边缘自然向上弯曲,

因此,@pt1将始终为false,因为它位于多边形的“弯曲”边之外。按原样(缓冲以便您可以看到该点)

同样,@pt2实际上位于曲线边的内部,因此将始终为真,如此(显示为缓冲和多边形中的孔)


如果您使用几何体(平面模型)渲染这些,您将得到您想要的答案,但不一定是正确的答案。

SQL Server 2012给出的结果与您在SQL Server 2008 R2上观察到的结果相同,顺便说一句。我想这就是答案: