X3GDOPParam.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 = PosResType == EnumPosResType.X3NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  22. RefLat = PosResType == EnumPosResType.X3NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  23. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  24. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  25. };
  26. private EnumPosResType PosResType;
  27. public X3GDOPParam(PosRes item)
  28. {
  29. InitializeComponent();
  30. txtCapTime.UseDefault();
  31. txtTleMain.UseDoubleClickToSelectAll();
  32. txtTleAdja1.UseDoubleClickToSelectAll();
  33. txtTleAdja2.UseDoubleClickToSelectAll();
  34. txtRefLocation1.UseDoubleClickToSelectAll();
  35. this.txtCapTime.DateTime = item.SigTime;
  36. this.txtDtousErr1.EditValue = 1;
  37. this.txtSatLocErr1.EditValue = 1000;
  38. PosResType = item.PosResType;
  39. if (PosResType == EnumPosResType.X3NoRef)
  40. {
  41. layoutControlItem14.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
  42. }
  43. List<string> xlall = new List<string>();
  44. string mainTle = string.Empty;
  45. string adjaTle1 = string.Empty;
  46. string adjaTle2 = string.Empty;
  47. using (RHDWContext db = new RHDWContext())
  48. {
  49. var sats = db.SatInfos.ToList();
  50. var cg = db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  51. var station = db.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  52. if (station != null)
  53. {
  54. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  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 (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  60. {
  61. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  62. }
  63. else
  64. {
  65. mainTle = xlList.First().TwoLine;
  66. }
  67. if (cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  68. {
  69. adjaTle1 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  70. }
  71. else
  72. {
  73. adjaTle1 = xlList.First().TwoLine;
  74. }
  75. if (cg.Adja2Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja2Code.Value))
  76. {
  77. adjaTle2 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  78. }
  79. else
  80. {
  81. adjaTle2 = xlList.First().TwoLine;
  82. }
  83. }
  84. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  85. txtTleAdja1.UseDefault().SetStringData(xlall).Text = adjaTle1;
  86. txtTleAdja2.UseDefault().SetStringData(xlall).Text = adjaTle2;
  87. }
  88. private void btnClose_Click(object sender, EventArgs e)
  89. {
  90. DxHelper.PopupHelper.HidePopup(this);
  91. }
  92. private void btnX1D2_Click(object sender, EventArgs e)
  93. {
  94. mapControl1.ClearMap();
  95. var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
  96. var (listSat, data) = GdopHelper.Gdop3Sat(Model.TleMain, Model.TleAdja1, Model.TleAdja2, Model.CapTime
  97. , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X3NoRef ? null : refs);
  98. if (data == null)
  99. {
  100. return;
  101. }
  102. foreach (var errLins in data)//画GDOP
  103. {
  104. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  105. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  106. }
  107. }
  108. }
  109. public class X3GDOP星地接口
  110. {
  111. /// <summary>
  112. /// 主星星历(Tle)
  113. /// </summary>
  114. public string TleMain { get; set; }
  115. /// <summary>
  116. /// 邻星1星历(Tle)
  117. /// </summary>
  118. public string TleAdja1 { get; set; }
  119. /// <summary>
  120. /// 邻星2星历(Tle)
  121. /// </summary>
  122. public string TleAdja2 { get; set; }
  123. /// <summary>
  124. /// 采集时刻
  125. /// </summary>
  126. public DateTime CapTime { get; set; }
  127. /// <summary>
  128. /// 参考站位置经度
  129. /// </summary>
  130. public double RefLon { get; set; }
  131. /// <summary>
  132. /// 参考站位置纬度
  133. /// </summary>
  134. public double RefLat { get; set; }
  135. /// <summary>
  136. /// 时差误差(单位us)
  137. /// </summary>
  138. public double DtousErr { get; set; } = 1;
  139. /// <summary>
  140. /// 星历位置误差(单位米)
  141. /// </summary>
  142. public double SatLocErr { get; set; } = 10000;
  143. }
  144. }