KML-File에서 지상 오버레이 모서리의 LAT/LNG 계산
-
06-07-2019 - |
문제
PHP 또는 JavaScript에서 KML 파일로 주어진지면 오버레이의 LAT/LNG에서 모서리를 찾아야합니다.
즉, 내가 가져와야하는 특정 예를 위해서는 다음과 같습니다.
<LatLonBox>
<north>60.406505416667</north>
<south>60.400570555556</south>
<east>5.3351572222222</east>
<west>5.3190577777778</west>
<rotation>3.7088732260919</rotation>
</LatLonBox>
코너 좌표로
SW: 60.400316388889;5.3194425
SE: 60.400824722222;5.3355405555556
NE: 60.406759444444;5.3347738888889
NW: 60.406251388889;5.3186730555556
나는 다른 방법을 얻을 수 있습니다 (적어도 적어도 PHP 코드)
$w=($nw_lng+$sw_lng)/2;
$e=($ne_lng+$se_lng)/2;
$n=($ne_lat+$nw_lat)/2;
$s=($se_lat+$sw_lat)/2;
$rot= rad2deg (atan ( ( $nw_lng - $sw_lng ) / ($sw_lat - $nw_lat ) / 2 ) );
돌아 가기가 쉽지만, 그곳에 도착하지 않고 시간을 사용했습니다. 팁이 있습니까?
해결책
사용해야합니다 구형 삼각법, 부분의 구형 기하학 완전한 정확도. 그러나 작은 구의 조각 만 다루기 때문에 유클리드 형상은 한 가지를 기억한다면 할 것입니다.
위도가 증가함에 따라 경도 선이 더 가까워집니다. 예를 들어, 북극 근처에서 위도 선이 거의 감동적입니다. 따라서 위도 차이를 조절하여 COS (위도)의 한계에 의해 모킹하여 감소하십시오. 그것은 당신에게 당신의 앱에 충분한 정확도를 줄 것입니다.
$n = 60.406505416667;
$s = 60.400570555556;
$e = 5.3351572222222;
$w = 5.3190577777778;
$rotn = 3.7088732260919;
$a = ($e + $w) / 2.0;
$b = ($n + $s) / 2.0;
$squish = cos(deg2rad($b));
$x = $squish * ($e - $w) / 2.0;
$y = ($n - $s) / 2.0;
$ne = array(
$a + ($x * cos(deg2rad($rotn)) - $y * sin(deg2rad($rotn))) /$squish,
$b + $x * sin(deg2rad($rotn)) + $y *cos(deg2rad($rotn))
);
$nw = array(
$a - ($x * cos(deg2rad($rotn)) + $y * sin(deg2rad($rotn))) /$squish,
$b - $x * sin(deg2rad($rotn)) + $y *cos(deg2rad($rotn))
);
$sw = array(
$a - ($x * cos(deg2rad($rotn)) - $y * sin(deg2rad($rotn))) /$squish,
$b - $x * sin(deg2rad($rotn)) - $y *cos(deg2rad($rotn))
);
$se = array(
$a + ($x * cos(deg2rad($rotn)) + $y * sin(deg2rad($rotn))) /$squish,
$b + $x * sin(deg2rad($rotn)) - $y *cos(deg2rad($rotn))
);
print_r(array(
'sw'=>$sw,
'se'=>$se,
'ne'=>$ne,
'nw'=>$nw,
));
나의 $squish
변수는 내가 언급 한 cos (lat)입니다. 수평 길이의 상대적인 부분에 대해서는 낙하산이 있습니다. 사인 테이블은 다음과 같습니다.
NE: (a + x cos A - y sin A, b + x sin A + y cos A)
NW: (a - x cos A - y sin A, b - x sin A + y cos A)
SW: (a - x cos A + y sin A, b - x sin A - y cos A)
SE: (a + x cos A + y sin A, b + x sin A - y cos A)
아마도 TTTPPP는 TTTPPP 테이블의 차이를 설명 할 수 있습니다.
제휴하지 않습니다 StackOverflow