- 积分
- 13192
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-11-15
- 最后登录
- 1970-1-1

|
发表于 2012-12-10 20:14:29
|
显示全部楼层
本帖最后由 luckycomcn 于 2012-12-10 20:16 编辑
自己写的兰伯特投影反解
 - /// <summary>
- /// 兰伯特投影转换为经纬投影,手动指定长半轴和短半轴
- /// </summary>
- /// <param name="LonRef">参考经度,为了方便,按照角度输入</param>
- /// <param name="LatRef">参考纬度,为了方便,按照角度输入</param>
- /// <param name="Slat">m=1时的南纬度,为了方便,按照角度输入</param>
- /// <param name="Nlat">m=1时的北纬度,为了方便,按照角度输入</param>
- /// <param name="deltaY">Y方向上的距离,以米为单位</param>
- /// <param name="deltaX">X方向上的距离,以米为单位</param>
- /// <param name="EarA">地球长半轴</param>
- /// <param name="EarB">地球短半轴</param>
- /// <returns></returns>
- public static double[] lccToLatLon(double LonRef, double LatRef, double Slat, double Nlat, double deltaY, double deltaX, double EarA, double EarB)
- {
- //这个函数参考了European Petroleum Survey Group的Coordinate Conversions and Transformations including Formulas
- double[] latAndLon = new double[2];
- double L0, B0, B1, B2, Y, X;
- double a, b, f, e; //四个变量分别是地球长半轴,地球短半轴,扁率,第一偏心率
- double mB1, mB2, tB0, tB1, tB2, n, F, r0, rd, td, Thetad, L, B, errf;
- int num;
- double pi = Math.PI; //PI,圆周率
- a = EarA; //地球长半轴
- b = EarB; //地球短半轴
- L0 = LonRef;
- B0 = LatRef;
- B1 = Slat;
- B2 = Nlat;
- Y = deltaY;
- X = deltaX;
- //各种输入经纬度转化成弧度
- L0 = L0 / 180 * pi;
- B0 = B0 / 180 * pi;
- B1 = B1 / 180 * pi;
- B2 = B2 / 180 * pi;
- f = (a - b) / a;
- e = Math.Pow((2 * f - Math.Pow(f, 2)), 0.5);
- mB1 = Math.Cos(B1) / Math.Pow((1 - Math.Pow(e, 2) * Math.Sin(B1) * Math.Sin(B1)), 0.5);
- mB2 = Math.Cos(B2) / Math.Pow((1 - Math.Pow(e, 2) * Math.Sin(B2) * Math.Sin(B2)), 0.5);
- tB0 = Math.Tan(pi / 4 - B0 / 2) / Math.Pow(((1 - e * Math.Sin(B0)) / (1 + e * Math.Sin(B0))), (e / 2));
- tB1 = Math.Tan(pi / 4 - B1 / 2) / Math.Pow(((1 - e * Math.Sin(B1)) / (1 + e * Math.Sin(B1))), (e / 2));
- tB2 = Math.Tan(pi / 4 - B2 / 2) / Math.Pow(((1 - e * Math.Sin(B2)) / (1 + e * Math.Sin(B2))), (e / 2));
- n = Math.Log(mB1 / mB2) / Math.Log(tB1 / tB2);
- F = mB1 / (n * Math.Pow(tB1, n));
- r0 = a * F * Math.Pow(tB0, n);
- rd = Math.Sign(n) * Math.Pow((Math.Pow(Y, 2) + Math.Pow((r0 - X), 2)), 0.5);
- td = Math.Pow((rd / (a * F)), (1 / n));
- Thetad = Math.Atan(Y / (r0 - X));
- L = Thetad / n + L0;
- B = B0;
- errf = 1;
- num = 0;
- while (Math.Abs(errf) > (float)(1e-8) && num < 2000)
- {
- B1 = pi / 2 - 2 * Math.Atan(td * Math.Pow(((1 - e * Math.Sin(B)) / (1 + e * Math.Sin(B))), (e / 2)));
- errf = B1 - B;
- B = B1;
- num = num + 1;
- }
- B = B * 180 / pi;
- L = L * 180 / pi;
- latAndLon[0] = L;
- latAndLon[1] = B;
- return latAndLon;
- }
|
|