XZGDOPParam .cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. errLins.ErrDistance = errLins.ErrDistance / 10;
  79. foreach (var line in errLins.MapLines)
  80. {
  81. var newLine = SampleDots(line);
  82. mapControl1.Invoke(new Action(() =>
  83. {
  84. var mapLines = newLine.Line.Select(p => (errLins.ErrDistanceKm, p.Lon, p.Lat));
  85. mapControl1.DrawGdopLine(mapLines);
  86. }));
  87. }
  88. }
  89. }
  90. public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
  91. {
  92. var dots = line.Line;
  93. if (dots.Count < 30) return line;
  94. var tmp = dots.Count / 30;
  95. var newLine = new XdCxRhDW.App.DTO.MapLine();
  96. for (int i = 0; i < dots.Count; i += tmp)
  97. {
  98. newLine.Line.Add(dots[i]);
  99. }
  100. if (!newLine.Line.Contains(dots.Last()))
  101. newLine.Line.Add(dots.Last());
  102. return newLine;
  103. }
  104. private void btnClose_Click(object sender, EventArgs e)
  105. {
  106. PopupHelper.HidePopup(this);
  107. }
  108. }
  109. public class GDOP星座协同接口
  110. {
  111. /// <summary>
  112. /// 主星星历(Tle)
  113. /// </summary>
  114. public string TleLeo1 { get; set; }
  115. /// <summary>
  116. /// 邻星星历(Tle)
  117. /// </summary>
  118. public string TleLeo2 { get; set; }
  119. /// <summary>
  120. /// 采集时刻
  121. /// </summary>
  122. public DateTime CapTime { get; set; }
  123. /// <summary>
  124. /// 参考站位置经度
  125. /// </summary>
  126. public double RefLon { get; set; }
  127. /// <summary>
  128. /// 参考站位置纬度
  129. /// </summary>
  130. public double RefLat { get; set; }
  131. /// <summary>
  132. /// 时差误差(单位us)
  133. /// </summary>
  134. public double DtousErr { get; set; } = 1;
  135. /// <summary>
  136. /// 频差误差(Hz)
  137. /// </summary>
  138. public double DfoErr { get; set; }
  139. /// <summary>
  140. /// 星历位置误差(单位米)
  141. /// </summary>
  142. public double SatLocErr { get; set; } = 10000;
  143. /// <summary>
  144. ///星历速度误差
  145. /// </summary>
  146. public double EphVelErr { get; set; }
  147. /// <summary>
  148. /// 上行频点1(Hz)
  149. /// </summary>
  150. public double fu1 { get; set; }
  151. /// <summary>
  152. /// 上行频点2(Hz)
  153. /// </summary>
  154. public double fu2 { get; set; }
  155. }
  156. }