CJG-02 火星坐标
BD09 百度坐标
CJG-02 -> BD09
private static double x_pi = ((3.14159265358979324 * 3000.0)/180.0);
/*CJG-02 - BD09*/
public static double[] bd_encrypt(double gg_lat, double gg_lon)
{
double bd_lon,bd_lat;
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);
bd_lon = z * Math.cos(theta) + 0.0065;
bd_lat = z * Math.sin(theta) + 0.006;
return new double[]{bd_lat,bd_lon};
}
BD09 -> CGJ-02
/*BD09 - CJG-02*/
public static double[] bd_decrypt(double bd_lat, double bd_lon)
{
double gg_lon,gg_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 * x_pi);
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
gg_lon = z * Math.cos(theta);
gg_lat = z * Math.sin(theta);
return new double[]{gg_lon,gg_lat};
}