[英]STIntersect geography,geometry datatype
我有一个圆和一个点,在几何学中,点与圆相交,但在地理学上却不相交。
DECLARE @circle GEOGRAPHY = GEOGRAPHY::Point(39.10591303215, 21.923140028856, 4120).STBuffer(500)
DECLARE @geogpoint GEOGRAPHY = GEOGRAPHY::Point(51.590294, 25.16387, 4120)
select @circle,@geogpoint.ToString(),@geogpoint,@circle.STIntersects(@geogpoint)
DECLARE @circle1 geometry = geometry::Point(39.10591303215, 21.923140028856, 4120).STBuffer(500)
DECLARE @geomgpoint geometry = geometry::Point(51.590294, 25.16387, 4120)
select @circle1,@geomgpoint.ToString(),@geomgpoint,@circle1.STIntersects(@geomgpoint)
我有很多圆圈和点,问题是几何几乎都相交而地理很少。
对于“ Geography
,缓冲区的大小以SRID为单位。 对于4120:
SELECT unit_of_measure FROM sys.spatial_reference_systems WHERE spatial_reference_id = 4120
给“米”
因此,您要添加500m的缓冲区。 现在,您的两个(无缓冲)点之间的距离是多少?
DECLARE @circle GEOGRAPHY = GEOGRAPHY::Point(39.10591303215, 21.923140028856, 4120)
DECLARE @geogpoint GEOGRAPHY = GEOGRAPHY::Point(51.590294, 25.16387, 4120)
SELECT @circle.STDistance(@geogpoint)
1410017.60306578 metres
这解释了为什么STIntersects返回false。
对于Geometery
,您正在使用“单位”。 您的两点之间的距离是多少?
DECLARE @circle1 geometry = geometry::Point(39.10591303215, 21.923140028856, 4120)
DECLARE @geomgpoint geometry = geometry::Point(51.590294, 25.16387, 4120)
select @circle1.STDistance(@geomgpoint)
12.898143234446 'units' (in this case degrees)
这就是为什么第二个查询返回true的原因。
看看“空间数据类型中的度量”一节https://msdn.microsoft.com/en-us/library/bb964711.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.