X1D1GDOPParam.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using DevExpress.XtraMap;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Data;
  5. using System.Linq;
  6. using XdCxRhDW.App.Model;
  7. using XdCxRhDW.App.EFContext;
  8. using XdCxRhDW.App.Api.GDOP误差椭圆;
  9. using System.Collections.Generic;
  10. namespace XdCxRhDW.App.UserControl
  11. {
  12. public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  13. {
  14. public MapControl mapControl1;
  15. public GDOP星地一星一地接口 Model => new GDOP星地一星一地接口()
  16. {
  17. TleMain = txtTleMain.Text.Trim(),
  18. CapTime = txtCapTime.DateTime,
  19. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  20. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  21. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  22. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  23. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  24. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  25. };
  26. public X1D1GDOPParam(DateTime sigTime)
  27. {
  28. InitializeComponent();
  29. txtCapTime.UseDefault();
  30. txtTleMain.UseDoubleClickToSelectAll();
  31. txtStationLocation1.UseDoubleClickToSelectAll();
  32. txtRefLocation1.UseDoubleClickToSelectAll();
  33. this.txtCapTime.DateTime = sigTime;
  34. this.txtDtousErr1.EditValue = 1;
  35. this.txtSatLocErr1.EditValue = 1000;
  36. List<string> xlall = new List<string>();
  37. string mainTle = string.Empty;
  38. string adjaTle = string.Empty;
  39. using (RHDWContext db = new RHDWContext())
  40. {
  41. var sats = db.SatInfos.ToList();
  42. var list = db.TxInfos.ToList();
  43. var mainTx = list.Find(p => p.TxType == EnumTxType.MainSat);
  44. var adjaTx = list.Find(p => p.TxType == EnumTxType.AdjaSat);
  45. var cdbTx = list.Find(p => p.TxType == EnumTxType.Cdb);
  46. if (cdbTx != null)
  47. {
  48. this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
  49. }
  50. var cxTx = list.Find(p => p.TxType == EnumTxType.Cx);
  51. var refLoc = list.Find(p => p.TxType == EnumTxType.Ref);
  52. if (refLoc != null)
  53. {
  54. this.txtRefLocation1.Text = $"{refLoc.Lon},{refLoc.Lat}";
  55. }
  56. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  57. xlall.AddRange(xlList.Select(m => m.TwoLine));
  58. if (xlall.Count() == 0) return;
  59. if (mainTx != null && xlList.Any(m => m.SatCode == mainTx.SatInfo.SatCode))
  60. {
  61. mainTle = xlList.First(m => m.SatCode == mainTx.SatInfo.SatCode).TwoLine;
  62. }
  63. else
  64. {
  65. mainTle = xlList.First().TwoLine;
  66. }
  67. if (adjaTx != null && xlList.Any(m => m.SatCode == adjaTx.SatInfo.SatCode))
  68. {
  69. adjaTle = xlList.First(m => m.SatCode == adjaTx.SatInfo.SatCode).TwoLine;
  70. }
  71. else
  72. {
  73. adjaTle = xlList.First().TwoLine;
  74. }
  75. }
  76. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  77. }
  78. private void btnOK_Click(object sender, EventArgs e)
  79. {
  80. mapControl1.ClearMap();
  81. var (listSat, data) = GdopHelper.Gdop2Sat1DRef(Model.TleMain,"", Model.CapTime, new double[] { Model.StationLon, Model.StationLat, 0 },
  82. new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr);
  83. if (data == null)
  84. {
  85. return;
  86. }
  87. foreach (var errLins in data)//画GDOP
  88. {
  89. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  90. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  91. }
  92. }
  93. private void btnClose_Click(object sender, EventArgs e)
  94. {
  95. DxHelper.PopupHelper.HidePopup(this);
  96. }
  97. }
  98. public class GDOP星地一星一地接口
  99. {
  100. /// <summary>
  101. /// 主星星历(Tle)
  102. /// </summary>
  103. public string TleMain { get; set; }
  104. /// <summary>
  105. /// 采集时刻
  106. /// </summary>
  107. public DateTime CapTime { get; set; }
  108. /// <summary>
  109. /// 超短接收站-经度
  110. /// </summary>
  111. public double StationLon { get; set; }
  112. /// <summary>
  113. /// 超短接收站-纬度
  114. /// </summary>
  115. public double StationLat { get; set; }
  116. /// <summary>
  117. /// 参考站位置经度
  118. /// </summary>
  119. public double RefLon { get; set; }
  120. /// <summary>
  121. /// 参考站位置纬度
  122. /// </summary>
  123. public double RefLat { get; set; }
  124. /// <summary>
  125. /// 时差误差(单位us)
  126. /// </summary>
  127. public double DtousErr { get; set; } = 1;
  128. /// <summary>
  129. /// 星历位置误差(单位米)
  130. /// </summary>
  131. public double SatLocErr { get; set; } = 10000;
  132. }
  133. }