This is the Baidu map of the Mocato coordinates and Mars coordinates of the mutual conversion method, we refer to the use of it
Copy Code code as follows:
/**
* Baidu Mocha Drag coordinates and Mars coordinates encryption and decryption algorithm
* @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 ("Mocha coordinate latitude and longitude:" +lat+ "," +lon);
SYSTEM.OUT.PRINTLN ("Mars coordinate latitude and longitude degree:" +bd_decrypt (Lat,lon));
}
Decryption becomes Mars coordinates
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;
}
Encryption becomes Mocato coordinates
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;
}
}