经纬度转换为xy的问题,很急,谢谢!!!
INDEX TRACK NUMBER UTC DATE UTC TIME LOCAL DATE LOCAL TIME LATITUDE N/S LONGITUDE E/W ALTITUDE SPEED
1 1 2011-9-8 11:01:45 2011-9-8 19:01:45 30.69754 N 104.067535 E 493.08667 7.308
2 1 2011-9-8 11:01:46 2011-9-8 19:01:46 30.697487 N 104.06749 E 515.001465 7.524
3 1 2011-9-8 11:01:47 2011-9-8 19:01:47 30.697481 N 104.067482 E 503.61792 6.804
4 1 2011-9-8 11:01:48 2011-9-8 19:01:48 30.697474 N 104.067482 E 498.477295 4.032
5 1 2011-9-8 11:01:49 2011-9-8 19:01:49 30.697477 N 104.067482 E 499.39917 1.044
6 1 2011-9-8 11:01:50 2011-9-8 19:01:50 30.697477 N 104.067474 E 500.196045 1.908
数据里面有经度,纬度。就是 latitude 是纬度,longitude是经度。把 经纬度,转换为 xy值 。
我在网上,找了一个方法,为什么转换之后的值非常大。上百万,千万的值。大家看看我找的方法对不对?或者,你们有其他方法,麻烦给我贴出来一下,,谢谢 。。!!!
/// <summary>
/// 经纬度转换为xy坐标
/// </summary>
/// <param name="latitude">纬度</param>
/// <param name="longitude">经度</param>
/// <returns>xy数组</returns>
public static double[] GetGPSToXY(double latitude, double longitude)
{
double[] xy = {0,0 };
//-------------------输入要转换的(度.分)---------------------//
//经度(度.分)
double L = longitude;
//纬度(度.分)
double B = latitude;
//-----------------------------------------------------------//
//椭球参数
double a = 6378245.0;
double f = 1 / 298.3;
//第一偏心率
double ee = Math.Sqrt(0.00669342162297);
double E0 = 0.00673852541468;
double P0 = 0.017453292519943;
//中央子午线
double L0 = 117.07;
//转换为度
//L: ddd.ddddd
L = L / 100;
//B: dd.ddddd
B = B / 100;
//转换为弧度
double b = B * P0;
double l = (L - 117.07) * P0;
double A = 1 + 3 * (Math.Pow(ee, 2)) / 4 + 45 * (Math.Pow(ee, 4)) / 64 + 175 * (Math.Pow(ee, 6)) / 256 + 11025 * (Math.Pow(ee, 8)) / 16384 + 43659 * (Math.Pow(ee, 10)) / 65536;
double BB = 3 * (Math.Pow(ee, 2)) / 4 + 15 * (Math.Pow(ee, 4)) / 16 + 525 * (Math.Pow(ee, 6)) / 512 + 2206 * (Math.Pow(ee, 8)) / 2048 + 72765 * (Math.Pow(ee, 10)) / 65536;
double C = 15 * (Math.Pow(ee, 4)) / 64 + 105 * (Math.Pow(ee, 6)) / 256 + 2205 * (Math.Pow(ee, 8)) / 4096 + 10395 * (Math.Pow(ee, 10)) / 16384;
double D = 35 * (Math.Pow(ee, 6)) / 512 + 315 * (Math.Pow(ee, 8)) / 2048 + 31185 * (Math.Pow(ee, 10)) / 131072;
double E = 315 * (Math.Pow(ee, 8)) / 16384 + 3465 * (Math.Pow(ee, 10)) / 65536;
double F = 693 * (Math.Pow(ee, 10)) / 131072;
//大地坐标为(B,L)的点到赤道的子午线弧长
double X0 = a * (1 - (Math.Pow(ee, 2))) * (A * b - BB * (Math.Sin(4 * b)) / 4 - D * (Math.Sin(6 * b)) / 6 + E * (Math.Sin(8 * b)) / 8 - F * (Math.Sin(10 * b)) / 10);
//高斯投影正算参数
double g = (Math.Sqrt(E0)) * Math.Cos(b);
double t = Math.Tan(b);
double m0 = l * Math.Cos(b);
double N = a / (Math.Sqrt(1 - (Math.Pow(ee, 2)) * (Math.Pow((Math.Sin(b)), 2))));
double X = X0 + N * t * m0 / 2 + N * t * (5 - (Math.Pow(t, 2)) + 9 * (Math.Pow(g, 2)) + 4 * (Math.Pow(g, 4))) * (Math.Pow(m0, 4)) / 24 + N * t * (61 - 58 * (Math.Pow(t, 2)) + (Math.Pow(t, 4)) + 270 * (Math.Pow(g, 2)) - 330 * (Math.Pow(g, 2)) * (Math.Pow(t, 2))) * (Math.Pow(m0, 6)) / 720;
double Y = 500000 + N * m0 + N * (1 - (Math.Pow(t, 2)) + (Math.Pow(g, 2))) * (Math.Pow(m0, 3)) / 6 + N * (5 - 18 * (Math.Pow(t, 2)) + (Math.Pow(t, 4)) + 14 * (Math.Pow(g, 2)) - 58 * (Math.Pow(g, 2)) * (Math.Pow(t, 2))) * (Math.Pow(m0, 5)) / 120;
xy[0] = X;
xy[1] = Y;
return xy;
}
public static Tupe<double, double> GetGPSToXY(double latitude, double longitude)
{
Tupe<double, double> r = new Tupe<double, double>();
r.Item1 = (latitude - 40) * 110; //设 x 原点在 40 度。
r.Item2 = (longitude - 116) * 85; //设 y 原点在 116 度。
return r;
}