X3GDOPParam.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 DxHelper;
  8. using XdCxRhDW.Repostory;
  9. using XdCxRhDW.Entity;
  10. using XdCxRhDW.Api;
  11. namespace XdCxRhDW.App.UserControl
  12. {
  13. public partial class X3GDOPParam : DevExpress.XtraEditors.XtraUserControl
  14. {
  15. public MapControl mapControl1;
  16. public X3GDOP星地接口 Model => new X3GDOP星地接口()
  17. {
  18. TleMain = txtTleMain.Text.Trim(),
  19. TleAdja1 = txtTleAdja1.Text.Trim(),
  20. TleAdja2 = txtTleAdja2.Text.Trim(),
  21. CapTime = txtCapTime.DateTime,
  22. RefLon = PosResType == EnumPosResType.X3NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  23. RefLat = PosResType == EnumPosResType.X3NoRef ? 0 : Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  24. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  25. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  26. };
  27. private EnumPosResType PosResType;
  28. public X3GDOPParam(PosRes item)
  29. {
  30. InitializeComponent();
  31. this.layoutControl1.UseDefault();
  32. txtCapTime.UseDefault();
  33. txtTleMain.UseDoubleClickToSelectAll();
  34. txtTleAdja1.UseDoubleClickToSelectAll();
  35. txtTleAdja2.UseDoubleClickToSelectAll();
  36. txtRefLocation1.UseDoubleClickToSelectAll();
  37. this.txtCapTime.DateTime = item.SigTime;
  38. this.txtDtousErr1.EditValue = 1;
  39. this.txtSatLocErr1.EditValue = 10000;
  40. PosResType = item.PosResType;
  41. if (PosResType == EnumPosResType.X3NoRef)
  42. {
  43. layoutControlItem14.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
  44. }
  45. List<string> xlall = new List<string>();
  46. string mainTle = string.Empty;
  47. string adjaTle1 = string.Empty;
  48. string adjaTle2 = string.Empty;
  49. using (RHDWPartContext db = RHDWPartContext.GetContext(item.SigTime))
  50. {
  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.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  56. }
  57. var xlList = XlRepository.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 != null && 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. if (cg != null && cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  65. {
  66. adjaTle1 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  67. }
  68. if (cg != null && cg.Adja2Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja2Code.Value))
  69. {
  70. adjaTle2 = xlList.First(m => m.SatCode == cg.Adja2Code.Value).TwoLine;
  71. }
  72. txtMainSat.Text = "主星:" + cg.MainCode;
  73. txtAdjaSat1.Text = "邻1星:" + cg.Adja1Code;
  74. txtAdjaSat2.Text = "邻2星:" + cg.Adja2Code;
  75. }
  76. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  77. txtTleAdja1.UseDefault().SetStringData(xlall).Text = adjaTle1;
  78. txtTleAdja2.UseDefault().SetStringData(xlall).Text = adjaTle2;
  79. }
  80. private void btnClose_Click(object sender, EventArgs e)
  81. {
  82. DxHelper.PopupHelper.HidePopup(this);
  83. }
  84. private (bool, string) ParamValidate()
  85. {
  86. if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
  87. {
  88. return (false, "主星星历不能为空!");
  89. }
  90. if (string.IsNullOrWhiteSpace(txtTleAdja1.Text.Trim()))
  91. {
  92. return (false, "邻星1星历不能为空!");
  93. }
  94. if (string.IsNullOrWhiteSpace(txtTleAdja2.Text.Trim()))
  95. {
  96. return (false, "邻星2星历不能为空!");
  97. }
  98. if (txtTleMain.Text.Trim() == txtTleAdja1.Text.Trim() || txtTleMain.Text.Trim() == txtTleAdja2.Text.Trim() || txtTleAdja1.Text.Trim() == txtTleAdja2.Text.Trim())
  99. {
  100. return (false, "主邻星历不能相同!");
  101. }
  102. if (txtCapTime.DateTime == DateTime.MinValue)
  103. {
  104. return (false, "采集时刻不能为空!");
  105. }
  106. var refsta = txtRefLocation1.CheckLonLat("参考站");
  107. if (PosResType == EnumPosResType.X3 && !refsta.Item1)
  108. {
  109. return refsta;
  110. }
  111. return (true, "");
  112. }
  113. private void btnX1D2_Click(object sender, EventArgs e)
  114. {
  115. var pv = ParamValidate();
  116. if (!pv.Item1)
  117. {
  118. DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  119. return;
  120. }
  121. try
  122. {
  123. mapControl1.ClearMap();
  124. var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
  125. var (listSat, data) = GdopHelper.Gdop3Sat(Model.TleMain, Model.TleAdja1, Model.TleAdja2, Model.CapTime
  126. , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X3NoRef ? null : refs);
  127. if (data == null)
  128. {
  129. return;
  130. }
  131. foreach (var errLins in data)//画GDOP
  132. {
  133. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  134. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  135. }
  136. }
  137. catch (Exception ex)
  138. {
  139. DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
  140. }
  141. }
  142. }
  143. public class X3GDOP星地接口
  144. {
  145. /// <summary>
  146. /// 主星星历(Tle)
  147. /// </summary>
  148. public string TleMain { get; set; }
  149. /// <summary>
  150. /// 邻星1星历(Tle)
  151. /// </summary>
  152. public string TleAdja1 { get; set; }
  153. /// <summary>
  154. /// 邻星2星历(Tle)
  155. /// </summary>
  156. public string TleAdja2 { get; set; }
  157. /// <summary>
  158. /// 采集时刻
  159. /// </summary>
  160. public DateTime CapTime { get; set; }
  161. /// <summary>
  162. /// 参考站位置经度
  163. /// </summary>
  164. public double RefLon { get; set; }
  165. /// <summary>
  166. /// 参考站位置纬度
  167. /// </summary>
  168. public double RefLat { get; set; }
  169. /// <summary>
  170. /// 时差误差(单位us)
  171. /// </summary>
  172. public double DtousErr { get; set; } = 1;
  173. /// <summary>
  174. /// 星历位置误差(单位米)
  175. /// </summary>
  176. public double SatLocErr { get; set; } = 10000;
  177. }
  178. }