X2D1ErrEllipseParam.cs 5.7 KB

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