/// <summary> /// 二炮阵地方位计算中由两点的空间直角坐标求解方位角 /// </summary> /// <param name="pntA">起点空间直角坐标</param> /// <param name="pntB">末点空间直角坐标</param> /// <param name="a">参考椭球长半轴</param> /// <param name="f">参考椭球扁率倒数</param> /// <returns>两点点的大地方位角</returns> public static double Missile_XYZ_A(SpatialRectCoordinate pntA, SpatialRectCoordinate pntB, double a, double f) { double B, L, H; XYZ_BLH(pntA.X, pntA.Y, pntA.Z, out B, out L, out H, a, f); B = B * CoordConsts.PI / 180; L = L * CoordConsts.PI / 180; double Dx, Dy, Dz; Dx = pntB.X - pntA.X; Dy = pntB.Y - pntA.Y; Dz = pntB.Z - pntA.Z; double tempX, tempY; tempX = -Math.Sin(B) * Math.Cos(L) * Dx - Math.Sin(B) * Math.Sin(L) * Dy + Math.Cos(B) * Dz; tempY = -Math.Sin(L) * Dx + Math.Cos(L) * Dy; double A = Math.Atan(tempY / tempX); if (tempX > 0 && tempY < 0) { A += 2 * CoordConsts.PI; } if (tempX < 0) { A += CoordConsts.PI; } return(A * 180 / CoordConsts.PI); }
public GeoPoint(GaussCoordinate xyh, double a, double f) { try { //读取高斯平面坐标值,如果是未赋值对象则产生异常 double x = xyh.x; double y = xyh.y; ellipsoid = new ReferenceEllipsoid(a, f); gaussCoord = xyh; double B, L; Geodetic.xy_BL(x, y, out B, out L, xyh.BeltWidth, 0, ellipsoid.a, ellipsoid.f); geodeticCoord = new GeodeticCoordinate(B, L); dimension = 2; try { //如果存在高程异常和正常高,则按此式计算大地高 double h = xyh.h; if (!dHlIsNull) { geodeticCoord.H = h + dH; double X, Y, Z; Geodetic.BLH_XYZ(B, L, h + dH, out X, out Y, out Z, ellipsoid.a, ellipsoid.f); spatialCoord = new SpatialRectCoordinate(X, Y, Z); dimension = 3; } } catch { } } catch { } }
public GeoPoint(SpatialRectCoordinate XYZ, double a, double f) { try { //读取空间直角坐标值,如果未赋值则产生异常 double X = XYZ.X; double Y = XYZ.Y; double Z = XYZ.Z; ellipsoid = new ReferenceEllipsoid(a, f); spatialCoord = XYZ; double B, L, H; Geodetic.XYZ_BLH(X, Y, Z, out B, out L, out H, ellipsoid.a, ellipsoid.f); geodeticCoord = new GeodeticCoordinate(B, L, H); double x, y; Geodetic.BL_xy(geodeticCoord.B, geodeticCoord.L, out x, out y, ellipsoid.a, ellipsoid.f); gaussCoord = new GaussCoordinate(x, y); if (!dHlIsNull) { gaussCoord.h = H - dH; } dimension = 3; } catch { } }
public GeoPoint(GeodeticCoordinate BLH, double a, double f) { try { //获取大地坐标,如果赋的值是空对象则会产生异常 double B = BLH.B; double L = BLH.L; geodeticCoord = BLH; ellipsoid = new ReferenceEllipsoid(a, f); double x, y; Geodetic.BL_xy(B, L, out x, out y, ellipsoid.a, ellipsoid.f); gaussCoord = new GaussCoordinate(x, y); dimension = 2; try { //获取大地高,如果没有大地高,则产生异常,只取二维坐标 double H = BLH.H; double X, Y, Z; Geodetic.BLH_XYZ(B, L, H, out X, out Y, out Z, ellipsoid.a, ellipsoid.f); spatialCoord = new SpatialRectCoordinate(X, Y, Z); dimension = 3; } catch { } } catch { } }
public GeoPoint(double B, double L, double H, double a, double f) : this(B, L, a, f) { geodeticCoord = new GeodeticCoordinate(B, L, H); double X, Y, Z; Geodetic.BLH_XYZ(B, L, H, out X, out Y, out Z, ellipsoid.a, ellipsoid.f); spatialCoord = new SpatialRectCoordinate(X, Y, Z); dimension = 3; }
/// <summary> /// 坐标转换 /// </summary> /// <param name="xyzOld">旧坐标</param> /// <param name="xyzNew">新坐标</param> /// <param name="param">转换参数</param> public static void CoordinateTransform(double[] xyzOld, double[] xyzNew, TransformParameters param) { if (xyzNew.Length != 3 || xyzOld.Length != 3) { throw new Exception("坐标维数错误,必须为3"); } SpatialRectCoordinate p1 = new SpatialRectCoordinate(xyzOld[0], xyzOld[1], xyzOld[2]); SpatialRectCoordinate p2 = CoordinateTransform(p1, param); xyzNew[0] = p2.X; xyzNew[1] = p2.Y; xyzNew[2] = p2.Z; }
/// <summary> /// 布尔莎七参数模型坐标转换,从大地坐标到大地坐标 /// </summary> /// <param name="pntBLH"></param> /// <param name="eOld"></param> /// <param name="eNew"></param> /// <param name="param"></param> /// <returns></returns> public static GeodeticCoordinate CoordinateTransform(GeodeticCoordinate pntBLH, ReferenceEllipsoid eOld, ReferenceEllipsoid eNew, TransformParameters param) { double X, Y, Z; BLH_XYZ(pntBLH.B, pntBLH.L, pntBLH.H, out X, out Y, out Z, eOld.a, eOld.f); SpatialRectCoordinate s = CoordinateTransform(new SpatialRectCoordinate(X, Y, Z), param); double B, L, H; XYZ_BLH(s.X, s.Y, s.Z, out B, out L, out H, eNew.a, eNew.f); return(new GeodeticCoordinate(B, L, H)); }
/// <summary> /// 添加 /// </summary> /// <param name="XYZ"></param> public void Add(SpatialRectCoordinate XYZ) { GeoPoint point = new GeoPoint(XYZ); this.Add(point); }
public GeoPoint(SpatialRectCoordinate XYZ) : this(XYZ, Default_a, Default_f) { }
public GeoPoint(SpatialRectCoordinate XYZ, ReferenceEllipsoid e) : this(XYZ, e.a, e.f) { }