PosApi.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using DevExpress.Drawing.Internal.Fonts.Interop;
  8. using DevExpress.XtraBars.Docking2010.Views.Widget;
  9. using XdCxRhDW.App.Model;
  10. using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
  11. namespace XdCxRhDW.App.Api
  12. {
  13. public static class PosApi
  14. {
  15. #region cpp dll Interop
  16. //两星一地定位
  17. private const string X2D1 = @"AddIns\DLL_SC_2X1D_DW.dll";
  18. [DllImport(X2D1, EntryPoint = "SC_2X1D_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地
  19. private extern static void X2D1_POS_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] satStation1, double[] satStation2, double[] satStation3, double[] satStation4,
  20. double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
  21. #endregion
  22. /// <summary>
  23. /// 两星一地,返回经度纬度高度及镜像点,数组长度为6
  24. /// </summary>
  25. /// <param name="cgRes"></param>
  26. /// <returns></returns>
  27. public static double[] X2D1_POS(CgRes cgRes, List<TxInfo> listTx)
  28. {
  29. var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
  30. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  31. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  32. double[] mainSat = new double[3] { cgRes.MainX, cgRes.MainY, cgRes.MainZ };
  33. double[] adjaSat = new double[3] { cgRes.AdjaX, cgRes.AdjaY, cgRes.AdjaZ };
  34. double[] satStation = new double[3] { satTx.Lon, satTx.Lat, 0 };
  35. double[] cdbStation = new double[3] { cdbTx.Lon, cdbTx.Lat, 0 };
  36. double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
  37. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  38. double[] res = new double[6];
  39. X2D1_POS_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, satStation, satStation, refStation, zone, cgRes.DtoSx / 1e6, cgRes.DtoCdb / 1e6, cgRes.YbMain / 1e6, cgRes.YbAdja / 1e6, res);
  40. return res;
  41. }
  42. public static bool IsGeoPoint(double[] res)
  43. {
  44. return res[0] >= -180 && res[0] <= 180 && res[1] >= -90 && res[1] <= 90;
  45. }
  46. }
  47. }