java实现百度坐标的摩卡托坐标与火星坐标转换的示例
更新时间:2014年03月20日 10:12:21 作者:
这篇文章主要介绍了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;
}
}
相关文章
Spring Boot自定义配置属性源(PropertySource)
这篇文章主要介绍了Spring Boot自定义配置属性源(PropertySource),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-06-06
解决java.sql.SQLException: validateConnection false问题的方法汇总(最
这篇文章主要给大家介绍了关于解决java.sql.SQLException: validateConnection false问题的方法汇总,文中通过图文介绍的非常详细,需要的朋友可以参考下2023-03-03
解决Spring Cloud Gateway获取body内容,不影响GET请求的操作
这篇文章主要介绍了解决Spring Cloud Gateway获取body内容,不影响GET请求的操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-12-12


最新评论