X2D1GDOPParam.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using DevExpress.XtraEditors;
  2. using DevExpress.XtraMap;
  3. using DxHelper;
  4. using ExtensionsDev;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using XzXdDw.App;
  15. using XzXdDw.App.Model;
  16. using XzXdDw.App.Api.星地GDOP误差椭圆;
  17. using XzXdDw.App.EFContext;
  18. namespace XdCxRhDW.App.UserControl
  19. {
  20. public partial class X2D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  21. {
  22. public MapControl mapControl1;
  23. public GDOP星地两星一地接口 Model=> new GDOP星地两星一地接口()
  24. {
  25. TleMain = txtTleMain.Text.Trim(),
  26. TleAdja = txtTleAdja.Text.Trim(),
  27. CapTime = txtCapTime.DateTime,
  28. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  29. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  30. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  31. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  32. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  33. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  34. };
  35. public X2D1GDOPParam(DateTime sigTime)
  36. {
  37. InitializeComponent();
  38. txtCapTime.UseDefault();
  39. txtTleMain.UseDoubleClickToSelectAll();
  40. txtTleAdja.UseDoubleClickToSelectAll();
  41. txtStationLocation1.UseDoubleClickToSelectAll();
  42. txtRefLocation1.UseDoubleClickToSelectAll();
  43. List<TxInfo> listTx = new List<TxInfo>();
  44. using (RHDWContext db = new RHDWContext())
  45. {
  46. listTx = db.TxInfos.ToList();
  47. }
  48. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  49. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  50. this.txtCapTime.DateTime = sigTime;
  51. this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
  52. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  53. txtTleMain.UseDefault().SetStringData(TestData.AllTle) ;
  54. txtTleMain.Text = TestData.TleMain;
  55. txtTleAdja.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleAdja1;
  56. this.txtDtousErr1.EditValue = TestData.DtousErr;
  57. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  58. }
  59. private void btnOK_Click(object sender, EventArgs e)
  60. {
  61. mapControl1.ClearMap();
  62. var (listSat, data) = GdopHelper.Gdop2Sat1DRef(Model.TleMain, Model.TleAdja, Model.CapTime, new double[] { Model.StationLon, Model.StationLat, 0 },
  63. new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr);
  64. // var TleMain = "1 23467U 95003A 23357.44874407 -.00000021 00000+0 00000+0 0 9999;2 23467 9.7425 16.0141 0003225 208.7887 200.6055 1.00272282105868";
  65. // var TleAdja = "1 37256U 10068A 23357.77999653 -.00000213 00000+0 00000+0 0 9998;2 37256 49.2064 282.9700 0029000 212.5882 341.7791 1.00248080 47698";
  66. // var CapTime = new DateTime(2024, 3, 10,13,06,31);
  67. // var StationLon =122;
  68. // var StationLat =30;
  69. //var RefLon =121;
  70. // var RefLat =30;
  71. // var DtousErr =1;
  72. // var SatLocErr =1000;
  73. // var (listSat, data) = GdopHelper.Gdop2Sat1DRef(TleMain, TleAdja, CapTime, new double[] { StationLon, StationLat, 0 },
  74. // new double[] { RefLon, RefLat, 0 }, DtousErr, SatLocErr);
  75. if (data == null)
  76. {
  77. return;
  78. }
  79. if (listSat != null)//画卫星
  80. {
  81. foreach (var sat in listSat)
  82. {
  83. mapControl1.Invoke(new Action(() =>
  84. {
  85. string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString();
  86. mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°");
  87. mapControl1.DrawEllipse(sat.SatLat, sat.SatLon, 4800);
  88. }));
  89. }
  90. }
  91. if ((Model.StationLon >= 180 || Model.StationLon <= 180) && Model.StationLat >= -90 || Model.StationLat <= 90)//画天线
  92. {
  93. mapControl1.Invoke(new Action(() =>
  94. {
  95. mapControl1.DrawFixedImg("cdb", Model.StationLat, Model.StationLon, SvgHelper.LoadFromFile("Image\\tx.svg"), new Size(32, 32), $"超短站经度:{Model.StationLon}°\r\n超短站纬度:{Model.StationLat}°");
  96. }));
  97. }
  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. public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
  105. {
  106. var dots = line.Line;
  107. if (dots.Count < 30) return line;
  108. var tmp = dots.Count / 30;
  109. var newLine = new XdCxRhDW.App.DTO.MapLine();
  110. for (int i = 0; i < dots.Count; i += tmp)
  111. {
  112. newLine.Line.Add(dots[i]);
  113. }
  114. if (!newLine.Line.Contains(dots.Last()))
  115. newLine.Line.Add(dots.Last());
  116. return newLine;
  117. }
  118. private void btnClose_Click(object sender, EventArgs e)
  119. {
  120. PopupHelper.HidePopup(this);
  121. }
  122. }
  123. public class GDOP星地两星一地接口
  124. {
  125. /// <summary>
  126. /// 主星星历(Tle)
  127. /// </summary>
  128. public string TleMain { get; set; }
  129. /// <summary>
  130. /// 邻星星历(Tle)
  131. /// </summary>
  132. public string TleAdja { get; set; }
  133. /// <summary>
  134. /// 采集时刻
  135. /// </summary>
  136. public DateTime CapTime { get; set; }
  137. /// <summary>
  138. /// 超短接收站-经度
  139. /// </summary>
  140. public double StationLon { get; set; }
  141. /// <summary>
  142. /// 超短接收站-纬度
  143. /// </summary>
  144. public double StationLat { get; set; }
  145. /// <summary>
  146. /// 参考站位置经度
  147. /// </summary>
  148. public double RefLon { get; set; }
  149. /// <summary>
  150. /// 参考站位置纬度
  151. /// </summary>
  152. public double RefLat { get; set; }
  153. /// <summary>
  154. /// 时差误差(单位us)
  155. /// </summary>
  156. public double DtousErr { get; set; } = 1;
  157. /// <summary>
  158. /// 星历位置误差(单位米)
  159. /// </summary>
  160. public double SatLocErr { get; set; } = 10000;
  161. }
  162. }