我正在尝试为一组位置获取geography :: EnvelopeAggregate。对于各个点,使用Lat / Long计算地理列值。 当我尝试获取边界框(范围)时,框不会覆盖所有单个点。这是预期的行为吗?拥有该领域专业知识的人是否可以提供一些意见。 下面是SQL代码和相应的Map。
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;
答案 0 :(得分:1)
基于一些粗略的测试,它看起来像EnvelopeAggregate返回一个圆形区域。我发现了以下内容:
select geography::EnvelopeAggregate(sp.Location).ToString() AS SPExtents
FROM #Points sp
如果您想查看其中描述的实际区域,只需从上方移除.ToString()
即可。