소스 검색

添加绘制时差线

wyq 1 년 전
부모
커밋
8a4412ac1a

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

@@ -20,7 +20,7 @@ namespace XzXdDw.App.Api
              double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
 
 
-        private const string gzdw = @"AddIns\DLL_GZDW.dll";
+        private const string gzdw = @"Api\低轨时频差线及定位\DLL_GZDW.dll";
 
         /// <summary>
         /// 地轨双星dw
@@ -68,8 +68,8 @@ namespace XzXdDw.App.Api
         /// <param name="LOP_Value"></param>
         /// <param name="LOP_Len"></param>
         [DllImport(gzdw, EntryPoint = "TwoStar_SCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
-        private extern static void TwoStar_SCX(double[] main_sat_pos, double[] neigh_sat_pos, double[] ref_pos, double[] Zone,
-        double target_dto, double ref_dto, IntPtr LOP_Value, int[] LOP_Len);
+        public extern static void TwoStar_SCX(double[] main_sat_pos, double[] neigh_sat_pos, double[] ref_pos, double[] Zone,
+        double target_dto, double ref_dto, out IntPtr LOP_Value,ref int LOP_Len);
 
         /// <summary>
         /// 地轨双星频差线

BIN
XzXdDw.App/Api/时差线/DLL_LHDW32.dll


+ 163 - 0
XzXdDw.App/Api/时差线/DrawDtoLineHelper.cs

@@ -0,0 +1,163 @@
+using DevExpress.Internal.WinApi.Windows.UI.Notifications;
+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 XzXdDw.App.Api;
+
+namespace XdCxRhDW.App.Api.时差线
+{
+    public class DrawDtoLineHelper
+    {
+        #region 未使用
+        /*
+        static double[] HandleX2D1(X2D1Option opt)
+        {
+            var target_llh = DLL_LXYDApi.XingDi_DW(
+                    opt.MsEph
+                    , opt.NsEph
+                    , opt.MsAnt
+                    , opt.NsAnt
+                    , opt.CDBMsAnt
+                    , opt.CDBAnt
+                    , opt.RefGeod
+                    , opt.Zone
+                    , opt.SxDto * 1e-6
+                    , opt.xdDto * 1e-6
+                    , -opt.SampMsDto * 1e-6
+                    , -opt.SampNsDto * 1e-6
+                    , -opt.CDBpMsDto * 1e-6
+                    );
+            double[] result = new double[6];
+            Marshal.Copy(target_llh, result, 0, result.Length);
+            return result;
+        }
+       
+        static void HandleX1D2(X1D2Option opt)
+        {
+            var target_llh = DLL_YXLDApi.XingDi_DW_YXLD(
+                opt.MsEph
+                , opt.Ms1Ant
+                , opt.Ms2Ant
+                , opt.Nd1Ant
+                , opt.Nd2Ant
+                , opt.RefGeod1
+                , opt.RefGeod2
+                , opt.Zone
+                , opt.DtXd1 * 1e-6
+                , opt.DtXd2 * 1e-6
+                , -opt.DtRef1 * 1e-6
+                , -opt.DtRef2 * 1e-6
+                );
+            double[] result = new double[6];
+            Marshal.Copy(target_llh, result, 0, result.Length);
+            // OutputHelper.WritePos(result);
+        }
+         */
+        #endregion
+        private const string exeName = "XingDiSCX.exe";
+
+        public static IEnumerable<(double lon, double lat)> HandleDtoLineXd(DtoLineXdOption opt)
+        {
+            List<DtoLinePoint> list = new List<DtoLinePoint>();
+
+            string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "API\\时差线\\DtoLine.dat");
+            string exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "API\\时差线");
+            if (string.IsNullOrWhiteSpace(exePath))
+                throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
+            if (!Directory.Exists(exePath))
+                throw new Exception($"路径[{exePath}]不存在");
+            var exeFile = Path.Combine(exePath, exeName);
+            if (!File.Exists(exeFile))
+                throw new Exception($"文件[{exeFile}]不存在");
+            List<string> arguments = new List<string>();
+            arguments.Add(file);
+            arguments.Add($"{opt.MsEph[0]}");
+            arguments.Add($"{opt.MsEph[1]}");
+            arguments.Add($"{opt.MsEph[2]}");
+
+            arguments.Add($"{opt.MsAnt[0]}");
+            arguments.Add($"{opt.MsAnt[1]}");
+
+            arguments.Add($"{opt.CDBAnt[0]}");
+            arguments.Add($"{opt.CDBAnt[1]}");
+
+            arguments.Add($"{opt.RefGeod[0]}");
+            arguments.Add($"{opt.RefGeod[1]}");
+
+            arguments.Add($"{opt.xdDto}");
+            arguments.Add($"{opt.RefDto}");
+
+            Process p = new Process();
+            p.StartInfo.WorkingDirectory = exePath;
+            p.StartInfo.FileName = exeFile;
+            p.StartInfo.Arguments = string.Join(" ", arguments);
+            p.StartInfo.CreateNoWindow = true;
+            p.StartInfo.RedirectStandardError = true;
+            p.StartInfo.RedirectStandardOutput = true;
+            p.StartInfo.UseShellExecute = false;
+            p.Start();
+            var succeed = p.WaitForExit(10000);
+            if (!succeed)
+            {
+                throw new Exception($"进程[{exeName}]超时未完成!");
+            }
+            string result = p.StandardOutput.ReadToEnd();
+            if (string.IsNullOrWhiteSpace(result))
+            {
+                throw new Exception("计算时差线出现未知错误!");
+            }
+            var array = result.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+            if (array[0] == "1")
+            {
+                throw new Exception(array[1]);
+            }
+            var dtostr = File.ReadAllText(file);
+            list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DtoLinePoint>>(dtostr);
+
+            var Lines = list.Select(s => (s.Lon, s.Lat));
+            return Lines;
+        }
+
+
+        public static IEnumerable<(double lon, double lat)> HandleDtoLineTwoStart(DtoLineTwoStartOption opt)
+        {
+
+            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,
+                 opt.NsEph,
+                opt.RefGeod,
+                 zone,
+                opt.TargetDto * 1e-6,
+                opt.RefDto * 1e-6, out LOP_ValuePtr, ref LOP_Len);
+
+
+            double[] LOP_Value = new double[LOP_Len * 3];
+            if (LOP_Len > 0)
+            {
+                Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
+                for (int i = 0; i < LOP_Len; i++)
+                {
+                    int temp = i * 3;
+                    DtoLinePoint point = new DtoLinePoint();
+                    point.Lon = LOP_Value[temp + 1];
+                    point.Lat = LOP_Value[temp];
+                    list.Add(point);
+                }
+                //OutputHelper.WriteDtoLine(LOP_Value, LOP_Len);
+            }
+            var Lines = list.Select(p => (p.Lon, p.Lat));
+            return Lines;
+        }
+
+    }
+}

+ 83 - 0
XzXdDw.App/Api/时差线/DtoLineModel.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace XdCxRhDW.App.Api.时差线
+{
+    public class DtoLinePoint 
+    {
+        /// <summary>
+        /// 经度
+        /// </summary>
+        public double Lon { get; set; }
+        /// <summary>
+        /// 纬度
+        /// </summary>
+        public double Lat { get; set; }
+    }
+    public class DtoLineXdOption
+    {
+        /// <summary>
+        /// 主星星历
+        /// </summary>
+        public double[] MsEph { get; set; }
+      
+
+        /// <summary>
+        /// 主星接收站
+        /// </summary>
+        public double[] MsAnt { get; set; }
+       
+      
+        /// <summary>
+        /// 超短波接收站
+        /// </summary>
+        public double[] CDBAnt { get; set; }
+        /// <summary>
+        /// 参考站位置
+        /// </summary>
+        public double[] RefGeod { get; set; }
+        
+        /// <summary>
+        /// 星地时差 (us)
+        /// </summary>
+        public double xdDto { get; set; }
+        /// <summary>
+        /// 参考时差 (us)
+        /// </summary>
+        public double RefDto { get; set; }
+
+    }
+
+
+    public class DtoLineTwoStartOption
+    {
+        /// <summary>
+        /// 主星星历
+        /// </summary>
+        public double[] MsEph { get; set; }
+
+        /// <summary>
+        /// 邻星星历
+        /// </summary>
+        public double[] NsEph { get; set; }
+
+        /// <summary>
+        /// 参考站位置
+        /// </summary>
+        public double[] RefGeod { get; set; }
+
+        /// <summary>
+        /// 目标时差 (us)
+        /// </summary>
+        public double TargetDto { get; set; }
+        /// <summary>
+        /// 参考时差 (us)
+        /// </summary>
+        public double RefDto { get; set; }
+        
+
+    }
+}

BIN
XzXdDw.App/Api/时差线/Newtonsoft.Json.dll


BIN
XzXdDw.App/Api/时差线/XingDiSCX.exe


BIN
XzXdDw.App/Api/时差线/msvcp100.dll


BIN
XzXdDw.App/Api/时差线/msvcr100.dll


+ 25 - 0
XzXdDw.App/ExtensionsDev/MapControlEx.cs

@@ -1425,6 +1425,31 @@ public static class MapControlEx
         if (!polyLine.Points.Any()) return;
         innerData.mMapStorage.Items.Add(polyLine);
     }
+    public static void DrawDtoLine(this MapControl ctrl,string title, IEnumerable<(double lon, double lat)> lines)
+    {
+        if (lines == null || !lines.Any()) return;
+        var innerData = ctrl.Tag as InnerData;
+        var polyLine = new MapPolyline()
+        {
+            Stroke = ColorHelper.GetColor(title),
+            StrokeWidth = 2,
+            IsGeodesic = true,
+            CanResize = false,
+            CanEdit = false,
+            CanRotate = false,
+            IsHitTestVisible = true,
+            CanMove = false,
+            Tag = $"DrawDtoLine_{title}",
+            ToolTipPattern = $"{title}",
+        };
+        foreach (var item in lines)
+        {
+            if (double.IsNaN(item.lat) || double.IsNaN(item.lon)) continue;
+            polyLine.Points.Add(new GeoPoint(item.lat, item.lon));
+        }
+        if (!polyLine.Points.Any()) return;
+        innerData.mMapStorage.Items.Add(polyLine);
+    }
     public static void DrawErrEllipse(this MapControl ctrl, double r1, double r2, IEnumerable<(double lon, double lat)> lines)
     {
         if (lines == null || !lines.Any()) return;

+ 20 - 0
XzXdDw.App/Image/DrawLine.svg

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
+<style type="text/css">
+	.Green{fill:#039C23;}
+	.Black{fill:#727272;}
+	.Red{fill:#D11C1C;}
+	.Yellow{fill:#FFB115;}
+	.Blue{fill:#1177D7;}
+	.White{fill:#FFFFFF;}
+	.st0{opacity:0.5;}
+	.st1{opacity:0.75;}
+</style>
+<g id="EnableClustering">
+	<path class="Green" d="M32,16c0,4.4-3.6,8-8,8c-0.2,0-0.3,0-0.5,0c1.6-2.3,2.5-5.1,2.5-8s-0.9-5.6-2.5-8c0.2,0,0.3,0,0.5,0
+		C28.4,8,32,11.6,32,16z M14,16c0-3.9,2.3-7.5,5.8-9.1C17.7,5.1,15,4,12,4C5.4,4,0,9.4,0,16c0,6.6,5.4,12,12,12c3,0,5.7-1.1,7.8-2.9
+		C16.3,23.5,14,19.9,14,16z M21.3,8.5C18.2,9.6,16,12.5,16,16s2.2,6.4,5.3,7.5C23,21.5,24,18.9,24,16S23,10.5,21.3,8.5z"/>
+</g>
+</svg>

+ 61 - 0
XzXdDw.App/UserControl/CtrlPosXd.cs

@@ -21,6 +21,7 @@ using System.Windows.Controls;
 using System.Windows.Documents;
 using System.Windows.Forms;
 using XdCxRhDW.App.Api.时差粗值预测;
+using XdCxRhDW.App.Api.时差线;
 using XdCxRhDW.App.DTO;
 using XdCxRhDW.App.UserControl;
 using XzXdDw.App.Api;
@@ -82,6 +83,7 @@ namespace XzXdDw.App.UserControl
                         }
                     })
                     .AddMenu("手动定位", SvgHelper.LoadFromFile("Image\\Pos.svg"), XdPos)
+                    .AddMenu("绘制时差线", SvgHelper.LoadFromFile("Image\\DrawLine.svg"), DrawDtoLine)
                     .AddMenu("加载仿真数据", SvgHelper.LoadFromFile("Image\\LoadData.svg"), LoadTestData)
                     .AddMenu("停止加载", SvgHelper.LoadFromFile("Image\\Stop.svg"), () => stoped = true);
 
@@ -331,6 +333,65 @@ namespace XzXdDw.App.UserControl
             }
         }
 
+        private async void DrawDtoLine()
+        {
+            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);
+                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);
+                DtoLineXdOption dtoLineXd = new DtoLineXdOption();
+                dtoLineXd.MsEph = new double[] { cg.MainX,cg.MainY,cg.MainZ,0,0,0 };
+                dtoLineXd.MsAnt = new double[] { satTx.Lon, satTx.Lat, 0};
+                dtoLineXd.CDBAnt = new double[] { cdbTx.Lon, cdbTx.Lat, 0 };
+                dtoLineXd.RefGeod = new double[] { refTx.Lon, refTx.Lat, 0 };
+                dtoLineXd.xdDto = cg.DtoCdb;
+                dtoLineXd.RefDto = cg.YbMain - cg.YbAdja;
+
+
+                DtoLineTwoStartOption twoStartOption = new DtoLineTwoStartOption();
+                twoStartOption.MsEph = new double[] { cg.MainX, cg.MainY, cg.MainZ, 0, 0, 0 };
+                twoStartOption.NsEph = new double[] { cg.AdjaX, cg.AdjaY, cg.AdjaZ, 0, 0, 0 };
+                twoStartOption.RefGeod = new double[] { refTx.Lon, refTx.Lat, 0 };
+                twoStartOption.TargetDto = cg.DtoSx;
+                twoStartOption.RefDto = cg.YbMain - cg.YbAdja;
+               var tsDtoLine= DrawDtoLineHelper.HandleDtoLineTwoStart(twoStartOption);
+                mapControl1.DrawDtoLine($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]时差线", tsDtoLine);
+                var xdDtoLine =  DrawDtoLineHelper.HandleDtoLineXd(dtoLineXd);
+                mapControl1.DrawDtoLine($"星地[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == cdbTx.ID)?.Sat}]时差线", xdDtoLine);
+
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error("绘制时差线失败", ex);
+                XtraMessageBox.Show($"绘制时差线失败,失败信息:{ex.Message}");
+            }
+        }
+
 
         public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
         {

+ 21 - 0
XzXdDw.App/XzXdDw.App.csproj

@@ -146,6 +146,8 @@
     <Compile Include="Api\低轨GDOP误差椭圆\ErrEllipseHelper.cs" />
     <Compile Include="Api\低轨GDOP误差椭圆\GdopHelper.cs" />
     <Compile Include="Api\时差粗值预测\DtApi.cs" />
+    <Compile Include="Api\时差线\DrawDtoLineHelper.cs" />
+    <Compile Include="Api\时差线\DtoLineModel.cs" />
     <Compile Include="Api\星历推算\Tle2XYZ.cs" />
     <Compile Include="Api\星地GDOP误差椭圆\ErrEllipseHelper.cs" />
     <Compile Include="Api\星地GDOP误差椭圆\GdopHelper.cs" />
@@ -502,7 +504,25 @@
     <None Include="Image\初值预估.svg">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <Content Include="Api\时差线\DLL_LHDW32.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Api\时差线\msvcp100.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Api\时差线\msvcr100.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Api\时差线\Newtonsoft.Json.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Api\时差线\XingDiSCX.exe">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="DLL_GZDW.dll" />
+    <Content Include="Image\DrawLine.svg">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="Image\Pos.svg">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
@@ -523,6 +543,7 @@ move /Y *.dll AddIns
 move /Y *.pdb AddIns
 
 xcopy x64 AddIns\x64 /EHCIY
+xcopy x86 AddIns\x86 /EHCIY
 rmdir x86 /S/Q
 rmdir x64 /S/Q</PostBuildEvent>
   </PropertyGroup>