/// <summary> /// 将空间直角坐标转换为大地坐标 /// </summary> /// <param name="gXYZ">空间直角坐标</param> /// <returns>大地坐标</returns> private GeoBLH ConvertXYZToBLH(GeoXYZ gXYZ) { double l = Math.Atan2(gXYZ.gY, gXYZ.gX); l = l > 0 ? l : 2 * Math.PI + l; double tanB0 = gXYZ.gZ / Math.Sqrt(gXYZ.gX * gXYZ.gX + gXYZ.gY * gXYZ.gY); double tanB = 0; do { tanB = (gXYZ.gZ + re.a * re.firste2 * tanB0 / Math.Sqrt(1 + tanB0 * tanB0 - re.firste2 * tanB0 * tanB0)) / Math.Sqrt(gXYZ.gX * gXYZ.gX + gXYZ.gY * gXYZ.gY); double temp = tanB0; tanB0 = tanB; tanB = temp; }while (Math.Abs(tanB - tanB0) > 1.0e-11); double _B = Math.Atan(tanB) * Angle.Rou; double _L = l * Angle.Rou; double n = GeodeticCalculate.UnitaryCircleRadius(re, _B); double _H = Math.Sqrt(gXYZ.gX * gXYZ.gX + gXYZ.gY * gXYZ.gY) / Math.Cos(_B / Angle.Rou) - n; return(new GeoBLH(_B, _L, _H)); }
public GeodeticPoint(ReferenceEllipsoid refEll, GeoCoordinateType geoType, params string[] data) { re = refEll; GeoXYZ gXYZ = new GeoXYZ(0, 0, 0); GeoBLH gBLH = new GeoBLH(0, 0, 0); GeoxyH gxyH = new GeoxyH(0, 0, 0); switch (geoType) { case GeoCoordinateType.XYZ: if (data.Length != 3) { break; } else { gXYZ = new GeoXYZ(data[0], data[1], data[2]); gBLH = ConvertXYZToBLH(gXYZ); gxyH = ConvertBLHToxyH(gBLH); } break; case GeoCoordinateType.BLH: if (data.Length == 2) { gBLH = new GeoBLH(data[0], data[1]); gXYZ = ConvertBLHToXYZ(gBLH); gxyH = ConvertBLHToxyH(gBLH); } else if (data.Length == 3) { gBLH = new GeoBLH(data[0], data[1], data[2]); gXYZ = ConvertBLHToXYZ(gBLH); gxyH = ConvertBLHToxyH(gBLH); } else { break; } break; default: if (data.Length == 2) { gxyH = new GeoxyH(data[0], data[1]); gBLH = ConvertxyHToBLH(gxyH); gXYZ = ConvertBLHToXYZ(gBLH); } else if (data.Length == 3) { gxyH = new GeoxyH(data[0], data[1], data[3]); gBLH = ConvertxyHToBLH(gxyH); gXYZ = ConvertBLHToXYZ(gBLH); } else { break; } break; } gX = gXYZ.gX; gY = gXYZ.gY; gZ = gXYZ.gZ; gB = gBLH.gB; gL = gBLH.gL; gH = gBLH.gH; gx = gxyH.gx; gy = gxyH.gy; }