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;
}
}
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
Java特性
Java语言特性Java是一个简单的、面向对象的、分布式的、解释的、健壮的、安全带、结构中立的、可移植的、高性能...
[阅读全文]
-
Linux运维
Linux运维Linux运维Linux运维一 Linux基础知识Linux简介与安装Linux常用命令Vim编辑...
[阅读全文]
-
-
虚拟机对象的创建
读周志明老师《深入理解java虚拟机》笔记2.3.11.对象的创建当java虚拟机遇到一条字节码new指令时,首...
[阅读全文]
-
网友评论