X2D1GDOPParam.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. namespace XdCxRhDW.App.UserControl
  18. {
  19. public partial class X2D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  20. {
  21. public MapControl mapControl1;
  22. public GDOP星地两星一地接口 Model => new GDOP星地两星一地接口()
  23. {
  24. TleMain = txtTleMain.Text.Trim(),
  25. TleAdja = txtTleAdja.Text.Trim(),
  26. CapTime = txtCapTime.DateTime,
  27. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  28. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  29. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  30. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  31. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  32. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  33. };
  34. public X2D1GDOPParam()
  35. {
  36. InitializeComponent();
  37. }
  38. private void X2D1GDOPParam_Load(object sender, EventArgs e)
  39. {
  40. txtCapTime.UseDefault();
  41. txtCapTime.DateTime = TestData.Time;
  42. txtTleMain.UseDoubleClickToSelectAll();
  43. txtTleAdja.UseDoubleClickToSelectAll();
  44. txtStationLocation1.UseDoubleClickToSelectAll();
  45. txtRefLocation1.UseDoubleClickToSelectAll();
  46. this.txtCapTime.DateTime = TestData.Time;
  47. this.txtStationLocation1.Text = TestData.RecLoc;
  48. this.txtRefLocation1.Text = TestData.RefLoc;
  49. txtTleMain.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleMain;
  50. txtTleAdja.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleAdja1;
  51. this.txtDtousErr1.EditValue = TestData.DtousErr;
  52. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  53. }
  54. private void btnOK_Click(object sender, EventArgs e)
  55. {
  56. mapControl1.ClearMap();
  57. var (listSat, data) = GdopHelper.Gdop2Sat1DRef(new double[] { Model.StationLon, Model.StationLat },
  58. new double[] { Model.RefLon, Model.RefLat }, Model.TleMain, Model.TleAdja, Model.CapTime, Model.DtousErr, Model.SatLocErr);
  59. if (data == null)
  60. {
  61. return;
  62. }
  63. if (listSat != null)//画卫星
  64. {
  65. foreach (var sat in listSat)
  66. {
  67. mapControl1.Invoke(new Action(() =>
  68. {
  69. string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString();
  70. mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°");
  71. }));
  72. }
  73. }
  74. if ((Model.StationLon >= 180 || Model.StationLon <= 180) && Model.StationLat >= -90 || Model.StationLat <= 90)//画天线
  75. {
  76. mapControl1.Invoke(new Action(() =>
  77. {
  78. mapControl1.DrawFixedImg("cdb", Model.StationLat, Model.StationLon, SvgHelper.LoadFromFile("Image\\tx.svg"), new Size(32, 32), $"超短站经度:{Model.StationLon}°\r\n超短站纬度:{Model.StationLat}°");
  79. }));
  80. }
  81. foreach (var errLins in data)//画GDOP
  82. {
  83. foreach (var line in errLins.MapLines)
  84. {
  85. var newLine = SampleDots(line);
  86. mapControl1.Invoke(new Action(() =>
  87. {
  88. var mapLines = newLine.Line.Select(p => (errLins.ErrDistanceKm, p.Lon, p.Lat));
  89. mapControl1.DrawGdopLine(mapLines);
  90. }));
  91. }
  92. }
  93. }
  94. public DTO.MapLine SampleDots(DTO.MapLine line)
  95. {
  96. var dots = line.Line;
  97. if (dots.Count < 30) return line;
  98. var tmp = dots.Count / 30;
  99. var newLine = new DTO.MapLine();
  100. for (int i = 0; i < dots.Count; i += tmp)
  101. {
  102. newLine.Line.Add(dots[i]);
  103. }
  104. if (!newLine.Line.Contains(dots.Last()))
  105. newLine.Line.Add(dots.Last());
  106. return newLine;
  107. }
  108. private void btnClose_Click(object sender, EventArgs e)
  109. {
  110. PopupHelper.HidePopup(this);
  111. }
  112. }
  113. public class GDOP星地两星一地接口
  114. {
  115. /// <summary>
  116. /// 主星星历(Tle)
  117. /// </summary>
  118. public string TleMain { get; set; }
  119. /// <summary>
  120. /// 邻星星历(Tle)
  121. /// </summary>
  122. public string TleAdja { get; set; }
  123. /// <summary>
  124. /// 采集时刻
  125. /// </summary>
  126. public DateTime CapTime { get; set; }
  127. /// <summary>
  128. /// 超短接收站-经度
  129. /// </summary>
  130. public double StationLon { get; set; }
  131. /// <summary>
  132. /// 超短接收站-纬度
  133. /// </summary>
  134. public double StationLat { get; set; }
  135. /// <summary>
  136. /// 参考站位置经度
  137. /// </summary>
  138. public double RefLon { get; set; }
  139. /// <summary>
  140. /// 参考站位置纬度
  141. /// </summary>
  142. public double RefLat { get; set; }
  143. /// <summary>
  144. /// 时差误差(单位us)
  145. /// </summary>
  146. public double DtousErr { get; set; } = 1;
  147. /// <summary>
  148. /// 星历位置误差(单位米)
  149. /// </summary>
  150. public double SatLocErr { get; set; } = 10000;
  151. }
  152. }