#region//latitude and longitude transfer of Mercator
static double m_pi = Math.PI;
Transfer of Mercator by latitude
Longitude (Lon), Latitude (LAT)
Public double[] Lonlat2mercator (double lat, double lon)
{
double[] xy = new DOUBLE[2];
Double x = Lon *20037508.342789/180;
Double y = Math.Log (Math.tan (90+lat) *m_pi/360))/(m_pi/180);
y = y *20037508.34789/180;
Xy[0] = x;
Xy[1] = y;
return XY;
}
Mercator Transfer latitude
Public double[] Mercator2lonlat (double mercatorx,double mercatory)
{
double[] xy = new DOUBLE[2];
Double x = mercatorx/20037508.34*180;
Double y = mercatory/20037508.34*180;
Y= 180/m_pi* (2*math.atan (Math.exp (y*m_pi/180))-M_PI/2);
Xy[0] = x;
Xy[1] = y;
return XY;
}
#endregion
#region latitude and longitude transfer geodetic coordinates
Double pi = Math.PI;
Double sm_a = 6378137.0;
Double sm_b = 6356752.314;
Double utmscalefactor = 0.9996;
Public double[] LATLONTOUTM (double lat, double lon)
{
Double zone = Math.floor ((lon + 180.0)/6) + 1;
Double cm = Utmcentralmeridian (zone);
double[] xy = new DOUBLE[2];
Maplatlontoxy (lat/180.0 * pi, lon/180 * pi, CM, out xy);
/* Adjust easting and northing for UTM system. */
Xy[0] = xy[0] * utmscalefactor + 500000.0;
if (Lon > 120.0)
{
Xy[0] + + 530000;
}
XY[1] = xy[1] * utmscalefactor;
if (Xy[1] < 0.0)
{
XY[1] = xy[1] + 10000000.0;
}
return new double[] {xy[0], xy[1], zone};
}
Public double Utmcentralmeridian (double zone)
{
Double Cmeridian;
Double deg = -183.0 + (Zone * 6.0);
Cmeridian = deg/180.0 * PI;
return Cmeridian;
}
internal void Maplatlontoxy (double phi, double lambda, double lambda0, out double[] xy)
{
Double N, nu2, EP2, T, T2, L;
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.