【发布时间】:2014-01-06 08:27:50
【问题描述】:
我不想求助于将我的地理数据转换为几何,以便它在 STIntersect 中返回 true。
这是SQL中的代码:
DECLARE @point GEOGRAPHY = GEOGRAPHY::Point(1, 1, 4326)
DECLARE @polygon GEOGRAPHY = GEOGRAPHY::STGeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)
SELECT @polygon.STIntersects(@point), @point.STIntersects(@polygon)
以下返回 false (0),但是如果我使用:
DECLARE @point GEOMETRY = GEOMETRY::Point(1, 1, 4326)
DECLARE @polygon GEOMETRY = GEOMETRY::STGeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)
SELECT @polygon.STIntersects(@point), @point.STIntersects(@polygon)
它返回 true,我缺少什么吗?我所知道的是地理是 3D 平面,几何是平面地图,但是如果点在多边形中,我将使用地球进行计算。
PS:它不适用于 STContains、STWithin、STOverlaps
使用 Microsoft SQL Server 2012
【问题讨论】:
标签: sql geometry polygon point geography