X3GDOPParam.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using DevExpress.XtraMap;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Collections.Generic;
  7. using XdCxRhDW.Repostory.Model;
  8. using XdCxRhDW.Repostory.EFContext;
  9. using XdCxRhDW.Core.Api;
  10. namespace XdCxRhDW.App.UserControl
  11. {
  12. public partial class X3GDOPParam : DevExpress.XtraEditors.XtraUserControl
  13. {
  14. public MapControl mapControl1;
  15. public X3GDOP星地接口 Model => new X3GDOP星地接口()
  16. {
  17. TleMain = txtTleMain.Text.Trim(),
  18. TleAdja1 = txtTleAdja1.Text.Trim(),
  19. TleAdja2 = txtTleAdja2.Text.Trim(),
  20. CapTime = txtCapTime.DateTime,
  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 X3GDOPParam(PosRes item)
  27. {
  28. InitializeComponent();
  29. txtCapTime.UseDefault();
  30. txtTleMain.UseDoubleClickToSelectAll();
  31. txtTleAdja1.UseDoubleClickToSelectAll();
  32. txtTleAdja2.UseDoubleClickToSelectAll();
  33. txtRefLocation1.UseDoubleClickToSelectAll();
  34. this.txtCapTime.DateTime = item.SigTime;
  35. this.txtDtousErr1.EditValue = 1;
  36. this.txtSatLocErr1.EditValue = 1000;
  37. List<string> xlall = new List<string>();
  38. string mainTle = string.Empty;
  39. string adjaTle1 = string.Empty;
  40. string adjaTle2 = string.Empty;
  41. using (RHDWContext db = new RHDWContext())
  42. {
  43. var sats = db.SatInfos.ToList();
  44. var cg = db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  45. var station = db.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  46. if (station != null)
  47. {
  48. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  49. }
  50. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  51. xlall.AddRange(xlList.Select(m => m.TwoLine));
  52. if (xlall.Count() == 0) return;
  53. if (cg.MainCode.HasValue&&xlList.Any(m => m.SatCode == cg.MainCode.Value))
  54. {
  55. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  56. }
  57. else
  58. {
  59. mainTle = xlList.First().TwoLine;
  60. }
  61. if (cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  62. {
  63. adjaTle1 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  64. }
  65. else
  66. {
  67. adjaTle1 = xlList.First().TwoLine;
  68. }
  69. if (cg.Adja2Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja2Code.Value))
  70. {
  71. adjaTle2 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  72. }
  73. else
  74. {
  75. adjaTle2 = xlList.First().TwoLine;
  76. }
  77. }
  78. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  79. txtTleAdja1.UseDefault().SetStringData(xlall).Text = adjaTle1;
  80. txtTleAdja2.UseDefault().SetStringData(xlall).Text = adjaTle2;
  81. }
  82. private void btnClose_Click(object sender, EventArgs e)
  83. {
  84. DxHelper.PopupHelper.HidePopup(this);
  85. }
  86. private void btnX1D2_Click(object sender, EventArgs e)
  87. {
  88. mapControl1.ClearMap();
  89. var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
  90. var (listSat, data) = GdopHelper.Gdop3Sat(Model.TleMain, Model.TleAdja1, Model.TleAdja2, Model.CapTime
  91. , Model.DtousErr, Model.SatLocErr, refs);
  92. if (data == null)
  93. {
  94. return;
  95. }
  96. foreach (var errLins in data)//画GDOP
  97. {
  98. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  99. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  100. }
  101. }
  102. }
  103. public class X3GDOP星地接口
  104. {
  105. /// <summary>
  106. /// 主星星历(Tle)
  107. /// </summary>
  108. public string TleMain { get; set; }
  109. /// <summary>
  110. /// 邻星1星历(Tle)
  111. /// </summary>
  112. public string TleAdja1 { get; set; }
  113. /// <summary>
  114. /// 邻星2星历(Tle)
  115. /// </summary>
  116. public string TleAdja2 { get; set; }
  117. /// <summary>
  118. /// 采集时刻
  119. /// </summary>
  120. public DateTime CapTime { get; set; }
  121. /// <summary>
  122. /// 参考站位置经度
  123. /// </summary>
  124. public double RefLon { get; set; }
  125. /// <summary>
  126. /// 参考站位置纬度
  127. /// </summary>
  128. public double RefLat { get; set; }
  129. /// <summary>
  130. /// 时差误差(单位us)
  131. /// </summary>
  132. public double DtousErr { get; set; } = 1;
  133. /// <summary>
  134. /// 星历位置误差(单位米)
  135. /// </summary>
  136. public double SatLocErr { get; set; } = 10000;
  137. }
  138. }