X2D1GDOPParam.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 X2D1GDOPParam : 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 = PosResType == EnumPosResType.X2D1NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  23. RefLat = PosResType == EnumPosResType.X2D1NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  24. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  25. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  26. };
  27. private EnumPosResType PosResType;
  28. public X2D1GDOPParam(PosRes item)
  29. {
  30. InitializeComponent();
  31. txtCapTime.UseDefault();
  32. txtTleMain.UseDoubleClickToSelectAll();
  33. txtTleAdja.UseDoubleClickToSelectAll();
  34. txtStationLocation1.UseDoubleClickToSelectAll();
  35. txtRefLocation1.UseDoubleClickToSelectAll();
  36. this.txtCapTime.DateTime = item.SigTime;
  37. this.txtDtousErr1.EditValue = 1;
  38. this.txtSatLocErr1.EditValue = 1000;
  39. List<string> xlall = new List<string>();
  40. string mainTle = string.Empty;
  41. string adjaTle = string.Empty;
  42. PosResType = item.PosResType;
  43. if (PosResType == EnumPosResType.X2D1NoRef)
  44. {
  45. layoutControlItem14.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
  46. }
  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.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
  55. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  56. }
  57. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  58. xlall.AddRange(xlList.Select(m => m.TwoLine));
  59. if (xlall.Count() == 0) return;
  60. if (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  61. {
  62. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  63. }
  64. else
  65. {
  66. mainTle = xlList.First().TwoLine;
  67. }
  68. if (cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  69. {
  70. adjaTle = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  71. }
  72. else
  73. {
  74. adjaTle = xlList.First().TwoLine;
  75. }
  76. }
  77. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  78. txtTleAdja.UseDefault().SetStringData(xlall).Text = adjaTle;
  79. }
  80. private void btnOK_Click(object sender, EventArgs e)
  81. {
  82. mapControl1.ClearMap();
  83. var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  84. var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  85. var (listSat, data) = GdopHelper.Gdop2Sat1D(Model.TleMain, Model.TleAdja, Model.CapTime, cdb
  86. , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X2D1NoRef ? null : refstation);
  87. //var TleMain = "1 39206U 13036A 23202.42807559 .00000070 00000+0 00000+0 0 9997;2 39206 3.1191 34.4939 0054311 175.9148 65.5730 1.00271529 36651";
  88. //var TleAdja = "1 40892U 15046A 23201.78591034 -.00000153 00000+0 00000+0 0 9992;2 40892 0.0465 209.7898 0002849 182.8710 343.4998 1.00270904 28905";
  89. //var CapTime = new DateTime(2023, 7, 1, 9,00,30);
  90. //var StationLon = 122;
  91. //var StationLat = 30;
  92. //var RefLon = 121;
  93. //var RefLat = 30;
  94. //var DtousErr = 1;
  95. //var SatLocErr = 1000;
  96. //var (listSat, data) = GdopHelper.Gdop2Sat1D(TleMain, TleAdja, CapTime, new double[] { StationLon, StationLat, 0 },
  97. // DtousErr, SatLocErr, new double[] { RefLon, RefLat, 0 });
  98. foreach (var errLins in data)//画GDOP
  99. {
  100. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  101. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  102. }
  103. }
  104. private void btnClose_Click(object sender, EventArgs e)
  105. {
  106. DxHelper.PopupHelper.HidePopup(this);
  107. }
  108. }
  109. public class GDOP星地两星一地接口
  110. {
  111. /// <summary>
  112. /// 主星星历(Tle)
  113. /// </summary>
  114. public string TleMain { get; set; }
  115. /// <summary>
  116. /// 邻星星历(Tle)
  117. /// </summary>
  118. public string TleAdja { get; set; }
  119. /// <summary>
  120. /// 采集时刻
  121. /// </summary>
  122. public DateTime CapTime { get; set; }
  123. /// <summary>
  124. /// 超短接收站-经度
  125. /// </summary>
  126. public double StationLon { get; set; }
  127. /// <summary>
  128. /// 超短接收站-纬度
  129. /// </summary>
  130. public double StationLat { get; set; }
  131. /// <summary>
  132. /// 参考站位置经度
  133. /// </summary>
  134. public double RefLon { get; set; }
  135. /// <summary>
  136. /// 参考站位置纬度
  137. /// </summary>
  138. public double RefLat { get; set; }
  139. /// <summary>
  140. /// 时差误差(单位us)
  141. /// </summary>
  142. public double DtousErr { get; set; } = 1;
  143. /// <summary>
  144. /// 星历位置误差(单位米)
  145. /// </summary>
  146. public double SatLocErr { get; set; } = 10000;
  147. /// <summary>
  148. /// 定位类型
  149. /// </summary>
  150. public EnumPosResType PosResType { get; set; }
  151. }
  152. }