X3GDOPParam.cs 7.4 KB

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