GDOPParam.cs 6.3 KB

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