Dies ist die gegenseitige Konvertierungsmethode von Mochato -Koordinaten und Mars -Koordinaten von Baidu Map.
Die Codekopie lautet wie folgt:
/**
* Verschlüsselungs- und Entschlüsselungsalgorithmus von Baidu Mocha -Dragkoordinaten und Mars -Koordinaten
* @Author xfan
*
*/
öffentliche Klasse äußere {
private statische Doppel -Lat = 31,22997;
Private statische Doppel -Lon = 121.640756;
public static double x_pi = lat * lon / 180.0;
public static void main (String [] args) {
System.out.println ("Mokka -Koordinaten -Breitengrad und Längengrad:"+lat+","+lon);
System.out.println ("mars koordiniert Breitengrad und Längengrad:"+bd_decrypt (lat, lon));
}
// Entschlüsselung wird zu Mars -Koordinate
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;
}
// Verschlüsselung wird zur Mochato -Koordinate
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;
}
}