PosApi.cs 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using DevExpress.XtraBars.Docking2010.Views.Widget;
  9. using Extensions;
  10. using XzXdDw.App.Model;
  11. using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
  12. using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
  13. namespace XdDw.App.Api
  14. {
  15. public static class PosApi
  16. {
  17. #region cpp dll Interop
  18. //两星一地定位
  19. private const string X2D1 = @"AddIns\DLL_SC_2X1D_DW.dll";
  20. [DllImport(X2D1, EntryPoint = "SC_2X1D_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地
  21. private extern static void X2D1_POS_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] satStation1, double[] satStation2, double[] satStation3, double[] satStation4,
  22. double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
  23. private const string XdtsDll = @"Api\时差线\Positioning.dll";
  24. /// <summary>
  25. ///
  26. /// </summary>
  27. /// <param name="main_sat_pos"></param>
  28. /// <param name="neigh_sat_pos"></param>
  29. /// <param name="rec1_pos"></param>
  30. /// <param name="rec2_pos"></param>
  31. /// <param name="ref_pos"></param>
  32. /// <param name="Zone"></param>
  33. /// <param name="target_dto">目标时差 (s)</param>
  34. /// <param name="ref_dto">参考时差 (s)</param>
  35. /// <param name="LOP_Value"></param>
  36. /// <param name="LOP_Len"></param>
  37. [DllImport(XdtsDll, EntryPoint = "CurveByTwoTDOA", CallingConvention = CallingConvention.Cdecl)]//两星一地
  38. public extern static void CurveByTwoTDOA(double[] main_sat_pos, double[] neigh_sat_pos, double[] rec1_pos, double[] rec2_pos, double[] ref_pos, double[] Zone,
  39. double target_dto, double ref_dto, out IntPtr LOP_Value, ref int LOP_Len);
  40. #endregion
  41. /// <summary>
  42. /// 两星一地,返回经度纬度高度及镜像点,数组长度为6
  43. /// </summary>
  44. /// <param name="cgRes"></param>
  45. /// <returns></returns>
  46. public static double[] X2D1_POS(CgRes cgRes, List<TxInfo> listTx)
  47. {
  48. var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
  49. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  50. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  51. double[] mainSat = new double[3] { cgRes.MainX, cgRes.MainY, cgRes.MainZ };
  52. double[] adjaSat = new double[3] { cgRes.AdjaX, cgRes.AdjaY, cgRes.AdjaZ };
  53. double[] satStation = new double[3] { satTx.Lon, satTx.Lat, 0 };
  54. double[] cdbStation = new double[3] { cdbTx.Lon, cdbTx.Lat, 0 };
  55. double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
  56. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  57. double[] res = new double[6];
  58. 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);
  59. return res;
  60. }
  61. public static double[] X2D1_POS(CgRes cgRes, TxInfo satTx, TxInfo cdbTx, TxInfo refTx)
  62. {
  63. double[] mainSat = new double[3] { cgRes.MainX, cgRes.MainY, cgRes.MainZ };
  64. double[] adjaSat = new double[3] { cgRes.AdjaX, cgRes.AdjaY, cgRes.AdjaZ };
  65. double[] satStation = new double[3] { satTx.Lon, satTx.Lat, 0 };
  66. double[] cdbStation = new double[3] { cdbTx.Lon, cdbTx.Lat, 0 };
  67. double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
  68. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  69. double[] res = new double[6];
  70. 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);
  71. return res;
  72. }
  73. }
  74. }