X2D1GDOPParam.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 XdCxRhDW.App.Model;
  12. using XdCxRhDW.App.EFContext;
  13. using System.Data.Entity;
  14. using System.Windows.Documents;
  15. using XdCxRhDW.App.Api.GDOP误差椭圆;
  16. namespace XdCxRhDW.App.UserControl
  17. {
  18. public partial class X2D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  19. {
  20. public MapControl mapControl1;
  21. public GDOP星地两星一地接口 Model => new GDOP星地两星一地接口()
  22. {
  23. TleMain = txtTleMain.Text.Trim(),
  24. TleAdja = txtTleAdja.Text.Trim(),
  25. CapTime = txtCapTime.DateTime,
  26. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  27. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  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. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  32. };
  33. public X2D1GDOPParam(DateTime sigTime)
  34. {
  35. InitializeComponent();
  36. txtCapTime.UseDefault();
  37. txtTleMain.UseDoubleClickToSelectAll();
  38. txtTleAdja.UseDoubleClickToSelectAll();
  39. txtStationLocation1.UseDoubleClickToSelectAll();
  40. txtRefLocation1.UseDoubleClickToSelectAll();
  41. List<TxInfo> listTx = new List<TxInfo>();
  42. using (RHDWContext db = new RHDWContext())
  43. {
  44. listTx = db.TxInfos.ToList();
  45. }
  46. var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
  47. if (cdbTx != null)
  48. {
  49. this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
  50. }
  51. var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
  52. if (cdbTx != null)
  53. {
  54. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  55. }
  56. this.txtCapTime.DateTime = sigTime;
  57. List<XlInfo> xlList = new List<XlInfo>();
  58. using (RHDWContext db = new RHDWContext())
  59. {
  60. var res = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ);
  61. xlList.AddRange(res.ToList());
  62. }
  63. this.txtDtousErr1.EditValue = 1;
  64. this.txtSatLocErr1.EditValue = 1000;
  65. var xlall = xlList.Select(m => m.TwoLine);
  66. if (xlall.Count() == 0) return;
  67. txtTleMain.UseDefault().SetStringData(xlall);
  68. txtTleAdja.UseDefault().SetStringData(xlall);
  69. var mainSat = listTx.Find(p => p.TxType == EnumTxType.MainSat);
  70. txtTleMain.Text = mainSat != null && xlList.Any(m => m.SatCode == mainSat.SatInfoID) ?
  71. xlList.Find(m => m.SatCode == mainSat.SatInfoID).TwoLine : xlList.First().TwoLine;
  72. var adjaSat = listTx.Find(p => p.TxType == EnumTxType.AdjaSat);
  73. txtTleMain.Text = adjaSat != null && xlList.Any(m => m.SatCode == adjaSat.SatInfoID) ?
  74. xlList.Find(m => m.SatCode == adjaSat.SatInfoID).TwoLine : xlList.First().TwoLine;
  75. }
  76. private void btnOK_Click(object sender, EventArgs e)
  77. {
  78. mapControl1.ClearMap();
  79. var (listSat, data) = GdopHelper.Gdop2Sat1DRef(Model.TleMain, Model.TleAdja, Model.CapTime, new double[] { Model.StationLon, Model.StationLat, 0 },
  80. new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr);
  81. if (data == null)
  82. {
  83. return;
  84. }
  85. if (listSat != null)//画卫星
  86. {
  87. foreach (var sat in listSat)
  88. {
  89. mapControl1.Invoke(new Action(() =>
  90. {
  91. string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString();
  92. mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°");
  93. //mapControl1.DrawEllipse(sat.SatLat, sat.SatLon, 4800);
  94. }));
  95. }
  96. }
  97. if ((Model.StationLon >= 180 || Model.StationLon <= 180) && Model.StationLat >= -90 || Model.StationLat <= 90)//画天线
  98. {
  99. mapControl1.Invoke(new Action(() =>
  100. {
  101. mapControl1.DrawFixedImg("cdb", Model.StationLat, Model.StationLon, SvgHelper.LoadFromFile("Image\\tx.svg"), new Size(32, 32), $"超短站经度:{Model.StationLon}°\r\n超短站纬度:{Model.StationLat}°");
  102. }));
  103. }
  104. foreach (var errLins in data)//画GDOP
  105. {
  106. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  107. //mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  108. }
  109. }
  110. private void btnClose_Click(object sender, EventArgs e)
  111. {
  112. PopupHelper.HidePopup(this);
  113. }
  114. }
  115. public class GDOP星地两星一地接口
  116. {
  117. /// <summary>
  118. /// 主星星历(Tle)
  119. /// </summary>
  120. public string TleMain { get; set; }
  121. /// <summary>
  122. /// 邻星星历(Tle)
  123. /// </summary>
  124. public string TleAdja { get; set; }
  125. /// <summary>
  126. /// 采集时刻
  127. /// </summary>
  128. public DateTime CapTime { get; set; }
  129. /// <summary>
  130. /// 超短接收站-经度
  131. /// </summary>
  132. public double StationLon { get; set; }
  133. /// <summary>
  134. /// 超短接收站-纬度
  135. /// </summary>
  136. public double StationLat { get; set; }
  137. /// <summary>
  138. /// 参考站位置经度
  139. /// </summary>
  140. public double RefLon { get; set; }
  141. /// <summary>
  142. /// 参考站位置纬度
  143. /// </summary>
  144. public double RefLat { get; set; }
  145. /// <summary>
  146. /// 时差误差(单位us)
  147. /// </summary>
  148. public double DtousErr { get; set; } = 1;
  149. /// <summary>
  150. /// 星历位置误差(单位米)
  151. /// </summary>
  152. public double SatLocErr { get; set; } = 10000;
  153. }
  154. }