2017-02-28 7 views
1

선 스트링이 주어진 경우, 선 스트링의 시작점을 중심으로 원을 구성하면 원이 선 스트링과 교차 할 것으로 예상됩니다.SQL Server - Geography

declare @startPoint geography = geography::Point(51.947859,3.986790,4326) 
declare @endPoint geography = geography::Point(51.956383,3.995908,4326) 
declare @g geography = geography::STGeomFromText('LINESTRING(51.947859 3.986790, 55.956383 3.995908)', 4326).MakeValid() -- The linestring 

select 
    @startPoint.STDistance(@endPoint) -- is 1136.88182010473 metres 

declare @h geography = @startPoint.STBuffer(50) -- The Circle 

select 
    @g.STIntersection(@h).STEndPoint().Long,@g.STIntersection(@h).STStartPoint().Long 

select 
    @g.STIntersects(@h) -- Why is this false(0)? 

왜 원과 선 스트링이 교차하지 않는지 이해하는데 도움이 필요합니다. 감사.

답변

0

알아 냈어. 나는대로 @startPoint를 정의 할 때 : 텍스트이기 때문에,

set @startPoint = geography::Point(51.947859,3.986790,4326) 

점 :

set @startPoint= geography::STGeomFromText('POINT(51.947859 3.986790)',4326) 

텍스트로 요점은 다음과 같습니다 :

select @startpoint.ToString() -- result= POINT (3.98679 51.947859) 

나는대로 @startPoint를 정의 할 때

select @startpoint.ToString() -- POINT (51.947859 3.98679) 

즉, 첫 번째 구문은 위도, 경도를 사용하는 반면 두 번째 구문은 경도, 위도를 사용합니다. 두 번째 구문은을 사용하는 구문입니다. 의도적으로 또는 우연히, 이것은 개발자를위한 함정에 불과합니다.