[英]SQL Server geography polygon intersections
我在SQL Server 2012中遇到问题。当我尝试获取两个多边形的交集时:
DECLARE @boundingRect geography;
SET @boundingRect = N'POLYGON((27 30, 170 30, 170 80, 27 80, 27 30))'
DECLARE @boundingRect2 geography;
SET @boundingRect2 = N'POLYGON((84 56, 84.1 56, 84.1 56.1, 84 56.1, 84 56))'
SELECT @boundingRect.STIntersection(@boundingRect2).ToString()
它返回GEOMETRYCOLLECTION EMPTY
。 但是它必须返回第二个多边形,因为@boundingRect
包含@boundingRect2
。 如果我更改为
SET @boundingRect = N'POLYGON((27 20, 170 20, 170 80, 27 80, 27 20))'
工作正常。 为什么? 我究竟做错了什么?
在椭球系统中,多边形没有任何意义,或者是不明确的,没有方向。 例如,围绕赤道的圆环是否描述了北半球或南半球? 如果使用地理数据类型存储空间实例,则必须指定环的方向并准确描述实例的位置。 椭球系统中多边形的内部由左手定则定义。
而且的确,如果我颠倒为@boundingRect
指定点的顺序,它将返回结果:
DECLARE @boundingRect geography;
SET @boundingRect = N'POLYGON((27 30, 27 80, 170 80, 170 30, 27 30))'
DECLARE @boundingRect2 geography;
SET @boundingRect2 = N'POLYGON((84 56, 84.1 56, 84.1 56.1, 84 56.1, 84 56))'
SELECT @boundingRect.STIntersection(@boundingRect2).ToString()
结果:
POLYGON ((84 56.1, 84 56, 84.1 56, 84.1 56.1, 84 56.1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.