简单介绍一下常见的地理经纬度坐标系:
WGS-84
坐标系:
是国际标准坐标系,GPS
坐标(Google Earth
使用、或者GPS
模块)。
GCJ-02
坐标系:
火星坐标系,GCJ-02
是由中国国家测绘局制订的地理信息系统的坐标系统。它是一种对经纬度数据的加密算法,即加入随机的偏差。国内出版的各种地图系统(包括电子形式),出于国家安全考虑,必须至少采用GCJ-02
对地理位置进行首次加密。国内腾讯地图和高德地图都采用了GCJ-02
火星坐标系。
BD-09
坐标系:
百度坐标系,也就是在GCJ-02
的基础上,进行了BD-09
二次加密措施生成的一种坐标系。
GCJ-02
(火星,高德) 坐标和BD-09
(百度) 坐标相互转换的函数PHP
版本:
//BD-09(百度)坐标转换成GCJ-02(火星,高德)坐标//@param bd_lon 百度经度//@param bd_lat 百度纬度function bd_decrypt($bd_lon,$bd_lat){$x_pi = 3.14159265358979324 * 3000.0 / 180.0;$x = $bd_lon - 0.0065;$y = $bd_lat - 0.006;$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);$theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);// $data['gg_lon'] = $z * cos($theta);// $data['gg_lat'] = $z * sin($theta);$gg_lon = $z * cos($theta);$gg_lat = $z * sin($theta);// 保留小数点后六位$data['gg_lon'] = round($gg_lon, 6);$data['gg_lat'] = round($gg_lat, 6);return $data;}//GCJ-02(火星,高德)坐标转换成BD-09(百度)坐标//@param bd_lon 百度经度//@param bd_lat 百度纬度function bd_encrypt($gg_lon,$gg_lat){$x_pi = 3.14159265358979324 * 3000.0 / 180.0;$x = $gg_lon;$y = $gg_lat;$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);$theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);$bd_lon = $z * cos($theta) + 0.0065;$bd_lat = $z * sin($theta) + 0.006;// 保留小数点后六位$data['bd_lon'] = round($bd_lon, 6);$data['bd_lat'] = round($bd_lat, 6);return $data;}
/archives/1628.html