X2D1ErrEllipseParam.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using DevExpress.XtraEditors;
  2. using DevExpress.XtraMap;
  3. using DxHelper;
  4. using ExtensionsDev;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using XdCxRhDW.App.Api.星历推算;
  15. using XzXdDw.App;
  16. using XzXdDw.App.Api.低轨GDOP误差椭圆;
  17. using XzXdDw.App.EFContext;
  18. using XzXdDw.App.Model;
  19. namespace XdCxRhDW.App.UserControl
  20. {
  21. public partial class X2D1ErrEllipseParam : DevExpress.XtraEditors.XtraUserControl
  22. {
  23. public MapControl mapControl1;
  24. public double lon;
  25. public double lat;
  26. public ErrEllipse星地两星一地接口 Model => new ErrEllipse星地两星一地接口()
  27. {
  28. TleMain = txtTleMain.Text.Trim(),
  29. TleAdja = txtTleAdja.Text.Trim(),
  30. CapTime = txtCapTime.DateTime,
  31. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  32. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  33. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  34. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  35. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  36. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  37. };
  38. public X2D1ErrEllipseParam(DateTime sigTime)
  39. {
  40. InitializeComponent();
  41. txtCapTime.UseDefault();
  42. txtTleMain.UseDoubleClickToSelectAll();
  43. txtTleAdja.UseDoubleClickToSelectAll();
  44. txtStationLocation1.UseDoubleClickToSelectAll();
  45. txtRefLocation1.UseDoubleClickToSelectAll();
  46. List<TxInfo> listTx = new List<TxInfo>();
  47. using (RHDWContext db = new RHDWContext())
  48. {
  49. listTx = db.TxInfos.ToList();
  50. }
  51. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  52. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  53. this.txtCapTime.DateTime = sigTime;
  54. this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
  55. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  56. txtTleMain.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleMain;
  57. txtTleAdja.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleAdja1;
  58. this.txtDtousErr1.EditValue = TestData.DtousErr;
  59. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  60. }
  61. private void btnOK_Click(object sender, EventArgs e)
  62. {
  63. mapControl1.ClearMap();
  64. double[] main_sat = Tle2XYZ.GetXyz(Model.TleMain, Model.CapTime);
  65. double[] adja_sat = Tle2XYZ.GetXyz(Model.TleAdja, Model.CapTime);
  66. DrawErrorEllipse2X1D(lon,lat, main_sat, adja_sat, new double[] { Model.StationLon, Model.StationLat, 0 }, new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr);
  67. }
  68. private void DrawErrorEllipse2X1D(double posLon, double posLat, double[] MsEph, double[] NsEph, double[] CDBAnt, double[] RefGeod, double DtoErr, double EphErr)
  69. {
  70. try
  71. {
  72. List<TxInfo> listTx = new List<TxInfo>();
  73. List<XzXdDw.App.Model.SatInfo> listSat = new List<XzXdDw.App.Model.SatInfo>();
  74. using (RHDWContext db = new RHDWContext())
  75. {
  76. listTx = db.TxInfos.ToList();
  77. listSat = db.SatInfos.ToList();
  78. }
  79. var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
  80. var satNTx = listTx.Find(p => p.TxType == EnumTxType.AdjaSat);
  81. ErrorEllipseDTO2X1DOption Option = new ErrorEllipseDTO2X1DOption();
  82. Option.MsEph = MsEph;
  83. Option.NsEph = NsEph;
  84. Option.CDBAnt = CDBAnt;
  85. Option.RefGeod = RefGeod;
  86. Option.SelectPoint = new double[3] { posLon, posLat, 0 };
  87. Option.DtoErr = DtoErr * 1e-6;
  88. Option.EphErr = EphErr;
  89. var points = ErrEllipseHelper.ErrorEllipse2X1D(Option);
  90. mapControl1.DrawDtoPonit($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]误差椭圆线", points);
  91. }
  92. catch (Exception ex)
  93. {
  94. Serilog.Log.Error("绘制误差椭圆线失败", ex);
  95. XtraMessageBox.Show($"绘制误差椭圆线失败,失败信息:{ex.Message}");
  96. }
  97. }
  98. private void btnClose_Click(object sender, EventArgs e)
  99. {
  100. PopupHelper.HidePopup(this);
  101. }
  102. }
  103. public class ErrEllipse星地两星一地接口
  104. {
  105. /// <summary>
  106. /// 主星星历(Tle)
  107. /// </summary>
  108. public string TleMain { get; set; }
  109. /// <summary>
  110. /// 邻星星历(Tle)
  111. /// </summary>
  112. public string TleAdja { get; set; }
  113. /// <summary>
  114. /// 采集时刻
  115. /// </summary>
  116. public DateTime CapTime { get; set; }
  117. /// <summary>
  118. /// 超短接收站-经度
  119. /// </summary>
  120. public double StationLon { get; set; }
  121. /// <summary>
  122. /// 超短接收站-纬度
  123. /// </summary>
  124. public double StationLat { get; set; }
  125. /// <summary>
  126. /// 参考站位置经度
  127. /// </summary>
  128. public double RefLon { get; set; }
  129. /// <summary>
  130. /// 参考站位置纬度
  131. /// </summary>
  132. public double RefLat { get; set; }
  133. /// <summary>
  134. /// 时差误差(单位us)
  135. /// </summary>
  136. public double DtousErr { get; set; } = 1;
  137. /// <summary>
  138. /// 星历位置误差(单位米)
  139. /// </summary>
  140. public double SatLocErr { get; set; } = 10000;
  141. }
  142. }