高德和百度之间的经纬度转换

来源:互联网 发布:椭圆机品牌 知乎 编辑:程序博客网 时间:2024/04/30 02:26

不同的地图都有着自己的标准,我们有时就需要坐标间的相互转换

1.高德坐标转百度

double x_pi = (double) (3.14159265358979324 * 3000.0 / 180.0);
double x = Double.parseDouble(getIntent().getStringExtra("log"));
double y = Double.parseDouble(getIntent().getStringExtra("lat"));

double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
double bd_lon = z * Math.cos(theta) + 0.0065;//转换后的
double bd_lat = z * Math.sin(theta) + 0.006;//转换后的

2.百度坐标转高德
double x_pi = (double) (3.14159265358979324 * 3000.0 / 180.0);
double x = Double.parseDouble(getIntent().getStringExtra("log")) - 0.0065;
double y = Double.parseDouble(getIntent().getStringExtra("lat")) - 0.006;

double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
double bd_lon = z * Math.cos(theta);//转换后的
double bd_lat = z * Math.sin(theta);//转换后的


0 0
原创粉丝点击