XZGDOPParam .cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using DevExpress.Mvvm.ModuleInjection.Native;
  2. using DevExpress.XtraEditors;
  3. using DevExpress.XtraMap;
  4. using DxHelper;
  5. using ExtensionsDev;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using XzXdDw.App;
  16. using XzXdDw.App.Api.星地GDOP误差椭圆;
  17. using XzXdDw.App.Model;
  18. namespace XdCxRhDW.App.UserControl
  19. {
  20. public partial class XZGDOPParam : DevExpress.XtraEditors.XtraUserControl
  21. {
  22. public MapControl mapControl1;
  23. public GDOP星座协同接口 Model => new GDOP星座协同接口()
  24. {
  25. TleLeo1 = txtTleLeo1.Text.Trim(),
  26. TleLeo2 = txtTleLeo2.Text.Trim(),
  27. CapTime = txtCapTime.DateTime,
  28. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  29. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  30. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  31. DfoErr = Convert.ToDouble(txtDfoErr1.Text),
  32. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  33. EphVelErr = Convert.ToDouble(txtEphVelErr1.Text),
  34. fu1 = Convert.ToDouble(txtFu1.Text) * 1e6,
  35. fu2 = Convert.ToDouble(txtFu2.Text) * 1e6,
  36. };
  37. public XZGDOPParam(TxInfo refTx, DateTime sigTime, double upfreqHz1, double upfreqHz2)
  38. {
  39. InitializeComponent();
  40. txtCapTime.UseDefault();
  41. txtTleLeo1.UseDoubleClickToSelectAll();
  42. txtTleLeo2.UseDoubleClickToSelectAll();
  43. txtRefLocation1.UseDoubleClickToSelectAll();
  44. this.txtCapTime.DateTime = sigTime;
  45. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  46. txtTleLeo1.UseDefault().SetStringData(TestData.AllTle).Text = TestData.tleleo1;
  47. txtTleLeo2.UseDefault().SetStringData(TestData.AllTle).Text = TestData.tleleo2;
  48. this.txtDtousErr1.EditValue = TestData.DtousErr;
  49. this.txtDfoErr1.EditValue = TestData.DfoHzErr;
  50. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  51. this.txtEphVelErr1.EditValue = TestData.EphVelErr;
  52. this.txtFu1.EditValue = upfreqHz1 * 1e-6;
  53. this.txtFu2.EditValue = upfreqHz2 * 1e-6;
  54. }
  55. private void btnOK_Click(object sender, EventArgs e)
  56. {
  57. mapControl1.ClearMap();
  58. var (listSat, data) = GdopHelper.GdopLeoTowSatDRef(
  59. new double[] { Model.RefLon, Model.RefLat }, Model.TleLeo1, Model.TleLeo2, Model.CapTime, Model.DtousErr, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, Model.fu1, Model.fu2);
  60. if (data == null)
  61. {
  62. return;
  63. }
  64. if (listSat != null)//画卫星
  65. {
  66. foreach (var sat in listSat)
  67. {
  68. mapControl1.Invoke(new Action(() =>
  69. {
  70. string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString();
  71. mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°");
  72. mapControl1.DrawEllipse(sat.SatLat, sat.SatLon, 2225);
  73. }));
  74. }
  75. }
  76. foreach (var errLins in data)//画GDOP
  77. {
  78. foreach (var line in errLins.MapLines)
  79. {
  80. var newLine = SampleDots(line);
  81. mapControl1.Invoke(new Action(() =>
  82. {
  83. var mapLines = newLine.Line.Select(p => (errLins.ErrDistanceKm, p.Lon, p.Lat));
  84. mapControl1.DrawGdopLine(mapLines);
  85. }));
  86. }
  87. }
  88. }
  89. public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
  90. {
  91. var dots = line.Line;
  92. if (dots.Count < 30) return line;
  93. var tmp = dots.Count / 30;
  94. var newLine = new XdCxRhDW.App.DTO.MapLine();
  95. for (int i = 0; i < dots.Count; i += tmp)
  96. {
  97. newLine.Line.Add(dots[i]);
  98. }
  99. if (!newLine.Line.Contains(dots.Last()))
  100. newLine.Line.Add(dots.Last());
  101. return newLine;
  102. }
  103. private void btnClose_Click(object sender, EventArgs e)
  104. {
  105. PopupHelper.HidePopup(this);
  106. }
  107. }
  108. public class GDOP星座协同接口
  109. {
  110. /// <summary>
  111. /// 主星星历(Tle)
  112. /// </summary>
  113. public string TleLeo1 { get; set; }
  114. /// <summary>
  115. /// 邻星星历(Tle)
  116. /// </summary>
  117. public string TleLeo2 { get; set; }
  118. /// <summary>
  119. /// 采集时刻
  120. /// </summary>
  121. public DateTime CapTime { get; set; }
  122. /// <summary>
  123. /// 参考站位置经度
  124. /// </summary>
  125. public double RefLon { get; set; }
  126. /// <summary>
  127. /// 参考站位置纬度
  128. /// </summary>
  129. public double RefLat { get; set; }
  130. /// <summary>
  131. /// 时差误差(单位us)
  132. /// </summary>
  133. public double DtousErr { get; set; } = 1;
  134. /// <summary>
  135. /// 频差误差(Hz)
  136. /// </summary>
  137. public double DfoErr { get; set; }
  138. /// <summary>
  139. /// 星历位置误差(单位米)
  140. /// </summary>
  141. public double SatLocErr { get; set; } = 10000;
  142. /// <summary>
  143. ///星历速度误差
  144. /// </summary>
  145. public double EphVelErr { get; set; }
  146. /// <summary>
  147. /// 上行频点1(Hz)
  148. /// </summary>
  149. public double fu1 { get; set; }
  150. /// <summary>
  151. /// 上行频点2(Hz)
  152. /// </summary>
  153. public double fu2 { get; set; }
  154. }
  155. }