欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

java实现百度坐标的摩卡托坐标与火星坐标转换的示例

时间:2021-04-26 11:02:28|栏目:JAVA代码|点击:

这是百度地图的摩卡托坐标与火星坐标的相互转换方法,大家参考使用吧

复制代码 代码如下:

/**
 * 百度摩卡拖坐标与火星坐标的加密解密算法
 * @author XFan
 *
 */
public class Outer {
 private static double lat = 31.22997;
 private static double lon = 121.640756;
 public static double x_pi = lat * lon / 180.0;
 public static void main(String[] args) {
  System.out.println("摩卡坐标经纬度:"+lat+","+lon);
  System.out.println("火星坐标经纬度:"+bd_decrypt(lat,lon));
 }
 //解密成为火星坐标
 public static String bd_decrypt(double bd_lat, double bd_lon)
 {
     double x = bd_lon - 0.0065, y = bd_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 gg_lon = z * Math.cos(theta);
     double gg_lat = z * Math.sin(theta);
     return gg_lat+","+gg_lon;
 }
 //加密成为摩卡托坐标
 public static String bd_encrypt(double gg_lat, double gg_lon)
 {
     double x = gg_lon, y = gg_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;
     return gg_lat+","+gg_lon;
 }
}

上一篇:Intellij IDEA如何去掉@Autowired 注入警告的方法

栏    目:JAVA代码

下一篇:Java中的Vector和ArrayList区别及比较

本文标题:java实现百度坐标的摩卡托坐标与火星坐标转换的示例

本文地址:http://www.codeinn.net/misctech/108802.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有