Coordinate of the screen for latitude and longitude Conversion

Source: Internet
Author: User

Package com. hhwy. WebGIS. Map. util;
Import java. util .*;
Public class projecttranslate {

 
 
 
 
/* ----------------- Calculate the Inverse calculation factor of coordinates -----------------*/
// Fdao input-flat rate reciprocal
// Input a-elliptical radius, in meters
// K0, K1, K2, and K3 are Inverse Calculation factors.
Private void computeblfactor (double A, double fdao, Double K [])
{
Double E;
Double F;
Double B;

Double A1;
Double B1;
Double C1;
Double D1;
Double E1;
Double F1;

Double fa;
Double FB;
Double FC;
Double FD;
Double Fe;
Double FG;

Double FC1, FC2, FC3, FC4, Fb1, fb2, fb3, fb4, fd1, fd2, FD3, fd4;

F = 1/fdao;
B = A-A * F;
E = math. SQRT (A * A-B * B)/;

A1 = 1 + math. pow (E, 2) * 3/4 + math. pow (E, 4) * 45/64 + math. pow (E, 6) * 175/256 + math. pow (E, 8) * 11025/16384 + math. pow (E, 10) * 43659/65536;

B1 = math. pow (E, 2) * 3/4 + math. pow (E, 4) * 15/16 + math. pow (E, 6) * 525/512 + math. pow (E, 8) * 2205/2048 + math. pow (E, 10) * 72765/65536;

C1 = math. pow (E, 4) * 15/64 + math. pow (E, 6) * 105/256 + math. pow (E, 8) * 2205/4096 + math. pow (E, 10) * 10395/16384;

D1 = math. Pow (E, 6) * 35/512 + math. Pow (E, 8) * 315/2048 + math. Pow (E, 10) * 31185/13072;

E1 = math. Pow (E, 8) * 315/16384 + math. Pow (E, 10) * 3465/65536;

F1 = math. Pow (E, 10) * 693/13072;

Fa = A1 * a * (1-E * E );
Fb =-B1 * a * (1-E * E)/2;
Fc = C1 * a * (1-E * E)/4;
FD =-D1 * a * (1-E * E)/6;
Fe = e1 * a * (1-E * E)/8;
Fg =-F1 * a * (1-E * E)/10;

Fb1 =-FB/FA; FC1 =-FC/FA; fd1 =-FD/FA;

Fb2 = Fb1 + Fb1 * FC1-3.0/2.0 * Fb1 * Math. Pow (Fb1, 2)-2 * FC1 * Fb1;
FC2 = FC1 + Fb1 * Fb1;
Fd2 = fd1 + Fb1 * FC1 + 1.0/2.0 * Fb1 * Math. Pow (Fb1, 2) + 2 * FC1 * Fb1;

Fb3 = Fb1 + Fb1 * FC2-3.0/2.0 * Fb1 * Math. Pow (fb2, 2)-2 * FC1 * fb2;
FC3 = FC1 + Fb1 * fb2;
FD3 = fd1 + Fb1 * FC2 + 1.0/2.0 * Fb1 * Math. Pow (fb2, 2) + 2 * FC1 * fb2;

Fb4 = Fb1 + Fb1 * FC3-3.0/2.0 * Fb1 * Math. Pow (fb3, 2)-2 * FC1 * fb3;
FC4 = FC1 + Fb1 * fb3;
Fd4 = fd1 + Fb1 * fc3+ 1.0/2.0 * Fb1 * Math. Pow (fb3, 2) + 2 * FC1 * fb3;

K [0] = 1.0/FA;
K [1] = (fb4*2 + FC4 * 4 + fd4 * 6 );
K [2] = (FC4*8 + fd4 * 32 );
K [3] = fd4 * 32;
}


/* ----------------- Calculate the coordinate positive calculation factor -----------------*/
// Fdao input-flat rate reciprocal
// Input a-elliptical radius, in meters
// C0, C1, C2, and C3 are the Inverse Calculation factors.
Private void computefactor (double A, double fdao, double C [])
{
Double E;
Double F;
Double B;

Double A11;
Double B11;
Double C11;
Double D11;
Double E11;
Double F11;

Double fa;
Double FB;
Double FC;
Double FD;
Double Fe;
Double FG;

F = 1/fdao;
B = A-A * F;
E = math. SQRT (A * A-B * B)/;
A11 = 1 + math. pow (E, 2) * 3/4 + math. pow (E, 4) * 45/64 + math. pow (E, 6) * 175/256 + math. pow (E, 8) * 11025/16384 + math. pow (E, 10) * 43659/65536;

B11 = math. pow (E, 2) * 3/4 + math. pow (E, 4) * 15/16 + math. pow (E, 6) * 525/512 + math. pow (E, 8) * 2205/2048 + math. pow (E, 10) * 72765/65536;

C11 = math. pow (E, 4) * 15/64 + math. pow (E, 6) * 105/256 + math. pow (E, 8) * 2205/4096 + math. pow (E, 10) * 10395/16384;

D11 = math. Pow (E, 6) * 35/512 + math. Pow (E, 8) * 315/2048 + math. Pow (E, 10) * 31185/13072;

E11 = math. Pow (E, 8) * 315/16384 + math. Pow (E, 10) * 3465/65536;

F11 = math. Pow (E, 10) * 693/13072;

Fa = A11 * a * (1-E * E );
Fb =-B11 * a * (1-E * E)/2;
Fc = C11 * a * (1-E * E)/4;
FD =-D11 * a * (1-E * E)/6;
Fe = E11 * a * (1-E * E)/8;
Fg =-F11 * a * (1-E * E)/10;

C [0] = fa;
C [1] =-(FB * 2 + FC * 4 + FD * 6 );
C [2] = (FC * 8 + FD * 32 );
C [3] =-FD * 32;
/*************************************** *******
54 coordinate system computation result have difference from
The known value; but I don't find fault.
Known: CO 6367558.49686
C1 1, 32005.79642
C2. 133.86115
C3 1, 0.7031
Compute:
Co 1, 6367558.4968746
C1 1, 32005.780305529
C2. 133.9203503
C3 1, 0.7041
**************************************** *************************/
}
/*-----------------------------------------------------------*/
// Lon input-longitude, lat input-latitude, unit degree
// X output -- plane coordinate X value, y output -- plane coordinate Y value, in meters
// L0 input-Central meridian, Unit
// Fdao input-flat rate reciprocal
// Input a-elliptical radius, in meters
Public void guassbltoxy (double Lon, double Lat, double coordxy [], float l0, double fdao, float)
{
Double T, ita2, N, M0, L;
Double temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
Double Pi = math. Pi;
Double F;
Double B;
Double E2;
Double E12;
Double P2 = 3600.0*180.0/PI;
Double p0 = PI/180.0;
/* 54 coordonation kelasuofusiji */
// Double C0 = 6367558.49686;
// Double C1 = 32005.79642;
// Double C2 = 133.86115;
// Double C3 = 0.7031;
Double C0, C1, C2, C3;

C0 = C1 = C2 = C3 = 0;
Double [] C = new double [4];

Computefactor (A, fdao, C );
C0 = C [0];
C1 = C [1];
C2 = C [2];
C3 = C [3];
Double temp1, temp2, temp3, temp4, temp5;

F = 1/fdao;
B = A-A * F;
E2 = (A * A-B * B)/(A * );
E12 = e2/(1-E2 );
/* Gpolicansform */
L = (Lon-l0) * 3600;
T = math. Tan (LAT * P0 );
Temp1 = T * t;

Ita2 = E12 * Math. Cos (LAT * P0) * Math. Cos (LAT * P0 );
Temp2 = ita2 * ita2;

N = A/Math. SQRT (1-e2 * Math. Sin (LAT * P0) * Math. Sin (LAT * P0 ));
M0 = L * Math. Cos (LAT * P0)/P2;
Temp3 = M0 * M0;
Temp4 = temp3 * temp3;

Temp1 = N * M0;
Temp2 = C0 * lat * P0;

Temp5 = math. Sin (LAT * P0) * Math. Sin (LAT * P0 );
Temp3 = math. Cos (LAT * P0) * Math. Sin (LAT * P0) * (C1 + C2 * temp5
+ C3 * temp5 * temp5 );
Temp4 = 1.0/2.0 * n * T * temp3;
Temp5 = 1/24.0*(5.0-(temp1 * temp1) + 9 * ita2 + 4*(temp2 * temp2) * n * T * temp4;
Temp6 = 1/720*(61-58 * temp1 + (temp1 * temp1) * n * T * (temp3 * temp4 );
Temp7 = 1/6.0*(1-temp1 + ita2) * n * (M0 * temp3 );
Temp8 = 1/120.0*(5-18 * temp1 + (temp1 * temp1) + 14 * temp2-58 * ita2 * temp1) * n * (M0 * temp4 );

Coordxy [0] = temp2-temp3 + temp4 + temp5 + temp6;
Coordxy [1] = temp1 + temp7 + temp8 + 500000;

}
/*-----------------------------------------------------------*/
// Lon input-longitude, lat input-latitude, unit degree
// X output -- plane coordinate X value, y output -- plane coordinate Y value, in meters
// L0 input-Central meridian, Unit
// Fdao input-flat rate reciprocal
// Input a-elliptical radius, in meters

Public void guassxytobl (double [] coordbl, double X, Double Y, double l0, double fdao, double)
{
Double K0, K1, K2, K3;

Double F, B;

Double E2, E12;
Double Pi = math. Pi;
K0 = k1 = k2 = K3 = 0;
Double [] K = new double [4];
Computeblfactor (A, fdao, k );
K0 = K [0];
K1 = K [1];
K2 = K [2];
K3 = K [3];
Y-= 500000.00;
F = 1/fdao;
B = A-A * F;
E2 = (A * A-B * B)/(A * );
E12 = e2/(1-E2 );

Double p0 = 180.0/PI;
Double P2 = 3600.0*180.0/PI;
Double p0 = PI/180.0;

Double b0f = K0 * x * P0;
Double sinb0f = math. Sin (b0f * P0 );
Double sinb0f2 = math. Sin (b0f * P0) * Math. Sin (b0f * P0 );
Double temp1 = P0 * (math. Cos (b0f * P0) * sinb0f * (K1-K2 * sinb0f2 + K3 * sinb0f2 * sinb0f2 );
Double BF = b0f + temp1;

Double T = math. Tan (Bf * P0 );
Double t2 = T * t;
Double ita2 = E12 * Math. Cos (Bf * P0) * Math. Cos (Bf * P0 );
Double v2 = 1.0 + ita2;
Double N = A/Math. SQRT (1.0-e2 * Math. Sin (Bf * P0) * Math. Sin (Bf * P0 ));
Double YN = y/N;
Double yn2 = YN * YN;

Double temp2 = P2 * (-0.5) * V2 * T * yn2;
Double temp3 = P2 * 1.0/24.0*(5.0 + 3.0 * t2 + ita2-9.0 * ita2 * t2) * V2 * T * yn2 * yn2;
Double temp4 = P2 * (-1.0)/720.0*(61.0 + 90.0 * t2 + 45.0 * t2 * t2) * V2 * yn2 * yn2 * yn2;

Double temp5 = 1.0/Math. Cos (Bf * P0) * YN * P2;
Double temp6 = P2 * (-1.0)/6.0*(1.0 + 2.0 * t2 + ita2) * (1.0/Math. Cos (Bf * P0) * YN * yn2;
Double temp7 = P2 * 1.0/120.0*(5.0 + 28.0 * t2 + 24.0 * t2 * t2 + 6.0 * ita2 + 8.0 * ita2 * t2)
* (1.0/Math. Cos (BF) * yn2 * yn2 * YN;

Coordbl [0] = BF + (temp2 + temp3 + temp4)/3600.0;
Coordbl [1] = l0 + (temp5 + temp6 + temp7)/3600.0;

}

Public static void main (string ARGs [])
{
Projecttranslate Pt = new projecttranslate ();
Double [] coordxy = new double [2];

PT. guassbltoxy (117.1, 39, coordxy, 117,298.3, 6378245 );
System. Out. println ("= coordx =" + coordxy [0] + "= coordy =" + coordxy [1]);

}


}
 

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.