|
|
@ -1,7 +1,7 @@ |
|
|
|
package com.elink.esua.epdc.commons.tools.utils; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description TODO |
|
|
|
* @Description |
|
|
|
* @Author yinzuomei |
|
|
|
* @Date 2019/12/27 10:00 |
|
|
|
*/ |
|
|
@ -29,6 +29,7 @@ public class GPSUtils { |
|
|
|
* pi)) * 2.0 / 3.0; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
public static double[] transform(double lat, double lon) { |
|
|
|
if (outOfChina(lat, lon)) { |
|
|
|
return new double[]{lat, lon}; |
|
|
@ -45,6 +46,7 @@ public class GPSUtils { |
|
|
|
double mgLon = lon + dLon; |
|
|
|
return new double[]{mgLat, mgLon}; |
|
|
|
} |
|
|
|
|
|
|
|
public static boolean outOfChina(double lat, double lon) { |
|
|
|
if (lon < 72.004 || lon > 137.8347) |
|
|
|
return true; |
|
|
@ -52,6 +54,7 @@ public class GPSUtils { |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System |
|
|
|
* |
|
|
@ -78,13 +81,14 @@ public class GPSUtils { |
|
|
|
|
|
|
|
/** |
|
|
|
* * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return |
|
|
|
* */ |
|
|
|
*/ |
|
|
|
public static double[] gcj02_To_Gps84(double lat, double lon) { |
|
|
|
double[] gps = transform(lat, lon); |
|
|
|
double lontitude = lon * 2 - gps[1]; |
|
|
|
double latitude = lat * 2 - gps[0]; |
|
|
|
return new double[]{latitude, lontitude}; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 |
|
|
|
* |
|
|
@ -115,7 +119,9 @@ public class GPSUtils { |
|
|
|
return gps; |
|
|
|
} |
|
|
|
|
|
|
|
/**将gps84转为bd09 |
|
|
|
/** |
|
|
|
* 将gps84转为bd09 |
|
|
|
* |
|
|
|
* @param lat |
|
|
|
* @param lon |
|
|
|
* @return |
|
|
@ -125,6 +131,7 @@ public class GPSUtils { |
|
|
|
double[] bd09 = gcj02_To_Bd09(gcj02[0], gcj02[1]); |
|
|
|
return bd09; |
|
|
|
} |
|
|
|
|
|
|
|
public static double[] bd09_To_gps84(double lat, double lon) { |
|
|
|
double[] gcj02 = bd09_To_Gcj02(lat, lon); |
|
|
|
double[] gps84 = gcj02_To_Gps84(gcj02[0], gcj02[1]); |
|
|
@ -134,7 +141,9 @@ public class GPSUtils { |
|
|
|
return gps84; |
|
|
|
} |
|
|
|
|
|
|
|
/**保留小数点后六位 |
|
|
|
/** |
|
|
|
* 保留小数点后六位 |
|
|
|
* |
|
|
|
* @param num |
|
|
|
* @return |
|
|
|
*/ |
|
|
|