123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- 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 XdCxRhDW.App.Model;
- using XdCxRhDW.App.EFContext;
- using System.Data.Entity;
- using System.Windows.Documents;
- using XdCxRhDW.App.Api.GDOP误差椭圆;
- 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<TxInfo> listTx = new List<TxInfo>();
- using (RHDWContext db = new RHDWContext())
- {
- listTx = db.TxInfos.ToList();
- }
- var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
- if (cdbTx != null)
- {
- this.txtStationLocation1.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
- }
- var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
- if (cdbTx != null)
- {
- this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
- }
- this.txtCapTime.DateTime = sigTime;
- List<XlInfo> xlList = new List<XlInfo>();
- using (RHDWContext db = new RHDWContext())
- {
- var res = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ);
- xlList.AddRange(res.ToList());
- }
- this.txtDtousErr1.EditValue = 1;
- this.txtSatLocErr1.EditValue = 1000;
- var xlall = xlList.Select(m => m.TwoLine);
- if (xlall.Count() == 0) return;
- txtTleMain.UseDefault().SetStringData(xlall);
- txtTleAdja.UseDefault().SetStringData(xlall);
- var mainSat = listTx.Find(p => p.TxType == EnumTxType.MainSat);
- txtTleMain.Text = mainSat != null && xlList.Any(m => m.SatCode == mainSat.SatInfoID) ?
- xlList.Find(m => m.SatCode == mainSat.SatInfoID).TwoLine : xlList.First().TwoLine;
- var adjaSat = listTx.Find(p => p.TxType == EnumTxType.AdjaSat);
- txtTleMain.Text = adjaSat != null && xlList.Any(m => m.SatCode == adjaSat.SatInfoID) ?
- xlList.Find(m => m.SatCode == adjaSat.SatInfoID).TwoLine : xlList.First().TwoLine;
- }
- 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);
- 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);
- }
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- PopupHelper.HidePopup(this);
- }
- }
- public class GDOP星地两星一地接口
- {
- /// <summary>
- /// 主星星历(Tle)
- /// </summary>
- public string TleMain { get; set; }
- /// <summary>
- /// 邻星星历(Tle)
- /// </summary>
- public string TleAdja { get; set; }
- /// <summary>
- /// 采集时刻
- /// </summary>
- public DateTime CapTime { get; set; }
- /// <summary>
- /// 超短接收站-经度
- /// </summary>
- public double StationLon { get; set; }
- /// <summary>
- /// 超短接收站-纬度
- /// </summary>
- public double StationLat { get; set; }
- /// <summary>
- /// 参考站位置经度
- /// </summary>
- public double RefLon { get; set; }
- /// <summary>
- /// 参考站位置纬度
- /// </summary>
- public double RefLat { get; set; }
- /// <summary>
- /// 时差误差(单位us)
- /// </summary>
- public double DtousErr { get; set; } = 1;
- /// <summary>
- /// 星历位置误差(单位米)
- /// </summary>
- public double SatLocErr { get; set; } = 10000;
- }
- }
|