[C #] Mars coordinate system (GCJ-02) and Baidu coordinate system (BD-09) Conversion helper class

Source: Internet
Author: User
Tags cos

Key code:

usingSystem;usingYanZhiwei.DotNet2.Utilities.Models;namespaceyanzhiwei.dotnet2.utilities.common{// <summary>    /// Mars coordinate system (GCJ-02) and Baidu coordinate system (BD-09) Conversion helper class    // </summary>     Public classBdgcjlatlonhelper {/** Reference:*bd09 coordinate system: that is, the Baidu coordinate system, GCJ02 coordinate system after the encrypted coordinate system.          */        #regionConstantConst DoubleX_PI = 3.14159265358979324 * 3000.0/180.0;#endregion         #regionConvert GCJ-02 coordinates to BD-09 coordinates// <summary>        /// convert GCJ-02 coordinates to BD-09 coordinates        // </summary>        /// <param name= "gcjpoint" >gcj-02 coordinates </param>        // <returns>bd-09 coordinates </returns>         PublicLatlngpoint gcj02tobd09 (Latlngpoint gcjpoint) {Latlngpoint _bdpoint =NewLatlngpoint ();Double_x = Gcjpoint.lonx, y = gcjpoint.laty;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);            _bdpoint.lonx = _z * Math.Cos (_theta) + 0.0065; _bdpoint.laty = _z * Math.Cos (_theta) + 0.006;return_bdpoint; }#endregion         #regionConvert BD-09 coordinates to GCJ-02 coordinates// <summary>        /// convert BD-09 coordinates to GCJ-02 coordinates        // </summary>        /// <param name= "bdpoint" >bd-09 coordinates </param>        // <returns>gcj-02 coordinates </returns>         PublicLatlngpoint bd09togcj02 (Latlngpoint bdpoint) {Latlngpoint _gcjpoint =NewLatlngpoint ();Double_x = bdpoint.lonx-0.0065, _y = bdpoint.laty-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);            _gcjpoint.lonx = _z * Math.Cos (_theta); _gcjpoint.laty = _z * Math.sin (_theta);return_gcjpoint; }#endregion}}

[C #] Mars coordinate system (GCJ-02) and Baidu coordinate system (BD-09) Conversion helper class

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.