Handy:
private void ToGeographic(ref double x, ref double y)
{
if (Math.Abs(x) < 180 && Math.Abs(y) < 90)
return;
if ((Math.Abs(x) > 20037508.3427892) || (Math.Abs(y) > 20037508.3427892))
return;
double x = x;
double y = y;
double num3 = x / 6378137.0;
double num4 = num3 * 57.295779513082323;
double num5 = Math.Floor((double)((num4 + 180.0) / 360.0));
double num6 = num4 - (num5 * 360.0);
double num7 = 1.5707963267948966 - (2.0 * Math.Atan(Math.Exp((-1.0 * y) / 6378137.0)));
x= num6;
y= num7 * 57.295779513082323;
}
private void ToWebMercator(ref double lon, ref double lat)
{
if ((Math.Abs(lon) > 180 || Math.Abs(lat) > 90))
return;
double num = lon* 0.017453292519943295;
double x = 6378137.0 * num;
double a = lat* 0.017453292519943295;
lon= x;
lat= 3189068.5 * Math.Log((1.0 + Math.Sin(a)) / (1.0 - Math.Sin(a)));
}
No comments:
Post a Comment