2017-12-09 16 views
0

위치 집합에 대해 geography :: EnvelopeAggregate를 얻으려고합니다. 지형 열 값은 개별 점에 대한 위도/경도를 사용하여 계산됩니다. 경계 상자 (범위)를 가져 오려고하면 상자가 모든 개별 점을 포함하지 않습니다. 이 예상되는 동작입니까? 이 분야의 전문 지식을 가진 사람이 일부 의견을 제공 할 수 있습니까? 다음은 SQL 코드와 해당 맵을 플로팅 한 것입니다.SQL geography :: EnvelopeAggregate 출력이 정확하지 않습니다.

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 점이 경계 밖으로 나옵니다. 2 Points lying outside the extents.

또는이 4 개의 좌표를 연결하는 원을 그려야합니까? 어떤 경우에는 모든 점이 표시된 것처럼 원 안에 들어 있음을 볼 수 있습니다. EnvelopeAggregate 원형 영역을 반환처럼 거친 테스트를 기반으로 Circle

답변

1

Circle plotted using the coordinates

, 그것은 보인다. 나는 다음에 이것을 발견 :

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

그 설명의 실제 영역을 보려면

, 그냥 위에서 .ToString()를 제거합니다.