Conversion Algorithm of Mars coordinate system (GCJ-02) and Baidu coordinate system (BD-09)

Source: Internet
Author: User

For GCJ-02 and BD-09, see
Http://developer.baidu.com/map/question.htm#qa0043.

AlgorithmCodeAs shown in the following figure.Bd_encryptConvert GCJ-02 coordinates into BD-09 coordinates,Bd_decryptOtherwise.

# Include <math. h> const double x_pi = 3.14159265358979324*3000.0/180.0; void bd_encrypt (double gg_lat, double gg_lon, double & bd_lat, double & bd_lon) {Double X = gg_lon, y = gg_lat; double Z = SQRT (x * x + y * Y) + 0.00002 * sin (y * x_pi); double Theta = atan2 (Y, X) + 0.000003 * Cos (x * x_pi); bd_lon = z * Cos (theta) + 0.0065; bd_lat = z * sin (theta) + 0.006;} void bd_decrypt (double bd_lat, double bd_lon, double & gg_lat, double & gg_lon) {Double X = bd_lon-0.0065, y = bd_lat-0.006; Double Z = SQRT (x * x + y * Y) -0.00002 * sin (y * x_pi); double Theta = atan2 (Y, x)-0.000003 * Cos (x * x_pi); gg_lon = z * Cos (theta ); gg_lat = z * sin (theta );}

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.