X2D1GDOPParam.cs 7.4 KB

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