WGS84 (World Geodetic System 1984) is a coordinate system established for use in GPS positioning systems
GCJ-02, our country on the basis of WGS84 encryption to get
BD-09, Baidu coordinates in the GCJ-02 Foundation, has carried on the BD-09 two times the encryption
Mars coordinates and Baidu coordinates (GCJ-02----BD-09) conversion
The international latitude and longitude coordinates standard is WGS-84, the domestic must use at least the GCJ-02 which the National Survey Bureau formulates, the geographical location carries on the first encryption.
Baidu coordinates on this basis, carried out the BD-09 two times encryption measures, more protection of personal privacy.
The coordinate system of Baidu external interface is not the true latitude and longitude of GPs acquisition, and it needs to be transformed by coordinate transformation interface.
The conversion of Baidu coordinates to Mars coordinates:
Public classCoor {Const DoubleX_PI =3.14159265358979324*3000.0/180.0;//Defining Constants /// <summary> ///convert GCJ-02 coordinates to BD-09 coordinates/// </summary> /// <param name= "Gg_lat" >mars x coordinate</param> /// <param name= "Gg_lon" >Mars y-coordinate</param> /// <param name= "XX" >Baidu X coordinate</param> /// <param name= "YY" >Baidu y-coordinate</param> Public voidBd_encrypt (DoubleGg_lat,DoubleGg_lon, out DoubleXx out DoubleYY) { Doublex = Gg_lon, y =Gg_lat; Doublez = MATH.SQRT (x * x + y * y) +0.00002* Math.sin (Y *x_pi); Doubletheta = math.atan2 (y, x) +0.000003* MATH.COS (X *x_pi); XX= Z * Math.Cos (theta) +0.0065; YY= Z * Math.sin (theta) +0.006; } /// <summary> ///convert BD-09 coordinates to GCJ-02 coordinates/// </summary> /// <param name= "Bd_lat" >Baidu X coordinate</param> /// <param name= "Bd_lon" >Baidu y-coordinate</param> /// <param name= "XX" >mars x coordinate</param> /// <param name= "YY" >Mars y-coordinate</param> Public voidBd_decrypt (DoubleBd_lat,DoubleBd_lon, out DoubleXx out DoubleYY) { Doublex = Bd_lon-0.0065, y = Bd_lat-0.006; Doublez = MATH.SQRT (x * x + y * y)-0.00002* Math.sin (Y *x_pi); Doubletheta = math.atan2 (y, x)-0.000003* MATH.COS (X *x_pi); XX= Z *Math.Cos (theta); YY= Z *Math.sin (theta); } }
Conversion of Mars coordinates to WGS-84:
//GCJ-02 to WGS-84 conversion (i.e. GPS correction) Public classEviltransform {Const DoublePI =3.14159265358979324; Const DoubleA =6378245.0; Const DoubleEE =0.00669342162296594323; Public voidTransformDoubleWglat,DoubleWglon, out DoubleMglat, out DoubleMglon) { if(Outofchina (Wglat, Wglon)) {Mglat=Wglat; Mglon=Wglon; return; } DoubleDlat = Transformlat (Wglon-105.0, Wglat-35.0); DoubleDlon = Transformlon (Wglon-105.0, Wglat-35.0); DoubleRadlat = Wglat/180.0*Pi; DoubleMagic =Math.sin (Radlat); Magic=1-EE * Magic *Magic; DoubleSqrtmagic =math.sqrt (Magic); Dlat= (Dlat *180.0)/((A * (1-ee)/(Magic * sqrtmagic) *pi); Dlon= (Dlon *180.0)/(A/sqrtmagic * MATH.COS (Radlat) *pi); Mglat= Wglat +Dlat; Mglon= Wglon +Dlon; } Static BOOLOutofchina (DoubleLatDoubleLon) { if(Lon <72.004|| Lon >137.8347) return true; if(Lat <0.8293|| Lat >55.8271) return true; return false; } Static DoubleTransformlat (DoubleXDoubley) {DoubleRET =-100.0+2.0* x +3.0* y +0.2* Y * y +0.1* x * y +0.2*math.sqrt (Math.Abs (x)); RET+= (20.0* Math.sin (6.0* x * pi) +20.0* Math.sin (2.0* x * pi)) *2.0/3.0; RET+= (20.0* Math.sin (Y * pi) +40.0* Math.sin (Y/3.0* pi)) *2.0/3.0; RET+= (160.0* Math.sin (Y/12.0* pi) + the* Math.sin (Y * pi/30.0)) *2.0/3.0; returnret; } Static DoubleTransformlon (DoubleXDoubley) {DoubleRET =300.0+ x +2.0* y +0.1* x * x +0.1* x * y +0.1*math.sqrt (Math.Abs (x)); RET+= (20.0* Math.sin (6.0* x * pi) +20.0* Math.sin (2.0* x * pi)) *2.0/3.0; RET+= (20.0* Math.sin (x * pi) +40.0* Math.sin (X/3.0* pi)) *2.0/1.R; RET+= (150.0* Math.sin (X/12.0* pi) +300.0* Math.sin (X/30.0* pi)) *2.0/3.0; returnret; } }
SOURCE download
Coordinate conversion--gcj-02