X2D1GDOPParam.cs 7.4 KB

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