X2D1ErrEllipseParam.cs 6.0 KB

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