X1D1GDOPParam.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. using System.Runtime.ConstrainedExecution;
  11. namespace XdCxRhDW.App.UserControl
  12. {
  13. public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  14. {
  15. public MapControl mapControl1;
  16. public GDOP星地一星一地接口 Model => new GDOP星地一星一地接口()
  17. {
  18. TleMain = txtTleMain.Text.Trim(),
  19. CapTime = txtCapTime.DateTime,
  20. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  21. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  22. CXLon = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[0].Trim()),
  23. CXLat = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[1].Trim()),
  24. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  25. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  26. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  27. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  28. CXErr = Convert.ToDouble(txtCxErr.Text),
  29. };
  30. public X1D1GDOPParam(PosRes item)
  31. {
  32. InitializeComponent();
  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 (RHDWContext db = new RHDWContext())
  46. {
  47. var sats = db.SatInfos.ToList();
  48. var cg = db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  49. var station = db.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  50. if (station != null)
  51. {
  52. this.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
  53. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  54. this.txtCXStation.Text = $"{station.CxLon},{station.CxLat}";
  55. }
  56. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  57. xlall.AddRange(xlList.Select(m => m.TwoLine));
  58. if (xlall.Count() == 0) return;
  59. if (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  60. {
  61. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  62. }
  63. else
  64. {
  65. mainTle = xlList.First().TwoLine;
  66. }
  67. }
  68. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  69. }
  70. private (bool, string) ParamValidate()
  71. {
  72. if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
  73. {
  74. return (false, "主星星历不能为空!");
  75. }
  76. if (txtCapTime.DateTime==DateTime.MinValue)
  77. {
  78. return (false, "采集时刻不能为空!");
  79. }
  80. var txtstat = txtStationLocation1.CheckLonLat("超短波");
  81. if (!txtstat.Item1)
  82. {
  83. return txtstat;
  84. }
  85. var cxsta = txtCXStation.CheckLonLat("测向站");
  86. if (!cxsta.Item1)
  87. {
  88. return cxsta;
  89. }
  90. var refsta = txtRefLocation1.CheckLonLat("参考站");
  91. if (!refsta.Item1)
  92. {
  93. return refsta;
  94. }
  95. return (true, "");
  96. }
  97. private void btnOK_Click(object sender, EventArgs e)
  98. {
  99. var pv = ParamValidate();
  100. if (!pv.Item1)
  101. {
  102. DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  103. return;
  104. }
  105. try
  106. {
  107. mapControl1.ClearMap();
  108. var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  109. var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
  110. var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  111. var (listSat, data) = GdopHelper.Gdop1Sat1D(Model.TleMain, Model.CapTime, cdb, cx,
  112. Model.DtousErr, Model.CXErr, Model.SatLocErr, refstation);
  113. if (data == null)
  114. {
  115. return;
  116. }
  117. foreach (var errLins in data)//画GDOP
  118. {
  119. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  120. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  121. }
  122. }
  123. catch (Exception ex)
  124. {
  125. DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
  126. }
  127. }
  128. private void btnClose_Click(object sender, EventArgs e)
  129. {
  130. DxHelper.PopupHelper.HidePopup(this);
  131. }
  132. }
  133. public class GDOP星地一星一地接口
  134. {
  135. /// <summary>
  136. /// 主星星历(Tle)
  137. /// </summary>
  138. public string TleMain { get; set; }
  139. /// <summary>
  140. /// 采集时刻
  141. /// </summary>
  142. public DateTime CapTime { get; set; }
  143. /// <summary>
  144. /// 超短接收站-经度
  145. /// </summary>
  146. public double StationLon { get; set; }
  147. /// <summary>
  148. /// 超短接收站-纬度
  149. /// </summary>
  150. public double StationLat { get; set; }
  151. /// <summary>
  152. /// 参考站位置经度
  153. /// </summary>
  154. public double RefLon { get; set; }
  155. /// <summary>
  156. /// 参考站位置纬度
  157. /// </summary>
  158. public double RefLat { get; set; }
  159. /// <summary>
  160. /// 测向站位置经度
  161. /// </summary>
  162. public double CXLon { get; set; }
  163. /// <summary>
  164. ///测向站位置纬度
  165. /// </summary>
  166. public double CXLat { get; set; }
  167. /// <summary>
  168. /// 时差误差(单位us)
  169. /// </summary>
  170. public double DtousErr { get; set; } = 1;
  171. /// <summary>
  172. /// 星历位置误差(单位米)
  173. /// </summary>
  174. public double SatLocErr { get; set; } = 10000;
  175. /// <summary>
  176. /// 测向误差(单位°)
  177. /// </summary>
  178. public double CXErr { get; set; } = 0.01;
  179. }
  180. }