using DevExpress.XtraEditors; using DevExpress.XtraMap; using DxHelper; using ExtensionsDev; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using XdDw.App; using XdDw.App.Api.星历推算; using XdDw.App.EFContext; using XzXdDw.App.Model; namespace XdDw.App.UserControl { public partial class X2D1ErrEllipseParam : DevExpress.XtraEditors.XtraUserControl { public MapControl mapControl1; public double lon; public double lat; public ErrEllipse星地两星一地接口 Model => new ErrEllipse星地两星一地接口() { TleMain = txtTleMain.Text.Trim(), TleAdja = txtTleAdja.Text.Trim(), CapTime = txtCapTime.DateTime, StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()), StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()), RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()), RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()), DtousErr = Convert.ToDouble(txtDtousErr1.Text), SatLocErr = Convert.ToDouble(txtSatLocErr1.Text), }; public X2D1ErrEllipseParam(DateTime sigTime) { InitializeComponent(); txtCapTime.UseDefault(); txtTleMain.UseDoubleClickToSelectAll(); txtTleAdja.UseDoubleClickToSelectAll(); txtStationLocation1.UseDoubleClickToSelectAll(); txtRefLocation1.UseDoubleClickToSelectAll(); List listTx = new List(); using (RHDWContext db = new RHDWContext()) { listTx = db.TxInfos.ToList(); } var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb); var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref); this.txtCapTime.DateTime = sigTime; this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}"; this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}"; txtTleMain.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleMain; txtTleAdja.UseDefault().SetStringData(TestData.AllTle).Text = TestData.TleAdja1; this.txtDtousErr1.EditValue = TestData.DtousErr; this.txtSatLocErr1.EditValue = TestData.SatLocErr; } private void btnOK_Click(object sender, EventArgs e) { mapControl1.ClearMap(); double[] main_sat = Tle2XYZ.GetXyz(Model.TleMain, Model.CapTime); double[] adja_sat = Tle2XYZ.GetXyz(Model.TleAdja, Model.CapTime); DrawErrorEllipse2X1D(lon,lat, main_sat, adja_sat, new double[] { Model.StationLon, Model.StationLat, 0 }, new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr); } private void DrawErrorEllipse2X1D(double posLon, double posLat, double[] MsEph, double[] NsEph, double[] CDBAnt, double[] RefGeod, double DtoErr, double EphErr) { try { List listTx = new List(); List listSat = new List(); using (RHDWContext db = new RHDWContext()) { listTx = db.TxInfos.ToList(); listSat = db.SatInfos.ToList(); } var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat); var satNTx = listTx.Find(p => p.TxType == EnumTxType.AdjaSat); XdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO2X1DOption Option = new XdDw.App.Api.低轨GDOP误差椭圆.ErrorEllipseDTO2X1DOption(); Option.MsEph = MsEph; Option.NsEph = NsEph; Option.CDBAnt = CDBAnt; Option.RefGeod = RefGeod; Option.SelectPoint = new double[3] { posLon, posLat, 0 }; Option.DtoErr = DtoErr * 1e-6; Option.EphErr = EphErr; var points = XdDw.App.Api.低轨GDOP误差椭圆.ErrEllipseHelper.ErrorEllipse2X1D(Option); mapControl1.DrawDtoPonit($"双星[{listSat.FirstOrDefault(m => m.ID == satTx.ID)?.Sat},{listSat.FirstOrDefault(m => m.ID == satNTx.ID)?.Sat}]误差椭圆线", points); } catch (Exception ex) { Serilog.Log.Error("绘制误差椭圆线失败", ex); XtraMessageBox.Show($"绘制误差椭圆线失败,失败信息:{ex.Message}"); } } private void btnClose_Click(object sender, EventArgs e) { PopupHelper.HidePopup(this); } } public class ErrEllipse星地两星一地接口 { /// /// 主星星历(Tle) /// public string TleMain { get; set; } /// /// 邻星星历(Tle) /// public string TleAdja { get; set; } /// /// 采集时刻 /// public DateTime CapTime { get; set; } /// /// 超短接收站-经度 /// public double StationLon { get; set; } /// /// 超短接收站-纬度 /// public double StationLat { get; set; } /// /// 参考站位置经度 /// public double RefLon { get; set; } /// /// 参考站位置纬度 /// public double RefLat { get; set; } /// /// 时差误差(单位us) /// public double DtousErr { get; set; } = 1; /// /// 星历位置误差(单位米) /// public double SatLocErr { get; set; } = 10000; } }