using DPP_YH_Core.Extensions; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using XdCxRhDW.Dto; namespace XdCxRhDW.Api { /// /// 误差椭圆帮助类 /// public static class ErrEllipseHepler { private const string ErrellipDll = @"AddIns\GDOP误差椭圆\DLL_GDOP_Analysis0415"; /// /// 两星一地误差椭圆 /// /// 主星位置 长度6 /// 邻星位置 长度6 /// 超短波 长度3 /// 参考站 长度3 /// 定位点 长度3 /// 时差误差(s) /// /// 0.5 /// /// [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)] private extern static IntPtr Error_Ellipse_2X1D(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] refStation, double[] Select_Point, double dto_err, double eph_err, double Pe, ref int LOP_Len); /// /// 两星一地误差椭圆 /// /// 主星位置 长度6 /// 邻星位置 长度6 /// 超短波 长度3 /// 参考站 长度3 /// 定位点 长度3 /// 时差误差(s) /// /// 0.5 /// /// [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D_NoRef", CallingConvention = CallingConvention.Cdecl)] private extern static IntPtr Error_Ellipse_2X1D_NoRef(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] Select_Point, double dto_err, double eph_err, double Pe, ref int LOP_Len); /// /// 获取误差椭圆的长轴(m)、短轴(m)、倾角(°) /// /// /// /// /// /// /// /// /// /// /// public static ErrEllipseResDto ErrorEllipse2X1D(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double[] RefGeod, double DtoErrus, double EphErrm, bool outputErrPoint) { //IEnumerable res = new List(); int LOP_Len = 0; double Pe = 0.5; IntPtr LOP_ValuePtr = Error_Ellipse_2X1D( mainEph, adajEph, cdbPos, RefGeod, new double[3] { posLon, posLat, 0 }, DtoErrus * 1e-6, EphErrm,//单位m Pe, ref LOP_Len); double[] LOP_Value = new double[LOP_Len]; if (LOP_Len > 0) { Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length); } ErrEllipseResDto res = new ErrEllipseResDto(); res.LongRadius = LOP_Value[LOP_Value.Length - 3]; res.ShortRadius = LOP_Value[LOP_Value.Length - 2]; res.DipAngle = LOP_Value[LOP_Value.Length - 1]; if (outputErrPoint) { int count = LOP_Value.Length - 3; for (int i = 0; i < count; i += 2)//13 ---01 23 45 67 89 { res.GeoPoints.Add(new GeoPoint() { Lon = LOP_Value[i], Lat = LOP_Value[i + 1], }); } } return res; } /// /// 获取误差椭圆的长轴(m)、短轴(m)、倾角(°) /// /// /// /// /// /// /// /// /// /// public static ErrEllipseResDto ErrorEllipse2X1DNoRef(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double DtoErrus, double EphErrm, bool outputErrPoint) { //IEnumerable res = new List(); int LOP_Len = 0; double Pe = 0.5; IntPtr LOP_ValuePtr = Error_Ellipse_2X1D_NoRef( mainEph, adajEph, cdbPos, new double[3] { posLon, posLat, 0 }, DtoErrus * 1e-6, EphErrm,//单位m Pe, ref LOP_Len); double[] LOP_Value = new double[LOP_Len]; if (LOP_Len > 0) { Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length); } ErrEllipseResDto res = new ErrEllipseResDto(); res.LongRadius = LOP_Value[LOP_Value.Length - 3]; res.ShortRadius = LOP_Value[LOP_Value.Length - 2]; res.DipAngle = LOP_Value[LOP_Value.Length - 1]; if (outputErrPoint) { int count = LOP_Value.Length - 3; for (int i = 0; i < count; i += 2)//13 ---01 23 45 67 89 { res.GeoPoints.Add(new GeoPoint() { Lon = LOP_Value[i], Lat = LOP_Value[i + 1], }); } } return res; } } }