Java implementation of Baidu coordinates Mocato coordinates and Mars coordinate conversion example _java

Source: Internet
Author: User
Tags cos sin

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;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.