//高斯投影由经纬度(Unit:DD)计算大地平面坐标(含带号,Unit:Metres) public static XYZCoordinate GaussProjCal(BLHCoordinate BLH, Datum datum, double lon) { int ProjNo, ZoneWide; ////带宽 double longitude0, X0, xval, yval; double a, e2, ee, NN, T, C, A, M, b, l, h; b = BLH.B; l = BLH.L; h = BLH.H; ZoneWide = 3; //3度带宽 a = datum.r_major; ProjNo = (int)((l - 1.5) / ZoneWide + 1); longitude0 = lon; if (Math.Abs(lon - 0) < 0.000001) { longitude0 = ProjNo * ZoneWide; //中央经线 } longitude0 = longitude0 * Math.PI / 180; l = l * Math.PI / 180; //经度转换为弧度 b = b * Math.PI / 180; //纬度转换为弧度 e2 = datum.E2; ee = e2 * (1.0 - e2); NN = a / Math.Sqrt(1.0 - e2 * Math.Sin(b) * Math.Sin(b)); T = Math.Tan(b) * Math.Tan(b); C = ee * Math.Cos(b) * Math.Cos(b); A = (l - longitude0) * Math.Cos(b); M = a * ((1 - e2 / 4 - 3 * e2 * e2 / 64 - 5 * e2 * e2 * e2 / 256) * b - (3 * e2 / 8 + 3 * e2 * e2 / 32 + 45 * e2 * e2 * e2 / 1024) * Math.Sin(2 * b) + (15 * e2 * e2 / 256 + 45 * e2 * e2 * e2 / 1024) * Math.Sin(4 * b) - (35 * e2 * e2 * e2 / 3072) * Math.Sin(6 * b)); xval = NN * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee) * A * A * A * A * A / 120); yval = M + NN * Math.Tan(b) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 + (61 - 58 * T + T * T + 600 * C - 330 * ee) * A * A * A * A * A * A / 720); //X0 = 1000000L * ProjNo + 500000L; X0 = 500000L; xval = xval + X0; return(new XYZCoordinate(xval, yval, h)); }
public static XYZCoordinate BLHToXYZ(BLHCoordinate BLH, Datum datum) { double a = datum.r_major; double b = datum.r_minor; double b1 = BLH.B * Pi / 180; double l1 = BLH.L * Pi / 180; double h1 = BLH.H; double eq = datum.E2; double N = a / Math.Sqrt(1 - eq * Math.Sin(b1) * Math.Sin(b1)); double Xq = (N + h1) * Math.Cos(b1) * Math.Cos(l1); double Yq = (N + h1) * Math.Cos(b1) * Math.Sin(l1); double Zq = ((1 - eq) * N + h1) * Math.Sin(b1); return(new XYZCoordinate(Xq, Yq, Zq)); }