高德座標轉百度,百度轉高德
阿新 • • 發佈:2022-04-01
/** * 高德轉百度 * * @param longitude 經度 * @param latitude 緯度 * @return [經度, 緯度] */ public static double[] calGCJ02toBD09(double longitude, double latitude) { double z = Math.sqrt(longitude * longitude + latitude * latitude) + 0.00002 * Math.sin(latitude * PI); doubletheta = Math.atan2(latitude, longitude) + 0.000003 * Math.cos(longitude * PI); double retLat = z * Math.sin(theta) + 0.006; double retLon = z * Math.cos(theta) + 0.0065; return new double[]{retLon, retLat}; } //百度轉高德 public static double[] bd09ToGcj02(double bd_lon,double bd_lat ) {double x = bd_lon - 0.0065, y = bd_lat - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * PI); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * PI); double gg_lon = z * Math.cos(theta); double gg_lat = z * Math.sin(theta);return new double[]{gg_lon, gg_lat}; }