php如何實現騰訊與百度座標的轉換詳解

黄舟
發布: 2023-03-14 18:10:01
原創
1685 人瀏覽過

下面小編就為大家帶來一篇PHP實現騰訊與百度座標轉換。小編覺得蠻不錯的,現在就分享給大家,也給大家做個參考。一起跟著小編過來看看吧

廢話不多說,直接上程式碼


public function coordinate_switch($a,$b){//百度转腾讯坐标转换
  $x = (double)$b - 0.0065;
  $y = (double)$a - 0.006;
  $x_pi = 3.14159265358979324;
  $z = sqrt($x * $x+$y * $y) - 0.00002 * sin($y * $x_pi);
  $theta = atan2($y,$x) - 0.000003 * cos($x*$x_pi);
  $gb = number_format($z * cos($theta),15);
  $ga = number_format($z * sin($theta),15);
  return ['Latitude'=>$ga,'Longitude'=>$gb];
}

public function coordinate_switchf($a,$b){//腾讯转百度坐标转换
  $x = (double)$b ;
  $y = (double)$a;
  $x_pi = 3.14159265358979324;
  $z = sqrt($x * $x+$y * $y) + 0.00002 * sin($y * $x_pi);
  $theta = atan2($y,$x) + 0.000003 * cos($x*$x_pi);
  $gb = number_format($z * cos($theta) + 0.0065,6);
  $ga = number_format($z * sin($theta) + 0.006,6);

  return ['Latitude'=>$ga,'Longitude'=>$gb];

}
登入後複製

以上是php如何實現騰訊與百度座標的轉換詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!