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 XzXdDw.App; using XzXdDw.App.Model; using XzXdDw.App.Api.星地GDOP误差椭圆; using XzXdDw.App.EFContext; namespace XdCxRhDW.App.UserControl { public partial class X2D1GDOPParam : DevExpress.XtraEditors.XtraUserControl { public MapControl mapControl1; public GDOP星地两星一地接口 Model=> new GDOP星地两星一地接口() { 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 X2D1GDOPParam(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) ; txtTleMain.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(); var (listSat, data) = GdopHelper.Gdop2Sat1DRef(Model.TleMain, Model.TleAdja, Model.CapTime, new double[] { Model.StationLon, Model.StationLat, 0 }, new double[] { Model.RefLon, Model.RefLat, 0 }, Model.DtousErr, Model.SatLocErr); // var TleMain = "1 23467U 95003A 23357.44874407 -.00000021 00000+0 00000+0 0 9999;2 23467 9.7425 16.0141 0003225 208.7887 200.6055 1.00272282105868"; // var TleAdja = "1 37256U 10068A 23357.77999653 -.00000213 00000+0 00000+0 0 9998;2 37256 49.2064 282.9700 0029000 212.5882 341.7791 1.00248080 47698"; // var CapTime = new DateTime(2024, 3, 10,13,06,31); // var StationLon =122; // var StationLat =30; //var RefLon =121; // var RefLat =30; // var DtousErr =1; // var SatLocErr =1000; // var (listSat, data) = GdopHelper.Gdop2Sat1DRef(TleMain, TleAdja, CapTime, new double[] { StationLon, StationLat, 0 }, // new double[] { RefLon, RefLat, 0 }, DtousErr, SatLocErr); if (data == null) { return; } if (listSat != null)//画卫星 { foreach (var sat in listSat) { mapControl1.Invoke(new Action(() => { string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString(); mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°"); mapControl1.DrawEllipse(sat.SatLat, sat.SatLon, 4800); })); } } if ((Model.StationLon >= 180 || Model.StationLon <= 180) && Model.StationLat >= -90 || Model.StationLat <= 90)//画天线 { mapControl1.Invoke(new Action(() => { mapControl1.DrawFixedImg("cdb", Model.StationLat, Model.StationLon, SvgHelper.LoadFromFile("Image\\tx.svg"), new Size(32, 32), $"超短站经度:{Model.StationLon}°\r\n超短站纬度:{Model.StationLat}°"); })); } foreach (var errLins in data)//画GDOP { var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat)); mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1); } } public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line) { var dots = line.Line; if (dots.Count < 30) return line; var tmp = dots.Count / 30; var newLine = new XdCxRhDW.App.DTO.MapLine(); for (int i = 0; i < dots.Count; i += tmp) { newLine.Line.Add(dots[i]); } if (!newLine.Line.Contains(dots.Last())) newLine.Line.Add(dots.Last()); return newLine; } private void btnClose_Click(object sender, EventArgs e) { PopupHelper.HidePopup(this); } } public class GDOP星地两星一地接口 { /// /// 主星星历(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; } }