using DevExpress.Charts.Native; using DevExpress.Internal.WinApi.Windows.UI.Notifications; using DevExpress.XtraPrinting; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using XdDw.App.Api.时差线; using XdDw.App.DTO; using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock; namespace XdDw.App.Api.低轨GDOP误差椭圆 { public class ErrorEllipseDTFOTSOption { /// /// 主星星历 /// public double[] MsEph { get; set; } /// /// 邻星星历 /// public double[] NsEph { get; set; } /// /// 参考站位置 /// public double[] RefGeod { get; set; } /// /// 定位点 /// public double[] SelectPoint { get; set; } /// /// 时差误差(s) /// public double DtoErr { get; set; } /// /// 频差误差(Hz) /// public double DfoErr { get; set; } /// /// 星历位置误差 /// public double EphPosErr { get; set; } /// ///星历速度误差 /// public double EphVelErr { get; set; } /// /// 上行频点1(Hz) /// public double fu1 { get; set; } /// /// 上行频点2(Hz) /// public double fu2 { get; set; } /// /// 概率 默认0.5 /// public double Pe { get; set; } = 0.5; } public class ErrorEllipseDTO2X1DOption { /// /// 主星星历 /// public double[] MsEph { get; set; } /// /// 邻星星历 /// public double[] NsEph { get; set; } /// /// 超短波位置 /// public double[] CDBAnt { get; set; } /// /// 参考站位置 /// public double[] RefGeod { get; set; } /// /// 定位点 /// public double[] SelectPoint { get; set; } /// /// 时差误差(s) /// public double DtoErr { get; set; } /// /// 星历误差 /// public double EphErr { get; set; } /// /// 概率 默认0.5 /// public double Pe { get; set; } = 0.5; } public class ErrorEllipseDTO1XOption { /// /// 第一时刻星历 /// public double[] MsEph { get; set; } /// ///第二时刻星历 /// public double[] NsEph1 { get; set; } /// /// 第三时刻星历 /// public double[] NsEph2 { get; set; } /// /// 定位点 /// public double[] SelectPoint { get; set; } /// /// 频差误差(Hz) /// public double DfoErr { get; set; } /// /// 星历位置误差 /// public double EphPosErr { get; set; } /// ///星历速度误差 /// public double EphVelErr { get; set; } /// /// 上行频点(Hz) /// public double fu { get; set; } /// /// 概率 默认0.5 /// public double Pe { get; set; } = 0.5; } public static class ErrEllipseHelper { private const string GDOPDll = @"Api\低轨GDOP误差椭圆\GDOP\DLL_GD64.dll"; /// /// 两星一地误差椭圆 /// /// 主星位置 长度6 /// 邻星位置 长度6 /// 超短波 长度3 /// 参考站 长度3 /// 定位点 长度3 /// 时差误差(s) /// /// 0.5 /// /// [DllImport(GDOPDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)] public 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); [DllImport(GDOPDll, CallingConvention = CallingConvention.Cdecl)] public static extern void freeBuff(IntPtr buf); public static IEnumerable<(double lon, double lat)> ErrorEllipse2X1D(ErrorEllipseDTO2X1DOption opt) { int LOP_Len = 0; IntPtr LOP_ValuePtr = Error_Ellipse_2X1D( opt.MsEph, opt.NsEph, opt.CDBAnt, opt.RefGeod, opt.SelectPoint, opt.DtoErr, opt.EphErr, opt.Pe, ref LOP_Len); return ParseResult(LOP_ValuePtr, LOP_Len); } private static IEnumerable<(double lon, double lat)> ParseResult(IntPtr LOP_ValuePtr, int LOP_Len) { List list = new List(); double[] LOP_Value = new double[LOP_Len]; if (LOP_Len > 0) { Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length); int len = LOP_Len / 2; for (int i = 0; i < len; i++) { int temp = i * 2; list.Add(new DtoLinePoint() { Lon = LOP_Value[temp], Lat = LOP_Value[temp + 1] }); } } var Lines = list.Select(p => (p.Lon, p.Lat)); return Lines; } } }