X2D1GDOPParam.cs 6.4 KB

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