Coordinates are calculated
Lbxy (double L, double b, double *x, double *y, int l0)
{
Double SA,SB,SEP,SN,SY2,ST,SM,SX,HB;
Double XX,YY,HD,SD;
Determine the range of values
if (L > | | L < 0 | | b > | | | b < 0)
{
*x = l;
*y = b;
Return
}
L = l-l0;
SA = 6378245;
SB = 6356863.019;
Sep= 0.006738525415;
HD = B*PI;
HB = hd/180.0;
St = tan (HB);
Sn=pow (SA, (double) 2)/sqrt (POW (SA, (double) 2) *pow (cos (HB), (double) 2)
+pow (SB, (double) 2) *pow (sin (HB), (double) 2);
Sy2=sep*pow (cos (HB), (double) 2);
SD = cos (HB) *l*pi;
SM = sd/180.0;
SX = 111134.861*b-(32005.78*sin (HB) +133.924*pow (sin (HB), (double) 3) +0.697*pow (sin (HB), (double) 5)) *cos (HB);
xx = sx+sn*st* (0.5*pow (SM, (double) 2) +1.0/24.0* (5.0-pow (St, (double) 2) +9.0*sy2) *pow (SM, (double) 4));
yy = sn* (sm+1.0/6.0* (1.0-pow (St, (double) 2) +sy2) *pow (SM, (double) 3) +1.0/120.0* (5.0-18.0*pow (St, (double) 2) +pow (St, ( Double) 4)) *pow (SM, (double) 5));
*x = XX;
*y = yy+500000;
}
Coordinate inverse calculation
XYLB (double l0, double x, double y, double *l, double *b)
{
Double BF,VF,NF,YNF,TF,YF2,HBF;
Double SA,SB,SE2,SEP2,MF;
Double w1,w2,w,w3,w4;
Double pi = 3.1415926;
x = x/1000000.0;
y = y-500000.0;
BF = 9.04353692458*x-0.00001007623*pow (x,2.0) -0.00074438304*pow (x,3.0) -0.00000463064*pow (x,4.0) +0.00000505846* Pow (x,5.0) -0.00000016754*pow (x,6.0);
HBF = BF * pi/180.0;
SA = 6378245.0;
SB = 6356863.019;
SE2 = 0.006693421623;
SEP2 = 0.006738525415;
W1 = sin (HBF);
W2 = 1.0-se2 * POW (W1, (double) 2);
W = sqrt (w2);
MF = sa* (1.0-SE2)/pow (W, (double) 3);
W3 = cos (HBF);
W4 = POW (SA, (double) 2) *pow (W3, (double) 2) + POW (SB, (double) 2) *pow (W1, (double) 2);
NF = Pow (SA, (double) 2)/sqrt (W4);
YNF = Y/NF;
VF = NF/MF;
tf = tan (HBF);
YF2 = Sep2 * POW (W3, (double) 2);
*b = bf-1.0/2.0 * VF * TF * (POW (YNF, (double) 2) -1.0/12.0* (5.0+3.0*pow (TF, (double) 2) +yf2-9.0*yf2*pow (TF, (double) 2)) *pow (YNF, (double) 4)) *180.0/PI;
*l = 1.0/w3*ynf* (1.0-1.0/6.0* (1.0+2.0*pow (TF, (double) 2) +yf2) *pow (YNF, (double) 2) +1.0/120.0* (5.0+28.0*pow (TF, ( Double) 2) +24.0*pow (TF, (double) 2) +6.0*yf2+8.0*yf2*pow (TF, (double) 2)) *pow (YNF, (double) 4)) *180.0/pi;
*l = L0 + *l;
}
Beijing 54 coordinate and latitude-longitude coordinate conversion algorithm C + +