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