浏览代码

添加单星频差线

wyq 1 年之前
父节点
当前提交
4f03e3a3ad

+ 1 - 1
XzXdDw.App/Api/PosApi.cs

@@ -100,7 +100,7 @@ namespace XzXdDw.App.Api
         /// <param name="LOP_Len"></param>
         [DllImport(gzdw, EntryPoint = "SingleStar_PCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
         public extern static void SingleStar_PCX(double[] main_sat, double[] neigh_sat
-            , double[] Zone, double target_dfo, double fu, IntPtr LOP_Value, int[] LOP_Len);
+            , double[] Zone, double target_dfo, double fu,out IntPtr LOP_Value,ref int LOP_Len);
 
 
         private const string XdtsDll = @"Api\时差线\Positioning.dll";

+ 11 - 6
XzXdDw.App/Api/时差线/DrawDtoLineHelper.cs

@@ -60,7 +60,7 @@ namespace XdCxRhDW.App.Api.时差线
          */
         #endregion
         private const string exeName = "XingDiSCX.exe";
-
+        private static double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
         public static IEnumerable<(double lon, double lat)> DtoLineXd(DtoLineXdOption opt)
         {
             List<DtoLinePoint> list = new List<DtoLinePoint>();
@@ -135,7 +135,7 @@ namespace XdCxRhDW.App.Api.时差线
             List<DtoLinePoint> list = new List<DtoLinePoint>();
             IntPtr LOP_ValuePtr;
             int LOP_Len = 0;
-            double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
+
 
             PosApi.CurveByTwoTDOA(
                 opt.MsEph,
@@ -166,7 +166,6 @@ namespace XdCxRhDW.App.Api.时差线
             List<DtoLinePoint> list = new List<DtoLinePoint>();
             IntPtr LOP_ValuePtr;
             int LOP_Len = 0;
-            double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
 
             PosApi.TwoStar_SCX(
                 opt.MsEph,
@@ -189,11 +188,8 @@ namespace XdCxRhDW.App.Api.时差线
         public static IEnumerable<(double lon, double lat)> DfoLineXZTwoStart(DfoLineTwoStartOption opt)
         {
 
-            List<DtoLinePoint> list = new List<DtoLinePoint>();
             IntPtr LOP_ValuePtr;
             int LOP_Len = 0;
-            double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
-
             PosApi.TwoStar_PCX(
                 opt.MsEph,
                  opt.NsEph,
@@ -206,6 +202,15 @@ namespace XdCxRhDW.App.Api.时差线
             return ParseResult(LOP_ValuePtr, LOP_Len);
         }
 
+        public static IEnumerable<(double lon, double lat)> DfoLineSingleStart(double[] main_sat, double[] neigh_sat, double target_dfo, double fu)
+        {
+            IntPtr LOP_ValuePtr;
+            int LOP_Len = 0;
+            PosApi.SingleStar_PCX(main_sat, neigh_sat
+            , zone, target_dfo, fu, out LOP_ValuePtr, ref LOP_Len);
+            return ParseResult(LOP_ValuePtr, LOP_Len);
+        }
+
         private static IEnumerable<(double lon, double lat)> ParseResult(IntPtr LOP_ValuePtr, int LOP_Len)
         {
             List<DtoLinePoint> list = new List<DtoLinePoint>();

+ 74 - 7
XzXdDw.App/UserControl/CtrlPosSingle.cs

@@ -84,7 +84,9 @@ namespace XzXdDw.App.UserControl
                         }
                     })
                     .AddMenu("加载仿真数据", SvgHelper.LoadFromFile("Image\\LoadData.svg"), LoadTestData)
+                      .AddMenu("绘制频差线", SvgHelper.LoadFromFile("Image\\DfoLine.svg"), DrawDfoLine)
                     .AddMenu("绘制误差椭圆", SvgHelper.LoadFromFile("Image\\误差椭圆.svg"), DrawErrorEllipse1X)
+
                     .AddMenu("停止加载", SvgHelper.LoadFromFile("Image\\Stop.svg"), () => stoped = true);
 
 
@@ -228,14 +230,19 @@ namespace XzXdDw.App.UserControl
                 var satNTx = listTx.Find(p => p.TxType == EnumTxType.AdjaSat);
                 var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
                 var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
+#warning 但凡是和频差相关的 星历必须给速度
+                double[] main_eph = new double[6] { -1608409.905, 5994264.071, 3139843.443, -6633.016931, -374.023436, -2678.1580461 };
+
+                double[] main_eph1 = new double[6] { -3479298.029, 5612482.078, 2187911.486, -5784.105325, -2163.505176, -3632.855383 };
+                double[] main_eph2 = new double[6] { -5018677.726, 4714449.429, 1001437.615, -4399.327638, -3780.398104, -4206.338078 };
                 XzXdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO1XOption Option = new XzXdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO1XOption();
-                Option.MsEph = new double[] { cg.MainX, cg.MainY, cg.MainZ, 0, 0, 0 };
-                Option.NsEph1 = new double[] { cg.AdjaX, cg.AdjaY, cg.AdjaZ, 0, 0, 0 };
-                Option.NsEph2 = new double[] { cdbTx.Lon, cdbTx.Lat, 0 };
-                Option.SelectPoint = new double[3] { item.PosLon, item.PosLat, 0 };
-                Option.DfoErr = 1;
-                Option.EphPosErr = 1;
-                Option.EphVelErr = 1;
+                Option.MsEph = main_eph;
+                Option.NsEph1 = main_eph1;
+                Option.NsEph2 = main_eph2;
+                Option.SelectPoint =new double[2] { -180, -85}; ;//new double[3] { item.PosLon, item.PosLat, 0 };
+                Option.DfoErr = 0.01; ;
+                Option.EphPosErr = 1.0e3;
+                Option.EphVelErr = 0.1;
                 Option.fu = 3.1085e8;
                 var points = XzXdDw.App.Api.低轨GDOP误差椭圆.ErrEllipseHelper.ErrorEllipseSingleX(Option);
                 mapControl1.DrawDtoPonit($"单星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat}]误差椭圆线", points);
@@ -247,6 +254,66 @@ namespace XzXdDw.App.UserControl
                 XtraMessageBox.Show($"绘制误差椭圆线失败,失败信息:{ex.Message}");
             }
         }
+
+        private async void DrawDfoLine()
+        {
+            try
+            {
+
+                var ids = gridView1.GetSelectedRows();
+                if (ids.Length <= 0)
+                {
+                    XtraMessageBox.Show("请选择需要绘制频差线的定位数据信息!");
+                    return;
+                }
+                var item = gridView1.GetRow(ids[0]) as PosRes;
+                List<TxInfo> listTx = new List<TxInfo>();
+                List<Model.SatInfo> listSat = new List<Model.SatInfo>();
+                CgRes cg;
+                using (RHDWContext db = new RHDWContext())
+                {
+                    listTx = db.TxInfos.ToList();
+                    listSat = db.SatInfos.ToList();
+                    cg = await db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefaultAsync();
+
+                }
+                if (cg == null)
+                {
+                    XtraMessageBox.Show($"未找到定位相关的计算[{item.CgResID}]信息");
+                    return;
+                }
+                var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
+                double[] main_eph = new double[6] { -1608409.905, 5994264.071, 3139843.443, -6633.016931, -374.023436, -2678.1580461 };
+
+                double[] main_eph1 = new double[6] { -3479298.029, 5612482.078, 2187911.486, -5784.105325, -2163.505176, -3632.855383 };
+                double[] main_eph2 = new double[6] { -5018677.726, 4714449.429, 1001437.615, -4399.327638, -3780.398104, -4206.338078 };
+
+                //double[] Ref_Station_LLH = { 112.33, 16.3, 0 };
+                double[] Ref_Station_LLH = { 115.5, 9.899, 64 }; //*****参考站的位置
+                double[] Zone = new double[4] { -85, 85, -180, 180 };
+
+                double target_dfo1 = 2.002242571242008e+02;
+                double target_dfo2 = 4.311089914542198e+03;
+
+                double fu1 = 3.1085e8;
+
+
+                double[] target_llh = new double[6];
+                var xdDtoLine = DrawDtoLineHelper.DfoLineSingleStart(main_eph, main_eph1, target_dfo1,fu1);
+                mapControl1.DrawDtoPonit($"星地[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat}时刻1频差线", xdDtoLine);
+
+                var xdDtoLine1 = DrawDtoLineHelper.DfoLineSingleStart(main_eph, main_eph2, target_dfo2, fu1);
+                mapControl1.DrawDtoPonit($"星地[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat}时刻2频差线", xdDtoLine1);
+
+
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error("绘制频差线失败", ex);
+                XtraMessageBox.Show($"绘制频差线失败,失败信息:{ex.Message}");
+            }
+        }
+
         public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
         {
             var dots = line.Line;

+ 12 - 4
XzXdDw.App/UserControl/CtrlPosXd.cs

@@ -150,7 +150,7 @@ namespace XzXdDw.App.UserControl
                             }
                         });
                     })
-                    
+
                     .AddPosMenu<PosRes>("误差椭圆", SvgHelper.LoadFromFile("Image\\误差椭圆.svg"), item =>
                     {
                         string msg = "星地我这里只有GDOP和定位\r\n罗博士和黎强应该有相关算法\r\n关闭后将自动绘制高轨双星误差椭圆";
@@ -431,13 +431,21 @@ namespace XzXdDw.App.UserControl
                 var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
                 var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
                 XzXdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO2X1DOption Option = new XzXdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO2X1DOption();
-                Option.MsEph = new double[] { cg.MainX, cg.MainY, cg.MainZ, 0, 0, 0 };
+                /*Option.MsEph = new double[] { cg.MainX, cg.MainY, cg.MainZ, 0, 0, 0 };
                 Option.NsEph = new double[] { cg.AdjaX, cg.AdjaY, cg.AdjaZ, 0, 0, 0 };
                 Option.CDBAnt = new double[] { cdbTx.Lon, cdbTx.Lat, 0 };
                 Option.RefGeod = new double[] { refTx.Lon, refTx.Lat, 0 };
                 Option.SelectPoint = new double[3] { item.PosLon, item.PosLat, 0 };
-                Option.DtoErr = 1;
-                Option.EphErr = 1;
+                Option.DtoErr = 1.0e-6;
+                Option.EphErr = 1.0e3;*/
+
+                Option.MsEph = new double[] { -1608409.905, 5994264.071, 3139843.443, -6633.016931, -374.023436, -2678.1580461 };
+                Option.NsEph = new double[] { -4629566.829, 4978943.601, 1487242.596, -4890.245126, -3337.702797, -4031.339975 };
+                Option.CDBAnt = new double[] { cdbTx.Lon, cdbTx.Lat, 0 };
+                Option.RefGeod = new double[] { 115.5, 9.899, 64 };
+                Option.SelectPoint = new double[2] { -180, -85 }; ;
+                Option.DtoErr = 1.0e-6;
+                Option.EphErr = 1.0e3;
                 var points = XzXdDw.App.Api.低轨GDOP误差椭圆.ErrEllipseHelper.ErrorEllipse2X1D(Option);
                 mapControl1.DrawDtoPonit($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]误差椭圆线", points);