java實(shí)現(xiàn)百度坐標(biāo)的摩卡托坐標(biāo)與火星坐標(biāo)轉(zhuǎn)換的示例
更新時(shí)間:2014年03月20日 10:12:21 作者:
這篇文章主要介紹了java實(shí)現(xiàn)百度坐標(biāo)的摩卡托坐標(biāo)與火星坐標(biāo)轉(zhuǎn)換的示例,需要的朋友可以參考下
這是百度地圖的摩卡托坐標(biāo)與火星坐標(biāo)的相互轉(zhuǎn)換方法,大家參考使用吧
復(fù)制代碼 代碼如下:
/**
* 百度摩卡拖坐標(biāo)與火星坐標(biāo)的加密解密算法
* @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("摩卡坐標(biāo)經(jīng)緯度:"+lat+","+lon);
System.out.println("火星坐標(biāo)經(jīng)緯度:"+bd_decrypt(lat,lon));
}
//解密成為火星坐標(biāo)
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;
}
//加密成為摩卡托坐標(biāo)
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;
}
}
相關(guān)文章
Spring Boot自定義配置屬性源(PropertySource)
這篇文章主要介紹了Spring Boot自定義配置屬性源(PropertySource),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
使用Java實(shí)現(xiàn)6種常見負(fù)載均衡算法
Java負(fù)載均衡算法也是分布式系統(tǒng)中的重要組成部分,用于將來自客戶端的請(qǐng)求分配到不同的后端服務(wù)器上,本文將介紹常見的Java負(fù)載均衡算法,輪詢法、加權(quán)隨機(jī)法……一次性讓你了解?6?種常見負(fù)載均衡算法
2023-06-06
解決java.sql.SQLException:?validateConnection?false問題的方法匯總(最
這篇文章主要給大家介紹了關(guān)于解決java.sql.SQLException:?validateConnection?false問題的方法匯總,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
2023-03-03
MyBatis Properties及別名定義實(shí)例詳解
這篇文章主要介紹了MyBatis Properties及別名定義實(shí)例詳解,需要的朋友可以參考下
2017-08-08
解決Spring Cloud Gateway獲取body內(nèi)容,不影響GET請(qǐng)求的操作
這篇文章主要介紹了解決Spring Cloud Gateway獲取body內(nèi)容,不影響GET請(qǐng)求的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
2020-12-12
SSM 實(shí)現(xiàn)登錄驗(yàn)證碼功能(附源碼)
這篇文章主要介紹了SSM 實(shí)現(xiàn)登錄驗(yàn)證碼功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
2018-12-12 
