X1D1GDOPParam.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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;
  8. using XdCxRhDW.Entity;
  9. using XdCxRhDW.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. this.layoutControl1.UseDefault();
  33. txtCapTime.UseDefault();
  34. txtTleMain.UseDoubleClickToSelectAll();
  35. txtStationLocation1.UseDoubleClickToSelectAll();
  36. txtRefLocation1.UseDoubleClickToSelectAll();
  37. txtCXStation.UseDoubleClickToSelectAll();
  38. this.txtCapTime.DateTime = item.SigTime;
  39. this.txtDtousErr1.EditValue = 1;
  40. this.txtSatLocErr1.EditValue = 10000;
  41. this.txtCxErr.EditValue = 0.001;
  42. List<string> xlall = new List<string>();
  43. string mainTle = string.Empty;
  44. string adjaTle = string.Empty;
  45. using (RHDWPartContext db = RHDWPartContext.GetContext(item.SigTime))
  46. {
  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 = XlRepository.GetAllAsync().Result.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 != null && 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. txtMainSat.Text = "主星:" + cg.MainCode;
  63. }
  64. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  65. }
  66. private (bool, string) ParamValidate()
  67. {
  68. if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
  69. {
  70. return (false, "主星星历不能为空!");
  71. }
  72. if (txtCapTime.DateTime == DateTime.MinValue)
  73. {
  74. return (false, "采集时刻不能为空!");
  75. }
  76. var txtstat = txtStationLocation1.CheckLonLat("超短波");
  77. if (!txtstat.Item1)
  78. {
  79. return txtstat;
  80. }
  81. var cxsta = txtCXStation.CheckLonLat("测向站");
  82. if (!cxsta.Item1)
  83. {
  84. return cxsta;
  85. }
  86. var refsta = txtRefLocation1.CheckLonLat("参考站");
  87. if (!refsta.Item1)
  88. {
  89. return refsta;
  90. }
  91. return (true, "");
  92. }
  93. private void btnOK_Click(object sender, EventArgs e)
  94. {
  95. var pv = ParamValidate();
  96. if (!pv.Item1)
  97. {
  98. DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  99. return;
  100. }
  101. try
  102. {
  103. mapControl1.ClearMap();
  104. var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  105. var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
  106. var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  107. var (listSat, data) = GdopHelper.Gdop1Sat1D(Model.TleMain, Model.CapTime, cdb, cx,
  108. Model.DtousErr, Model.CXErr, Model.SatLocErr, refstation);
  109. if (data == null)
  110. {
  111. return;
  112. }
  113. foreach (var errLins in data)//画GDOP
  114. {
  115. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  116. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
  122. }
  123. }
  124. private void btnClose_Click(object sender, EventArgs e)
  125. {
  126. DxHelper.PopupHelper.HidePopup(this);
  127. }
  128. }
  129. public class GDOP星地一星一地接口
  130. {
  131. /// <summary>
  132. /// 主星星历(Tle)
  133. /// </summary>
  134. public string TleMain { get; set; }
  135. /// <summary>
  136. /// 采集时刻
  137. /// </summary>
  138. public DateTime CapTime { get; set; }
  139. /// <summary>
  140. /// 超短接收站-经度
  141. /// </summary>
  142. public double StationLon { get; set; }
  143. /// <summary>
  144. /// 超短接收站-纬度
  145. /// </summary>
  146. public double StationLat { get; set; }
  147. /// <summary>
  148. /// 参考站位置经度
  149. /// </summary>
  150. public double RefLon { get; set; }
  151. /// <summary>
  152. /// 参考站位置纬度
  153. /// </summary>
  154. public double RefLat { get; set; }
  155. /// <summary>
  156. /// 测向站位置经度
  157. /// </summary>
  158. public double CXLon { get; set; }
  159. /// <summary>
  160. ///测向站位置纬度
  161. /// </summary>
  162. public double CXLat { get; set; }
  163. /// <summary>
  164. /// 时差误差(单位us)
  165. /// </summary>
  166. public double DtousErr { get; set; } = 1;
  167. /// <summary>
  168. /// 星历位置误差(单位米)
  169. /// </summary>
  170. public double SatLocErr { get; set; } = 10000;
  171. /// <summary>
  172. /// 测向误差(单位°)
  173. /// </summary>
  174. public double CXErr { get; set; } = 0.01;
  175. }
  176. }