X3GDOPParam.cs 7.4 KB

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