瀏覽代碼

添加DW范围是否使用镜像点

wyq 1 年之前
父節點
當前提交
756c6715d7
共有 2 個文件被更改,包括 43 次插入7 次删除
  1. 41 7
      XzXdDw.App/Api/PosApi.cs
  2. 2 0
      XzXdDw.App/App.config

+ 41 - 7
XzXdDw.App/Api/PosApi.cs

@@ -1,10 +1,12 @@
 using System;
 using System.Collections.Generic;
+using System.Configuration;
 using System.Linq;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using DevExpress.XtraBars.Docking2010.Views.Widget;
+using Extensions;
 using XzXdDw.App.Model;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
 using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
@@ -101,7 +103,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,out IntPtr LOP_Value,ref 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";
@@ -157,19 +159,20 @@ namespace XzXdDw.App.Api
             return res;
         }
 
-        public static double[] X1_POS(CgRes cg,CgRes cg1,double upfreqHz)
+        public static double[] X1_POS(CgRes cg, CgRes cg1, double upfreqHz)
         {
-           
-            double[] mainSat = new double[6] { cg.MainX, cg.MainY, cg.MainZ,cg .MainVX,cg.MainVY,cg.MainVZ};
+
+            double[] mainSat = new double[6] { cg.MainX, cg.MainY, cg.MainZ, cg.MainVX, cg.MainVY, cg.MainVZ };
             double[] adjaSat1 = new double[6] { cg.AdjaX, cg.AdjaY, cg.AdjaZ, cg.AdjaVX, cg.AdjaVY, cg.AdjaVZ };
             double[] adjaSat2 = new double[6] { cg1.AdjaX, cg1.AdjaY, cg1.AdjaZ, cg1.AdjaVX, cg1.AdjaVY, cg1.AdjaVZ };
             double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
             double[] res = new double[6];
-            SingleStar_DFO_DW(mainSat, adjaSat1, adjaSat2,  zone, cg.DfoSx,cg1.DfoSx, upfreqHz, res);
+            SingleStar_DFO_DW(mainSat, adjaSat1, adjaSat2, zone, cg.DfoSx, cg1.DfoSx, upfreqHz, res);
+            IsRange(res);
             return res;
         }
 
-        public static double[] X2_POS(CgRes cg, TxInfo refTx, double upfreqHz1,double upfreqHz2)
+        public static double[] X2_POS(CgRes cg, TxInfo refTx, double upfreqHz1, double upfreqHz2)
         {
             double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
 
@@ -177,12 +180,43 @@ namespace XzXdDw.App.Api
             double[] adjaSat1 = new double[6] { cg.AdjaX, cg.AdjaY, cg.AdjaZ, cg.AdjaVX, cg.AdjaVY, cg.AdjaVZ };
             double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
             double[] res = new double[6];
-            TwoStar_DTFO_DW(mainSat, adjaSat1,refStation, zone,cg.DtoSx, cg.DfoSx, cg.DtoCdb, cg.DfoCdb, upfreqHz1, upfreqHz2, res);
+            TwoStar_DTFO_DW(mainSat, adjaSat1, refStation, zone, cg.DtoSx, cg.DfoSx, cg.DtoCdb, cg.DfoCdb, upfreqHz1, upfreqHz2, res);
+            IsRange(res);
             return res;
         }
         public static bool IsGeoPoint(double[] res)
         {
             return res[0] >= -180 && res[0] <= 180 && res[1] >= -90 && res[1] <= 90;
         }
+
+        private static void IsRange(double[] PosRes)
+        {
+            var centerLon = ConfigurationManager.AppSettings["CenterLon"].To(144);
+            var centerLat = ConfigurationManager.AppSettings["CenterLat"].To(13);
+            var lonRange = ConfigurationManager.AppSettings["LonRange"].To(10);
+            var LatRange = ConfigurationManager.AppSettings["LatRange"].To(10);
+
+            var startLon = centerLon - lonRange / 2f;
+            var endLon = centerLon + lonRange / 2f;
+            var startLat = centerLat - LatRange / 2f;
+            var endLat = centerLat + LatRange / 2f;
+
+            double posLon = PosRes[0];
+            double posLat = PosRes[1];
+            double posHigth = PosRes[2];
+            if (posLon == 0 || posLon == 999)
+            {
+                return;
+            }
+            if (startLon > posLon || endLon < posLon || startLat > posLat || endLat < posLat)
+            {
+                PosRes[0] = PosRes[3];
+                PosRes[1] = PosRes[4];
+                PosRes[2] = PosRes[5];
+                PosRes[3] = posLon;
+                PosRes[4] = posLat;
+                PosRes[5] = posHigth;
+            }
+        }
     }
 }

+ 2 - 0
XzXdDw.App/App.config

@@ -82,5 +82,7 @@
 		<!--框选范围-->
 		<add key="CenterLon" value="144"/>
 		<add key="CenterLat" value="13"/>
+		<add key="LonRange" value="10"/>
+		<add key="LatRange" value="10"/>
 	</appSettings>
 </configuration>