zhangzhiming 1 tahun lalu
induk
melakukan
059c39f831

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

@@ -69,7 +69,7 @@ namespace XzXdDw.App.Api
         /// <param name="LOP_Len"></param>
         [DllImport(gzdw, EntryPoint = "TwoStar_SCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
         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);
+        double target_dto, double ref_dto, out IntPtr LOP_Value,ref int LOP_Len);
 
         /// <summary>
         /// 地轨双星频差线

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

@@ -92,6 +92,9 @@ namespace XdCxRhDW.App.Api.时差线
             arguments.Add($"{opt.xdDto}");
             arguments.Add($"{opt.RefDto}");
 
+
+            arguments.Add($"{opt.PosLon}");
+            arguments.Add($"{opt.PosLat}");
             Process p = new Process();
             p.StartInfo.WorkingDirectory = exePath;
             p.StartInfo.FileName = exeFile;
@@ -126,7 +129,7 @@ namespace XdCxRhDW.App.Api.时差线
         }
 
 
-        public static IEnumerable<(double lon, double lat)> HandleDtoLineTwoStart(DtoLineTwoStartOption opt)
+        public static IEnumerable<(double lon, double lat)> HandleDtoLineXDTwoStart(DtoLineTwoStartOption opt)
         {
 
             List<DtoLinePoint> list = new List<DtoLinePoint>();
@@ -134,9 +137,11 @@ namespace XdCxRhDW.App.Api.时差线
             int LOP_Len = 0;
             double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
 
-            PosApi.TwoStar_SCX(
+            PosApi.CurveByTwoTDOA(
                 opt.MsEph,
                  opt.NsEph,
+                 opt.MsAnt,
+                 opt.NsAnt,
                 opt.RefGeod,
                  zone,
                 opt.TargetDto * 1e-6,
@@ -147,15 +152,8 @@ namespace XdCxRhDW.App.Api.时差线
             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);
+
+                list = OutputHelper.WriteDtoLine(LOP_Value, LOP_Len);
             }
             var Lines = list.Select(p => (p.Lon, p.Lat));
             return Lines;

+ 24 - 1
XzXdDw.App/Api/时差线/DtoLineModel.cs

@@ -49,6 +49,13 @@ namespace XdCxRhDW.App.Api.时差线
         /// </summary>
         public double RefDto { get; set; }
 
+        /// <summary>
+        /// 经度
+        /// </summary>
+        public double PosLon { get; set; }
+
+        public double PosLat { get; set; }
+
     }
 
 
@@ -64,6 +71,16 @@ namespace XdCxRhDW.App.Api.时差线
         /// </summary>
         public double[] NsEph { get; set; }
 
+        /// <summary>
+        /// 主星接收站
+        /// </summary>
+        public double[] MsAnt { get; set; }
+
+        /// <summary>
+        /// 邻星接收站
+        /// </summary>
+        public double[] NsAnt { get; set; }
+
         /// <summary>
         /// 参考站位置
         /// </summary>
@@ -77,7 +94,13 @@ namespace XdCxRhDW.App.Api.时差线
         /// 参考时差 (us)
         /// </summary>
         public double RefDto { get; set; }
-        
+
+        /// <summary>
+        /// 经度
+        /// </summary>
+        public double PosLon { get; set; }
+
+        public double PosLat { get; set; }
 
     }
 }

+ 130 - 0
XzXdDw.App/Api/时差线/OutputHelper.cs

@@ -0,0 +1,130 @@
+using DevExpress.Map.Kml.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace XdCxRhDW.App.Api.时差线
+{
+    public class OutputHelper
+    {
+        public const double WGS84a = 6378137.0;
+        public const double f = 1.0 / 298.257224;
+
+        public static List<DtoLinePoint> WriteDtoLine(double[] LOP_Value, int LOP_Len)
+        {
+            List<DtoLinePoint> list = new List<DtoLinePoint>();
+
+            if (LOP_Len == 0) return list;
+            var len = LOP_Len * 2;
+            Lla[] line = new Lla[len + 1];
+            double? prevLon = null, prevLat = null;
+            for (int i = 0; i < LOP_Len; i++)
+            {
+                var lon1 = LOP_Value[3 * i + 1];
+                var lon2 = LOP_Value[3 * i + 2];
+                var lat = LOP_Value[3 * i];
+                var p2Idx = len - 1 - i;
+                if (lon1 != -1 && lon2 != -1)
+                {
+                    if (prevLon == null)
+                    {
+                        line[i] = new Lla(lon1, lat);
+                        line[p2Idx] = new Lla(lon2, lat);
+                    }
+                    else
+                    {
+                        var disLon1 = DisLon(prevLon.Value, prevLat.Value, lon1, lat);
+                        var disLon2 = DisLon(prevLon.Value, prevLat.Value, lon2, lat);
+                        if (disLon1 < disLon2)
+                        {
+                            line[i] = new Lla(lon1, lat);
+                            line[p2Idx] = new Lla(lon2, lat);
+                        }
+                        else
+                        {
+                            line[i] = new Lla(lon2, lat);
+                            line[p2Idx] = new Lla(lon1, lat);
+                        }
+                    }
+                    prevLon = line[i].Lon;
+                    prevLat = line[i].Lat;
+                }
+            }
+            var firstPoint = line.FirstOrDefault(m => m != null);
+            if (firstPoint != null)
+            {
+                line[line.Length - 1] = new Lla(firstPoint.Lon, firstPoint.Lat);
+            }
+            Array.ForEach(line, lla =>
+            {
+                if (lla != null)
+                {
+                    DtoLinePoint dtoLine = new DtoLinePoint();
+                    dtoLine.Lon = lla.Lon;
+                    dtoLine.Lat = lla.Lat;
+                    list.Add(dtoLine);
+                }
+            });
+            return list;
+        }
+
+        public static double DisLon(double lon1, double lat1, double lon2, double lat2)
+        {
+            return DistinceLla(new double[] { lon1, lat1, 0 }, new double[] { lon2, lat2, 0 });
+        }
+
+        public static double DistinceLla(double[] lla1, double[] lla2)
+        {
+            double[] xyz1 = LLA2XYZ(lla1[0], lla1[1], lla1[2]), xyz2 = LLA2XYZ(lla2[0], lla2[1], lla2[2]);
+            return Distince(xyz1[0], xyz1[1], xyz1[2], xyz2[0], xyz2[1], xyz2[2]);
+        }
+
+        public static double Distince(double x1, double y1, double z1, double x2, double y2, double z2)
+        {
+            double x = (x1 - x2);
+            double y = (y1 - y2);
+            double z = (z1 - z2);
+            double dist = Math.Sqrt(x * x + y * y + z * z);
+            return dist;
+        }
+
+        public static double[] LLA2XYZ(double lon, double lat, double alt)
+        {
+            lat = Math.PI * lat / 180.0;
+            lon = Math.PI * lon / 180.0;
+
+            double cosLat = Math.Cos(lat);
+            double sinLat = Math.Sin(lat);
+
+            double cosLong = Math.Cos(lon);
+            double sinLong = Math.Sin(lon);
+
+            double c = 1 / Math.Sqrt(cosLat * cosLat + (1 - f) * (1 - f) * sinLat * sinLat);
+            double s = (1 - f) * (1 - f) * c;
+
+            double x = (WGS84a * c + alt) * cosLat * cosLong;
+            double y = (WGS84a * c + alt) * cosLat * sinLong;
+            double z = (WGS84a * s + alt) * sinLat;
+
+            return new double[3] { x, y, z };
+        }
+    }
+
+    public class Lla
+    {
+        public Lla(double lon, double lat)
+        {
+            this.Lon = lon;
+            this.Lat = lat;
+        }
+
+        public double Lon { get; set; }
+
+        public double Lat { get; set; }
+
+        public double Alt { get; set; } = 0;
+    }
+
+}

TEMPAT SAMPAH
XzXdDw.App/Api/时差线/Positioning.dll


+ 49 - 0
XzXdDw.App/Api/时差线/Positioning.h

@@ -0,0 +1,49 @@
+#pragma once
+
+#ifdef _WIN32
+# if defined(Positioning_LIB)
+#  define Positioning_EXPORT __declspec(dllexport)
+# else
+#  define Positioning_EXPORT __declspec(dllimport)
+# endif
+#else
+#  define Positioning_EXPORT
+#endif
+
+extern "C"
+{
+	/*
+	双星时差线
+	LOP_Value 返回值 结构参考DTO_Plot
+	LOP_Len*3为LOP_Value的长度
+	*/
+	Positioning_EXPORT void CurveByTwoTDOA(double *main_sat_pos, double *neigh_sat_pos, double *rec_pos1, double *rec_pos2, double *ref_pos,
+		double *Zone, double target_dto, double ref_dto, double **LOP_Value, int *LOP_Len);
+
+	/*
+	双星时差线-无参
+	LOP_Value 返回值 结构参考DTO_Plot
+	LOP_Len*3为LOP_Value的长度
+	*/
+	Positioning_EXPORT void CurveByTwoTDOAWithNoRef(double *main_sat_pos, double *neigh_sat_pos, double *rec_pos1, double *rec_pos2,
+		double *Zone, double target_dto, double **LOP_Value, int *LOP_Len);
+
+	/*
+	三星定位
+	target_llh,长度固定为6  经度、纬度、高;(镜像)经度、纬度、高
+	*/
+	Positioning_EXPORT void HyperbolicPositioning(double *main_sat, double *neigh_sat1, double *neigh_sat2, double *Sat_Station_LLH1, double *Sat_Station_LLH2, double *Sat_Station_LLH3,
+		double *Ref_Station_LLH, double *Zone, double target_dto1, double target_dto2, double ref_dto1, double ref_dto2, double *target_llh);
+
+	/*
+	三星定位
+	target_llh,长度固定为6	经度、纬度、高;(镜像)经度、纬度、高
+	*/
+	Positioning_EXPORT void HyperbolicPositioningWithNoRef(double *main_sat, double *neigh_sat1, double *neigh_sat2, double *Sat_Station_LLH1, double *Sat_Station_LLH2, double *Sat_Station_LLH3,
+		double *Zone, double target_dto1, double target_dto2, double *target_llh);
+
+	/*
+	用于释放时差线缓存
+	*/
+	Positioning_EXPORT void Destory(void *buf);
+};

TEMPAT SAMPAH
XzXdDw.App/Api/时差线/XingDiSCX.exe


+ 7 - 1
XzXdDw.App/UserControl/CtrlPosXd.cs

@@ -371,16 +371,22 @@ namespace XzXdDw.App.UserControl
                 dtoLineXd.RefGeod = new double[] { refTx.Lon, refTx.Lat, 0 };
                 dtoLineXd.xdDto = cg.DtoCdb;
                 dtoLineXd.RefDto = cg.YbMain;
+                dtoLineXd.PosLon = item.PosLon;
+                dtoLineXd.PosLat = item.PosLat;
                 var xdDtoLine = DrawDtoLineHelper.HandleDtoLineXd(dtoLineXd);
                 mapControl1.DrawDtoLine($"星地[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == cdbTx.ID)?.Sat}]时差线", xdDtoLine);
 
                 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.MsAnt= new double[] { satTx.Lon, satTx.Lat, 0 };
+                twoStartOption.NsAnt = new double[] { satNTx.Lon, satNTx.Lat, 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);
+                twoStartOption.PosLon = item.PosLon;
+                twoStartOption.PosLat = item.PosLat;
+                var tsDtoLine= DrawDtoLineHelper.HandleDtoLineXDTwoStart(twoStartOption);
                 mapControl1.DrawDtoLine($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]时差线", tsDtoLine);
                
 

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

@@ -148,6 +148,7 @@
     <Compile Include="Api\时差粗值预测\DtApi.cs" />
     <Compile Include="Api\时差线\DrawDtoLineHelper.cs" />
     <Compile Include="Api\时差线\DtoLineModel.cs" />
+    <Compile Include="Api\时差线\OutputHelper.cs" />
     <Compile Include="Api\星历推算\Tle2XYZ.cs" />
     <Compile Include="Api\星地GDOP误差椭圆\ErrEllipseHelper.cs" />
     <Compile Include="Api\星地GDOP误差椭圆\GdopHelper.cs" />
@@ -489,6 +490,10 @@
     <Content Include="Api\时差线\Newtonsoft.Json.dll">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="Api\时差线\Positioning.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Api\时差线\Positioning.h" />
     <Content Include="Api\时差线\XingDiSCX.exe">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>