X2D1ErrEllipseParam.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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(long cgResID)
  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. CgRes cg;
  48. using (RHDWContext db = new RHDWContext())
  49. {
  50. listTx = db.TxInfos.ToList();
  51. cg = db.CgRes.Where(m => m.ID == cgResID).FirstOrDefault();
  52. }
  53. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  54. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  55. this.txtCapTime.DateTime = cg.SigTime;
  56. this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
  57. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  58. txtTleMain.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleMain;
  59. txtTleAdja.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleAdja1;
  60. this.txtDtousErr1.EditValue = TestData.DtousErr;
  61. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  62. }
  63. private void btnOK_Click(object sender, EventArgs e)
  64. {
  65. mapControl1.ClearMap();
  66. double[] main_sat = Tle2XYZ.GetXyz(Model.TleMain, Model.CapTime);
  67. double[] adja_sat = Tle2XYZ.GetXyz(Model.TleAdja, Model.CapTime);
  68. 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);
  69. }
  70. private void DrawErrorEllipse2X1D(double posLon, double posLat, double[] MsEph, double[] NsEph, double[] CDBAnt, double[] RefGeod, double DtoErr, double EphErr)
  71. {
  72. try
  73. {
  74. List<TxInfo> listTx = new List<TxInfo>();
  75. List<XzXdDw.App.Model.SatInfo> listSat = new List<XzXdDw.App.Model.SatInfo>();
  76. using (RHDWContext db = new RHDWContext())
  77. {
  78. listTx = db.TxInfos.ToList();
  79. listSat = db.SatInfos.ToList();
  80. }
  81. var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
  82. var satNTx = listTx.Find(p => p.TxType == EnumTxType.AdjaSat);
  83. ErrorEllipseDTO2X1DOption Option = new ErrorEllipseDTO2X1DOption();
  84. Option.MsEph = MsEph;
  85. Option.NsEph = NsEph;
  86. Option.CDBAnt = CDBAnt;
  87. Option.RefGeod = RefGeod;
  88. Option.SelectPoint = new double[3] { posLon, posLat, 0 };
  89. Option.DtoErr = DtoErr * 1e-6;
  90. Option.EphErr = EphErr;
  91. var points = ErrEllipseHelper.ErrorEllipse2X1D(Option);
  92. mapControl1.DrawDtoPonit($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]误差椭圆线", points);
  93. }
  94. catch (Exception ex)
  95. {
  96. Serilog.Log.Error("绘制误差椭圆线失败", ex);
  97. XtraMessageBox.Show($"绘制误差椭圆线失败,失败信息:{ex.Message}");
  98. }
  99. }
  100. private void btnClose_Click(object sender, EventArgs e)
  101. {
  102. PopupHelper.HidePopup(this);
  103. }
  104. }
  105. public class ErrEllipse星地两星一地接口
  106. {
  107. /// <summary>
  108. /// 主星星历(Tle)
  109. /// </summary>
  110. public string TleMain { get; set; }
  111. /// <summary>
  112. /// 邻星星历(Tle)
  113. /// </summary>
  114. public string TleAdja { get; set; }
  115. /// <summary>
  116. /// 采集时刻
  117. /// </summary>
  118. public DateTime CapTime { get; set; }
  119. /// <summary>
  120. /// 超短接收站-经度
  121. /// </summary>
  122. public double StationLon { get; set; }
  123. /// <summary>
  124. /// 超短接收站-纬度
  125. /// </summary>
  126. public double StationLat { get; set; }
  127. /// <summary>
  128. /// 参考站位置经度
  129. /// </summary>
  130. public double RefLon { get; set; }
  131. /// <summary>
  132. /// 参考站位置纬度
  133. /// </summary>
  134. public double RefLat { get; set; }
  135. /// <summary>
  136. /// 时差误差(单位us)
  137. /// </summary>
  138. public double DtousErr { get; set; } = 1;
  139. /// <summary>
  140. /// 星历位置误差(单位米)
  141. /// </summary>
  142. public double SatLocErr { get; set; } = 10000;
  143. }
  144. }