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