X2D1ErrEllipseParam.cs 6.1 KB

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