SQL geography::EnvelopeAggregate 输出不准确

SQL geography::EnvelopeAggregate output not accurate

我正在尝试获取一组位置的 geography::EnvelopeAggregate。地理列值是使用 Lat/Long 为各个点计算的。 当我尝试获取边界框(范围)时,该框并未覆盖所有单个点。这是预期的行为吗?有这方面专业知识的人可以提供一些意见吗? 下面是 SQL 代码和绘制的相应地图。

IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE id = OBJECT_ID(N'tempdb..[#ServicePoints]'))
    BEGIN
        DROP TABLE #Points
    END
CREATE TABLE #Points
(
    PointId nvarchar(max),
    Lat float,
    Long float,
    Location geography
)
insert into #Points(PointId, Lat, Long, Location)
values ('point1', 47.659226, -117.218292, geography::Point(47.659226, -117.218292, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point2', 47.659226, -117.218292, geography::Point(47.659226, -117.218292, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.659226, -117.218292, geography::Point(47.659226, -117.218292, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.658276, -117.218474, geography::Point(47.658276, -117.218474, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.658323, -117.21899, geography::Point(47.658323, -117.21899, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.658341, -117.219487, geography::Point(47.658341, -117.219487, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.660115, -117.219365, geography::Point(47.660115, -117.219365, 4326))
insert into #Points(PointId, Lat, Long, Location)
values ('point3', 47.658478, -117.216265, geography::Point(47.658478, -117.216265, 4326))

select * from #Points
--select geography::Point(47.658323, -117.21899, 4326)
Select E1.ID, 
                   E1.SPEXtents.STPointN(3).Lat as BottomLeft_Lat, 
                   E1.SPEXtents.STPointN(3).Long as BottomLeft_Long,
                   E1.SPEXtents.STPointN(1).Lat as RightTop_Lat,         
                   E1.SPEXtents.STPointN(1).Long as RightTop_Long, 
                   E1.SPExtents.STPointN(2).Lat as BottomRight_Lat,
                   E1.SPExtents.STPointN(2).Long as BottomRight_Long,
                   E1.SPExtents.STPointN(4).Lat as TopRight_Lat,
                   E1.SPExtents.STPointN(4).Long as TopRight_Long

        from
        (SELECT 1 as ID,
                geography::EnvelopeAggregate(sp.Location) AS SPExtents
        FROM #Points sp
        ) E1;

这些点在地图中的表示如下。可以看出,有 2 个点位于边界之外。

或者我应该绘制一个连接这 4 个坐标的圆吗?在这种情况下,我可以看到所有点都落在如图所示的圆圈内。

根据一些粗略的测试,EnvelopeAggregate returns 看起来像是一个圆形区域。我发现了以下内容:

select geography::EnvelopeAggregate(sp.Location).ToString() AS SPExtents
FROM #Points sp

如果你想看到它描述的实际区域,只需从上面删除 .ToString()