X1D1GDOPParam.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using DevExpress.XtraMap;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Collections.Generic;
  7. using XdCxRhDW.Repostory.Model;
  8. using XdCxRhDW.Repostory.EFContext;
  9. using XdCxRhDW.Core.Api;
  10. namespace XdCxRhDW.App.UserControl
  11. {
  12. public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  13. {
  14. public MapControl mapControl1;
  15. public GDOP星地一星一地接口 Model => new GDOP星地一星一地接口()
  16. {
  17. TleMain = txtTleMain.Text.Trim(),
  18. CapTime = txtCapTime.DateTime,
  19. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  20. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  21. CXLon = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[0].Trim()),
  22. CXLat = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[1].Trim()),
  23. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  24. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  25. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  26. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  27. CXErr= Convert.ToDouble(txtCxErr.Text),
  28. };
  29. public X1D1GDOPParam(PosRes item)
  30. {
  31. InitializeComponent();
  32. txtCapTime.UseDefault();
  33. txtTleMain.UseDoubleClickToSelectAll();
  34. txtStationLocation1.UseDoubleClickToSelectAll();
  35. txtRefLocation1.UseDoubleClickToSelectAll();
  36. txtCXStation.UseDoubleClickToSelectAll();
  37. this.txtCapTime.DateTime = item.SigTime;
  38. this.txtDtousErr1.EditValue = 1;
  39. this.txtSatLocErr1.EditValue = 1000;
  40. this.txtCxErr.EditValue = 0.001;
  41. List<string> xlall = new List<string>();
  42. string mainTle = string.Empty;
  43. string adjaTle = string.Empty;
  44. using (RHDWContext db = new RHDWContext())
  45. {
  46. var sats = db.SatInfos.ToList();
  47. var cg = db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  48. var station = db.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  49. if (station != null)
  50. {
  51. this.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
  52. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  53. this.txtCXStation.Text= $"{station.CxLon},{station.CxLat}";
  54. }
  55. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  56. xlall.AddRange(xlList.Select(m => m.TwoLine));
  57. if (xlall.Count() == 0) return;
  58. if (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  59. {
  60. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  61. }
  62. else
  63. {
  64. mainTle = xlList.First().TwoLine;
  65. }
  66. }
  67. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  68. }
  69. private void btnOK_Click(object sender, EventArgs e)
  70. {
  71. mapControl1.ClearMap();
  72. var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  73. var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
  74. var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  75. var (listSat, data) = GdopHelper.Gdop1Sat1D(Model.TleMain, Model.CapTime, cdb, cx,
  76. Model.DtousErr,Model.CXErr, Model.SatLocErr, refstation);
  77. if (data == null)
  78. {
  79. return;
  80. }
  81. foreach (var errLins in data)//画GDOP
  82. {
  83. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  84. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  85. }
  86. }
  87. private void btnClose_Click(object sender, EventArgs e)
  88. {
  89. DxHelper.PopupHelper.HidePopup(this);
  90. }
  91. }
  92. public class GDOP星地一星一地接口
  93. {
  94. /// <summary>
  95. /// 主星星历(Tle)
  96. /// </summary>
  97. public string TleMain { get; set; }
  98. /// <summary>
  99. /// 采集时刻
  100. /// </summary>
  101. public DateTime CapTime { get; set; }
  102. /// <summary>
  103. /// 超短接收站-经度
  104. /// </summary>
  105. public double StationLon { get; set; }
  106. /// <summary>
  107. /// 超短接收站-纬度
  108. /// </summary>
  109. public double StationLat { get; set; }
  110. /// <summary>
  111. /// 参考站位置经度
  112. /// </summary>
  113. public double RefLon { get; set; }
  114. /// <summary>
  115. /// 参考站位置纬度
  116. /// </summary>
  117. public double RefLat { get; set; }
  118. /// <summary>
  119. /// 测向站位置经度
  120. /// </summary>
  121. public double CXLon { get; set; }
  122. /// <summary>
  123. ///测向站位置纬度
  124. /// </summary>
  125. public double CXLat { get; set; }
  126. /// <summary>
  127. /// 时差误差(单位us)
  128. /// </summary>
  129. public double DtousErr { get; set; } = 1;
  130. /// <summary>
  131. /// 星历位置误差(单位米)
  132. /// </summary>
  133. public double SatLocErr { get; set; } = 10000;
  134. /// <summary>
  135. /// 测向误差(单位°)
  136. /// </summary>
  137. public double CXErr { get; set; } = 0.01;
  138. }
  139. }