【PHP版】火星坐标系 (GCJ-02) 与百度坐标系 (BD-09ll)转换算法
首先感谢java版作者@宋宋宋伟,java版我是看http://blog.csdn.net/coolypf/article/details/8569813
然后根据java代码修改成了php代码。
<?php
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标
*
* @param gg_lat
* @param gg_lon
* @return
*/
function gcj02_To_Bd09($gg_lon, $gg_lat) {
$x = $gg_lon;
$y = $gg_lat;
$z = Math.sqrt($x * $x + $y * $y) + 0.00002 * Math.sin($y * pi());
$theta = Math.atan2($y, $x) + 0.000003 * Math.cos($x * pi());
$bd_lon = $z * Math.cos($theta) + 0.0065;
$bd_lat = $z * Math.sin($theta) + 0.006;
return array($bd_lon, $bd_lat);
}
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 BD-09 坐标转换成GCJ-02 坐标
*
* @param bd_lon
* @param bd_lat
* @return
*/
function bd09_To_Gcj02($bd_lon, $bd_lat) {
$x = $bd_lon - 0.0065;
$y = $bd_lat - 0.006;
$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * pi());
$theta = atan2($y, $x) - 0.000003 * cos($x * pi());
$gg_lon = $z * cos($theta);
$gg_lat = $z * sin($theta);
return array($gg_lon, $gg_lat);
}
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];
}
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];
}
// // 113.139278,23.112388
$bd_lon = 23.112388;
$bd_lat = 113.139278;
// print_r(bd09_To_Gcj02($bd_lon, $bd_lat));
print_r(coordinate_switch($bd_lon, $bd_lat));
// // 23.106200,113.132840
$gg_lon = 23.106200;
$gg_lat = 113.132840;
// print_r(gcj02_To_Bd09($gg_lon, $gg_lat));
print_r(coordinate_switchf($gg_lon, $gg_lat));
【PHP版】火星坐标系 (GCJ-02) 与百度坐标系 (BD-09ll)转换算法的更多相关文章
- 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法
$x_pi = 3.14159265358979324 * 3000.0 / 180.0; //火星坐标系 (GCJ-02)转百度坐标系 (BD-09)算法 function bd_encrypt($ ...
- iOS 地图坐标系之间的转换WGS-84世界标准坐标、GCJ-02中国国测局(火星坐标,高德地图)、BD-09百度坐标系转换
开发过程中遇到地图定位不准确,存在偏差.首先确认你获取到的坐标所在坐标系跟地图数据是不是相匹配的. 常用的地图SDK:高德地图使用的是GCJ-02(也就是火星坐标系),百度使用的是BD-09百度坐标系 ...
- (数据科学学习手札60)用Python实现WGS84、火星坐标系、百度坐标系、web墨卡托四种坐标相互转换
一.简介 主流被使用的地理坐标系并不统一,常用的有WGS84.GCJ02(火星坐标系).BD09(百度坐标系)以及百度地图中保存矢量信息的web墨卡托,本文利用Python编写相关类以实现4种坐标系统 ...
- JAVA火星坐标系、百度坐标系、84坐标系相互转换工具类
/** * 坐标系转换工具类 */ public class PositionUtil { public static double pi = 3.1415926535897932384626; pu ...
- [转]iOS开发中的火星坐标系及各种坐标系转换算法
iOS开发中的火星坐标系及各种坐标系转换算法 源:https://my.oschina.net/u/2607703/blog/619183 其原理是这样的:保密局开发了一个系统,能将实际的坐标转 ...
- iOS开发中的火星坐标系及各种坐标系转换算法
原文地址:http://m.oschina.net/blog/619183?ref=myread 其原理是这样的:保密局开发了一个系统,能将实际的坐标转换成虚拟的坐标.所有在中国销售的数字地图必须使用 ...
- 地球坐标-火星坐标-百度坐标及之间的转换算法 C#
美国GPS使用的是WGS84的坐标系统,以经纬度的形式来表示地球平面上的某一个位置.但在我国,出于国家安全考虑,国内所有导航电子地图必须使 用国家测绘局制定的加密坐标系统,即将一个真实的经纬度坐标加密 ...
- Objective-C上地球坐标系到火星坐标系转换算法
Objective-C上地球坐标系到火星坐标系转换算法 http://blog.csdn.net/zhaoxy_thu/article/details/17033347
- Visual Studio 2017 Enterprise 发布 15.3.3 版,附离线安装包百度网盘下载。
Visual Studio 2017 Enterprise 发布 15.3.3 版,附离线安装包百度网盘下载. Visual Studio 2017 Enterprise 更新至 15.3.3 ,本安 ...
随机推荐
- openssl 1.1.1 reference
openssl 1.1.1 include/openssl aes.h: # define HEADER_AES_H aes.h: # define AES_ENCRYPT 1 aes.h: # de ...
- hikey960编译记录
arm64内核编译命令: 1 make ARCH=arm64 hikey960-defconfig 2 make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- ...
- Oracle 数据库监听无法连接上、监听HANG住、监听无响应、TNS-12560
环境: Windows server 2003 Oracle 11.2.0.1 问题: 一套老数据库在运行了很久后,突然就连接不上了,提示监听异常. 处理: 1.CMD命令行检查监听状态:无监听 2. ...
- Codeforces Round #550 (Div. 3) F. Graph Without Long Directed Paths
F. Graph Without Long Directed Paths time limit per test 2 seconds memory limit per test 256 ...
- 清晰讲解SQL语句中的外连接,通用于Mysql和Oracle,全是干货哦
直入主题: 我们做一个操作,将员工SCOTT的部门去掉,再次通过内连接查看数据,看看会产生什么现象? 使用内连接,查询数据 问题:找不到SCOTT员工了,只有13条数据,这显然不合理:这就是内连接的缺 ...
- Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案
1 cartool 下载地址 https://github.com/steventroughtonsmith/cartool 由于在macOS Mojave系统上 之前代码会报错需要修改main.m ...
- LoadRunner脚本准备
脚本录制1.启动LoadRunner2.打开VuGen在LoadRunner Launcher窗格中,单击创建/编辑脚本3.创建一个空白Web脚本在“新建虚拟用户”对话框里选择新建脚本的协议一般选择W ...
- Java序列化随记
序列化简介: 程序中的对象并不只是存在内存中,还需要传输网络,或者保存起来下次再加载出来用,因此需要Java序列化技术. Java序列化技术正是将对象转变成一串由二进制字节组成的数组,可以通过将二进制 ...
- dynamic动态类型的扩展方法
对于一个动态类型来说,你可以认为它包含任意成员,它们都能通过编译.但到了运行时,到底是否拥有这些成员,就真相大白了.如 dynamic test = ; Console.Write(test.Name ...
- 关于hadoop的运行的一些指标监控(非cdh平台的)
在hadoop-env.sh中添加: # 在配置namenode和datanode时都会有用到JMX_OPTS的代码,是为了减少重复提取出的公共代码 export JMX_OPTS="-Dc ...