123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- using DevExpress.Xpo;
- using DevExpress.Xpo.Generators;
- using Ips.Library.Basic;
- using Ips.Library.Entity;
- using Ips.LocAlgorithm;
- using Ips.Sps.Scheduling.Entities;
- using Ips.Sps.TskResults.Peses;
- using Ips.Sps.TskResults.Poses;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ips.Sps.Scheduling.SigLocs
- {
- public class LocSigUtil
- {
- public static Pos CreatePos(PosResult posRes, int tskId, RunSig sig, DateTime sigTime, Session session)
- {
- Pos pos = new Pos(session);
- pos.TskId = tskId;
- pos.SigId = sig.SigId;
- pos.EmtId = sig.EmtId;
- pos.SigTime = sigTime;
- pos.SigFreq = sig.SigFreq;
- pos.BandWidth = sig.BandWidth;
- pos.CreateTime = DateTime.Now;
- if (posRes != null)
- {
- SetPosLoc(pos, posRes, sig);
- }
- else
- {
- pos.PosType = PosType.X3;
- pos.HasRef = false;
- pos.PosLon = LonNan.Value;
- pos.PosLat = LatNan.Value;
- pos.PosAlt = 0;
- pos.MirrLon = LonNan.Value;
- pos.MirrLat = LatNan.Value;
- pos.IsValid = false;
- }
- return pos;
- }
- public static void SavePosRel(Pos pos, Pes tarPes, Pes refPes, List<Pes> refPesList, Session session)
- {
- List<PosRel> posRelList = new List<PosRel>();
- PosRel posRel = new PosRel(session);
- posRelList.Add(posRel);
- posRel.PosId = pos.Id;
- posRel.PesId = tarPes.Id;
- posRel.Category = SignalCategory.TarSig;
- if (refPes != null)
- {
- posRel.RefDt = refPes.Dt;
- posRel.RefDf = refPes.Df;
- posRel.RefSnr = refPes.Snr;
- posRel.RefEmtId = refPes.EmtId;
- posRel.RefSigLon = refPes.SigLon;
- posRel.RefSigLat = refPes.SigLat;
- posRel.RefSigAlt = refPes.SigAlt;
- if (refPesList.IsNotNullOrEmpty())
- {
- foreach (var refPesItem in refPesList)
- {
- PosRel refPosRel = new PosRel();
- refPosRel.PosId = posRel.PosId;
- refPosRel.PesId = refPesItem.Id;
- refPosRel.Category = SignalCategory.RefSig;
- refPosRel.RefDt = refPesItem.Dt;
- refPosRel.RefDf = refPesItem.Df;
- refPosRel.RefSnr = refPesItem.Snr;
- refPosRel.RefEmtId = refPesItem.EmtId;
- refPosRel.RefSigLon = refPesItem.SigLon;
- refPosRel.RefSigLat = refPesItem.SigLat;
- refPosRel.RefSigAlt = refPes.SigAlt;
- posRelList.Add(refPosRel);
- }
- }
- }
- posRel.Save();
- }
- public static int GetGdopErr(Pos pos, Pes pes1, Pes pes2, double[] refSigLla)
- {
- int result = -1;
- try
- {
- bool isGeoPoint = GeoUtil.IsValidPoint(pos.PosLon, pos.PosLat);
- if (!isGeoPoint) return result;
- ExeResult<GdopErrResult> gdopErr = null;
- if (refSigLla.IsNotNullOrEmpty())
- {
- gdopErr = LocRhUtil.GdopErrRef(pos.GetPosLLA(), refSigLla
- , pes1.GetMainEphXYZ(), pes1.GetAdjaEphXYZ()
- , pes2.GetMainEphXYZ(), pes2.GetAdjaEphXYZ()).Result;
- }
- else
- {
- gdopErr = LocRhUtil.GdopErr(pos.GetPosLLA(), pes1.GetAdjaAntLLA()
- , pes1.GetMainEphXYZ(), pes1.GetAdjaEphXYZ()
- , pes2.GetMainEphXYZ(), pes2.GetAdjaEphXYZ()).Result;
- }
- if (gdopErr != null && gdopErr.Result != null && gdopErr.ExitCode == 0)
- {
- result = (int)(gdopErr.Result.ErrorRange);
- }
- }
- catch (Exception ex)
- {
- IpsLogger.Error($"定位点误差计算错误,信号时间:{pos.SigTime:yyyy-MM-dd HH:mm:ss},信号频点:{pos.SigFreq.E6m()}",ex);
- }
- return result;
- }
- public static void SetPosLoc(Pos pos, PosResult posRes, RunSig sig)
- {
- pos.PosType = posRes.PosType;
- pos.HasRef = posRes.HasRef;
- pos.PosAlt = sig.SigAlt;
- pos.IsValid = posRes.Result1.IsValid() || posRes.Result2.IsValid();
- if (pos.IsValid)
- {
- pos.IsValid = SpsConst.NoRefIsValidPos || pos.HasRef;
- }
- GeoLLA lla1 = posRes.Result1, lla2 = posRes.Result2;
- GeoLLA posLoc = lla1, posMir = lla2;
- if (pos.IsValid)
- {
- bool lla1InZone = GeoUtil.InZone(lla1.Lon, lla1.Lat, sig.LonMin, sig.LonMax, sig.LatMin, sig.LatMax);
- bool lla2InZone = GeoUtil.InZone(lla2.Lon, lla2.Lat, sig.LonMin, sig.LonMax, sig.LatMin, sig.LatMax);
- if ((lla1InZone == true && lla2InZone == true) || (lla1InZone == false && lla2InZone == false))
- {
- var dis1 = GeoUtil.DistinceLla(lla1.Lon, lla1.Lat, sig.SigAlt, sig.SigLon, sig.SigLat, sig.SigAlt);
- var dis2 = GeoUtil.DistinceLla(lla2.Lon, lla2.Lat, sig.SigAlt, sig.SigLon, sig.SigLat, sig.SigAlt);
- if (dis1 > dis2)
- {
- posLoc = lla2;
- posMir = lla1;
- }
- }
- else if (lla2InZone)
- {
- posLoc = lla2;
- posMir = lla1;
- }
- }
- pos.PosLon = posLoc.Lon;
- pos.PosLat = posLoc.Lat;
- pos.MirrLon = posMir.Lon;
- pos.MirrLat = posMir.Lat;
- }
- private static void SetPosMirr(Pos pos, GeoLLA lla1, GeoLLA lla2)
- {
- pos.PosLon = lla1.Lon;
- pos.PosLat = lla1.Lat;
- pos.MirrLon = lla2.Lon;
- pos.MirrLat = lla2.Lat;
- }
- }
- }
|