型別
說明使用者
wgs84
美國gps
國際通用,如谷歌國外地圖、osm地圖
火星系gcj-02
國測局制定的標準,國內地圖必須至少使用此對位置進行首次加密
bg-09
共有兩個類,coordinate和coordinatetool。
coordinate,座標點物件:
class
coordinate
}
coordinatetool ,座標轉換工具類:
define('x_pi',3.14159265358979324 * 3000.0 / 180.0);
class
coordinatetool
/***@param $bd_loc 火星座標點(class coordinate)
* @return $bg_loc coordinate物件,火星座標系經緯度座標
*/public
static
function
bd_gcj
($bd_loc)
/*** 將國際通用座標系wgs84座標 轉換成 火星座標系gcj-02 座標
*@param $wgs_loc wgs84座標點(class coordinate)
* @return $bg_loc coordinate物件,火星座標系經緯度座標
*/public
static
function
wgs_gcj
($wgs_loc)
$x_pi = x_pi;
$dlat = self::transformlat($wgs_lon - 105.0, $wgs_lat - 35.0);
$dlon = self::transformlon($wgs_lon - 105.0, $wgs_lat - 35.0);
$radlat = $wgs_lat / 180.0 * $x_pi;
$magic = sin($radlat);
$magic = 1 - self::$ee * $magic * $magic;
$sqrtmagic = sqrt($magic);
$dlat = ($dlat * 180.0) / ((self::$a * (1 - self::$ee)) / ($magic * $sqrtmagic) * self::$pi);
$dlon = ($dlon * 180.0) / (self::$a / $sqrtmagic * cos($radlat) * self::$pi);
$mglat = $wgs_lat + $dlat;
$mglon = $wgs_lon + $dlon;
$gcj_loc = new coordinate($mglon,$mglat);
return
$gcj_loc;
}/**
* 將火星座標系gcj-02座標 轉換成 國際通用座標系wgs84座標
*@param $gcj_loc gcj-02座標點(class coordinate)
* @return $wgs_loc coordinate物件,國際通用座標系wgs84座標
*/public
static
function
gcj_wgs
($gcj_loc)
private
static
function
outofchina
($lon,$lat)
private
static
function
transformlat
($x,$y)
private
static
function
transformlon
($x, $y)
}
在controller層呼叫
$coordinate = new coordinate(113.3998,34.5443); //吃貨天堂的座標
$coord = coordinatetool::gcj_bd($coordinate);
$coordinate = new coordinate(113.3996,34.543);
$coord = coordinatetool::bd_gcj($coordinate);
//將國際通用座標系wgs84座標 轉換成 火星座標系gcj-02 座標
$coordinate = new coordinate(113.3924,34.54036);
$coord = coordinatetool::wgs_gcj($coordinate);
//將火星座標系gcj-02座標 轉換成 國際通用座標系wgs84座標
$coordinate = new coordinate(113.3998,34.5443);
$coord = coordinatetool::gcj_wgs($coordinate);
iOS 地球座標 火星座標說明
座標系介紹 首先介紹一下目前的定位座標系統 1 地球座標 代號 gps wgs84 有w就是世界通用的 也就是原始座標體系,這是國際公認的世界標準座標體系 使用 wgs84 座標系統的產品有 蘋果的 cllocationmanager 獲取的座標 2 火星座標 代號 gcj 02 g國家 c測繪 j...
百度座標,火星座標和WGS84相互轉換
1 4public class transform 16 17public point bd09togcj02 double bd lon,double bd lat 2728 29 3031 param lng32 param lat33 returns 34 35public point gcj...
IOS火星座標轉換
火星座標系統 是一種國家保密外掛程式,也叫做加密外掛程式或者加偏或者sm模組,其實就是對真實座標系統進行人為的加偏處理,按照特殊的演算法,將真實的座標加密成虛假的座標,而這個加偏並不是線性的加偏,所以各地的偏移情況都會有所不同。而加密後的座標也常被人稱為 火星座標系統 所有的電子地圖 導航裝置,都需...