質問

PHPまたはjavascriptのkmlファイルで指定されたグラウンドオーバーレイの緯度/経度のコーナーを見つける必要があります。

つまり特定の例については、次から取得する必要があります:

  <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  ) );

戻るのは簡単なはずですが、私はそこに着かずにこれに何時間も使いました。ヒントはありますか?

役に立ちましたか?

解決

球面三角法を使用する必要があります/en.wikipedia.org/wiki/Spherical_geometry "rel =" nofollow noreferrer ">球面形状を使用すると、完全な精度が得られます。ただし、扱っているのは球体の小さな部分だけなので、ユークリッドジオメトリは、1つだけ覚えておけばうまくいきます。

緯度が上がると、経度の線は互いに近づきます。たとえば、北極の近くでは、緯線はほとんど接触しています。したがって、緯度の差を調整し、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のテーブルとの違いを説明できるでしょう。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top