/// <summary> /// 指定时间前后最接近的服务。 /// </summary> /// <param name="time">指定时间</param> /// <param name="satelliteType">指定的系统</param> /// <returns></returns> private IEphemerisService[] GetNearstService(Time time, SatelliteType satelliteType) { var sources = this.dic[satelliteType]; IEphemerisService first = sources[0]; IEphemerisService second = sources[sources.Count - 1]; foreach (var source in sources) { if (source.TimePeriod.End < time && source.TimePeriod.End > first.TimePeriod.End) { first = source; } if (source.TimePeriod.Start > time && source.TimePeriod.Start < second.TimePeriod.Start) { second = source; } } var two = new IEphemerisService[2]; two[0] = first; two[1] = second; return(two); }
/// <summary> /// 构造函数 /// </summary> /// <param name="EphemerisService"></param> /// <param name="Prns"></param> /// <param name="CutOffAngle"></param> /// <param name="SatWeights"></param> public DopCaculator(IEphemerisService EphemerisService, List <SatelliteNumber> Prns, double CutOffAngle, SatWeightTable SatWeights) { this.EphemerisService = EphemerisService; this.Prns = Prns; this.SatWeights = SatWeights; this.CutOffAngle = CutOffAngle; }
/// <summary> /// 获取卫星在指定时刻,相对于测站的信息 /// </summary> /// <param name="service"></param> /// <param name="prn"></param> /// <param name="time"></param> /// <returns></returns> public StationSatInfo GetInstantSatInfo(IEphemerisService service, SatelliteNumber prn, Time time) { Geo.Coordinates.XYZ satPos = service.Get(prn, time).XYZ; GeoCoord coord = CoordTransformer.XyzToGeoCoord(satPos); Geo.Coordinates.Polar p = CoordTransformer.XyzToGeoPolar(satPos, StationPos); if (p.Elevation < EleAngle) { return(null); } this.LonLats.Add(new Vector(coord.Lon, coord.Lat) { Tag = prn.ToString() }); //显示到表格 return(new StationSatInfo() { PRN = prn, Time = time, Azimuth = p.Azimuth, ElevatAngle = p.Elevation, Distance = p.Range, Lat = coord.Lat, Lon = coord.Lon, Height = coord.Height, X = satPos.X, Y = satPos.Y, Z = satPos.Z }); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { log.Info("启动本地Ntrip数据传输"); ReceivedByteCount = 0; string filePath = this.fileOpenControl1.FilePath; var fileName = Path.GetFileName(filePath); FileInfo info = new FileInfo(filePath); progressBarComponent1.InitProcess(info.Length); RtcmFileNamer = RtcmFileNamer.Parse(fileName); this.NtripMountPoint = RtcmFileNamer.NtripMountPoint; RealTimeGnssDataWriter = new Ntrip.RealTimeGnssDataWriter(this.LocalDirectory, NtripMountPoint, RtcmFileNamer.Time); //解析器 Rtcm3DataReceiver = new Rtcm.Rtcm3DataReceiver(); RtcmDataParser = new Rtcm.RtcmDataParser(NtripMountPoint); RealTimeGnssDataWriter.BindRealTimeGnssDataProvider(RtcmDataParser); IEphemerisService indicatedEph = null; if (System.IO.File.Exists(fileOpenControl_nav.FilePath)) { indicatedEph = EphemerisDataSourceFactory.Create(fileOpenControl_nav.FilePath); } var type = GnssSolverTypeHelper.GetGnssSolverType(this.singleSiteGnssSolverTypeSelectionControl1.CurrentdType); RealTimeGnssPositioner = new RealTimeGnssPositioner(type, this.LocalDirectory, NtripMountPoint, RtcmFileNamer.Time); RealTimeGnssPositioner.BindRealTimeGnssDataProvider(this.RtcmDataParser); RealTimeGnssPositioner.EphemerisService = indicatedEph; Rtcm3DataReceiver.ContentReceived += Rtcm3DataReceiver_ContentReceived; BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open, FileAccess.Read), Encoding.ASCII); int readCount = 100; List <Byte> list = new List <byte>(); reader.BaseStream.Position = 0; while (!isStopLocalReading && reader.PeekChar() != -1) { var bt = reader.ReadByte(); list.Add(bt); if (list.Count >= readCount) { this.NTRIPCallBacktoUIThread(ResponseType.NtripClientIsReceivingData, "正在传送本地数据", list.ToArray()); list.Clear(); System.Threading.Thread.Sleep(3); } } if (RealTimeGnssPositioner != null && RealTimeGnssPositioner.Solver != null) { RealTimeGnssPositioner.Solver.TableTextManager.WriteAllToFileAndClearBuffer(); } }
public EmissionEphemerisRolver(IEphemerisService EphemerisService, DataSourceContext DataSouceProvider, EpochSatellite sat) { this.Name = "信号发射时刻的卫星位置的计算"; this.EphemerisService = EphemerisService; this.DataSouceProvider = DataSouceProvider; this.EpochSat = sat; log = Log.GetLog(this); }
/// <summary> /// 生成一个卫星高度角表格 /// </summary> /// <param name="TimeLooper"></param> /// <param name="siteXyz"></param> /// <param name="SatelliteTypes"></param> /// <param name="AngleCut"></param> /// <param name="EphemerisService"></param> /// <param name="tableName"></param> /// <returns></returns> public static ObjectTableStorage BuildTable( TimeLooper TimeLooper, XYZ siteXyz, List <SatelliteType> SatelliteTypes, double AngleCut = 10, IEphemerisService EphemerisService = null, string tableName = "卫星高度角") { return(BuildTable(TimeLooper.TimePeriod.Start, TimeLooper.TimePeriod.End, TimeLooper.StepInSeconds, siteXyz, SatelliteTypes, AngleCut, EphemerisService, tableName)); }
/// <summary> /// 卫星检查过滤。 /// </summary> /// <param name="EphemerisService">星历</param> /// <param name="VertAngleCut">高度截止角</param> public EphemerisFilter(IEphemerisService EphemerisService, double VertAngleCut = 10) { this.Name = "星历过滤器"; this.VertAngleCut = VertAngleCut; this.EphemerisService = EphemerisService; log.Info("将删除高度截止角低于 " + VertAngleCut + " 的卫星。"); RemovedPrn = new List <SatelliteNumber>(); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string navPath = this.fileOpenControl_ephe.FilePath; string directory = this.directorySelectionControl1.Path; var cutOffAngle = namedFloatControl_cutOffAnlgle.Value; var gridLooper = geoGridLoopControl1.GetGridLooper(); var timeLooper = timeLoopControl1.GetTimeLooper(); string satWeightPath = fileOpenControl_prnWeight.FilePath; var SatWeightData = new TwoKeyDictionary <Time, SatelliteNumber, double>(); SatWeightTable SatWeights = null; if (System.IO.File.Exists(satWeightPath)) { var reader = new ObjectTableReader(satWeightPath); var data = reader.Read(); SatWeights = new SatWeightTable(data, 730 * 24 * 3600, "Epoch", "PRN", "Weight"); SatWeights.Init(); log.Info("载入卫星权值文件 : " + satWeightPath); } else { log.Info("没有卫星权值文件"); } IEphemerisService EphemerisService = EphemerisDataSourceFactory.Create(navPath); var satTypes = multiGnssSystemSelectControl1.SatelliteTypes; List <SatelliteNumber> EnabledPrns = EphemerisService.Prns.FindAll(m => satTypes.Contains(m.SatelliteType)); if (EnabledPrns.Count == 0) { Geo.Utils.FormUtil.ShowWarningMessageBox("所选系统星历卫星数量为 0 ."); return; } EnabledPrns.Sort(); log.Info("当前系统:" + Geo.Utils.EnumerableUtil.ToString(satTypes) + ",卫星数量:" + EnabledPrns.Count + ", " + Geo.Utils.EnumerableUtil.ToString(EnabledPrns)); DopSolver = new DopSolver(EphemerisService, cutOffAngle, directory, EnabledPrns, SatWeights, timeLooper, gridLooper); DopSolver.IsSimpleModel = checkBox1IsSimpleModel.Checked; if (enabledFloatControl1maxDop.Enabled) { DopSolver.MaxDopThreshold = enabledFloatControl1maxDop.Value; } DopSolver.TimeLooper.ProgressViewer = progressBarComponent1; DopSolver.SolveAsync(); Geo.Utils.FormUtil.ShowOkAndOpenDirectory(directory); }
/// <summary> /// 获取伪距校准器。包含星历 设置、 /// </summary> /// <param name="Context"></param> /// <param name="Option"></param> /// <returns></returns> public static EpochInfoReviseManager GetRangeOnlyEpochInfoReviser(DataSourceContext Context, GnssProcessOption Option) { EpochInfoReviseManager processer = new EpochInfoReviseManager(Context, Option); IEphemerisService EphemerisService = Context.EphemerisService; //注意和哪些数据源相关 #region 首先对观测值进行过滤 if (Option.IsExcludeMalfunctioningSat) { processer.AddProcessor(new GnssSysRemover(Option)); processer.AddProcessor(new ZeroObsRemover()); if (Context.SatStateDataSource != null) { processer.AddProcessor(new ObsSatExcludeFilter(Context.SatStateDataSource)); } } if (Option.IsRemoveOrDisableNotPassedSat) { processer.AddProcessor(new IonoFreeUnavailableRemover()); } if (Option.IsEnableRemoveSats) { processer.AddProcessor(new SatelliteRemover(Option)); } #endregion #region 星历、钟差赋值和检核过滤 if (Option.IsEphemerisRequired) { processer.AddProcessor(new EpochEphemerisSetter(Context, Option)); //星历赋值与钟差赋值 cuiyang 2015.02.08 武大图书馆 processer.AddProcessor(new EphemerisFilter(EphemerisService, Option.VertAngleCut)); //星历过滤应该在星历赋值后执行 if (Option.IsDisableEclipsedSat) { processer.AddProcessor(new EclipsedSatFilter()); } } #endregion return(processer); }
/// <summary> /// 生成一个表格 /// </summary> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="interval"></param> /// <param name="siteXyz"></param> /// <param name="SatelliteTypes"></param> /// <param name="AngleCut"></param> /// <param name="EphemerisService"></param> /// <param name="tableName"></param> /// <returns></returns> public static ObjectTableStorage BuildTable( Time startTime, Time endTime, double interval, XYZ siteXyz, List <SatelliteType> SatelliteTypes, double AngleCut = 10, IEphemerisService EphemerisService = null, string tableName = "卫星高度角") { var table = new ObjectTableStorage(tableName); if (siteXyz == null) { return(null); } for (Time time = startTime; time <= endTime; time += interval) { table.NewRow(); table.AddItem("Epoch", time); foreach (var sat in EphemerisService.Prns) { if (!SatelliteTypes.Contains(sat.SatelliteType)) { continue; } var eph = EphemerisService.Get(sat, time); if (eph == null) { continue; } var p = CoordTransformer.XyzToGeoPolar(eph.XYZ, siteXyz); var ele = p.Elevation; if (ele >= AngleCut) { table.AddItem(sat, ele); } } table.EndRow(); } return(table); }
private static void AddRow(double AngleCut, IEphemerisService EphemerisService, XYZ siteXyz, ObjectTableStorage table, Time time) { table.NewRow(); table.AddItem("Epoch", time); foreach (var sat in EphemerisService.Prns) { var eph = EphemerisService.Get(sat, time); if (eph == null) { continue; } var p = CoordTransformer.XyzToGeoPolar(eph.XYZ, siteXyz); var ele = p.Elevation; if (ele >= AngleCut) { table.AddItem(sat, ele); } } table.EndRow(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="EphemerisService"></param> /// <param name="CutOffAngle"></param> /// <param name="EnabledPrns"></param> /// <param name="SatWeights"></param> /// <param name="outDirectory"></param> /// <param name="TimeLooper"></param> /// <param name="GeoGridLooper"></param> public DopSolver(IEphemerisService EphemerisService, double CutOffAngle, string outDirectory, List <SatelliteNumber> EnabledPrns, SatWeightTable SatWeights, TimeLooper TimeLooper, GeoGridLooper GeoGridLooper) { this.OutputDirectory = outDirectory; this.EphemerisService = EphemerisService; this.EnabledPrns = EnabledPrns; this.SatWeights = SatWeights; this.CutOffAngle = CutOffAngle; this.GeoGridLooper = GeoGridLooper; var satTypes = SatelliteNumber.GetSatTypes(EnabledPrns); this.FileNamePrefix = Geo.Utils.EnumerableUtil.ToString <SatelliteType>(satTypes, "-"); this.TimeLooper = TimeLooper; this.TimeLooper.Looping += TimeLooper_Looping; this.MaxDopThreshold = double.MaxValue; }
private void button_start_Click(object sender, EventArgs e) { var selectedSites = Geo.Utils.DataGridViewUtil.GetObjects <NtripStream>(dataGridView_site); if (selectedSites.Count == 0) { Geo.Utils.FormUtil.ShowWarningMessageBox("请选择测站后再试!"); return; } button_start.Enabled = false; var tables = new BaseDictionary <string, SourceTable>(Setting.NtripSourceManager.SourceTables); var table = tables.First; var sites = Setting.NtripSourceManager.CurrentCasterSites[selectedSites[0].CasterName];//tables.FirstKey]; IEphemerisService indicatedEph = null; if (System.IO.File.Exists(fileOpenControl_nav.FilePath)) { indicatedEph = EphemerisDataSourceFactory.Create(fileOpenControl_nav.FilePath); } var type = GnssSolverTypeHelper.GetGnssSolverType(this.singleSiteGnssSolverTypeSelectionControl1.CurrentdType); NtripRunner = new MultiSiteNtripRunner(); foreach (var item in selectedSites) { if (NtripRunner.Contains(item.Mountpoint)) { continue; } var caster = Setting.NtripSourceManager.NtripCasters[item.CasterName]; var t = tables.Get(item.CasterName); NtripOption option = new NtripOption(); option.IsWriteToLocal = this.checkBox_saveRawData.Checked; option.LocalDirectory = this.directorySelectionControl1.Path; option.CasterIp = caster.Host; option.CasterName = item.CasterName; option.Port = caster.Port; option.Username = caster.UserName; option.Password = caster.Password; option.PreferredMountPoint = item.Mountpoint; option.IsRequiresGGA = t.Get(item.Mountpoint).Num11 == 1; var runner = new NtripRunner(option); runner.GnssSolverType = type; runner.InfoProduced += NtripRunner_InfoProduced; runner.InstantInfoProduced += NtripRunner_InstantInfoProduced; NtripRunner.Add(item.Mountpoint, runner); } NtripRunner.Init(); foreach (var runner in NtripRunner) { //runner.RealTimeGnssPositioner.EphemerisService = indicatedEph; } NtripRunner.Start(); }
/// <summary> /// 构造函数。设置卫星星历,请在本类前执行 观测值的有效性检查与过滤。 /// </summary> public EmissionEphemerisRolverWithRange(IEphemerisService EphemerisService, DataSourceContext DataSouceProvider, EpochSatellite sat) : base(EphemerisService, DataSouceProvider, sat) { this.Name = "直接伪距法计算星历"; }
/// <summary> /// 通过文件构建,按照文件坐标计算,按照其采样率输出。 /// </summary> /// <param name="oFilePath"></param> /// <param name="EphemerisService"></param> /// <param name="tableName"></param> /// <param name="AngleCut"></param> /// <returns></returns> public static ObjectTableStorage BuildTable(string oFilePath, double AngleCut = 12, IEphemerisService EphemerisService = null, string tableName = null) { if (String.IsNullOrWhiteSpace(tableName)) { tableName = Path.GetFileName(oFilePath) + "-卫星高度角"; } RinexObsFileReader reader = new RinexObsFileReader(oFilePath); var header = reader.GetHeader(); var siteXyz = header.ApproxXyz; if (EphemerisService == null) { if (File.Exists(header.NavFilePath))//优先考虑自带导航文件 { EphemerisService = EphemerisDataSourceFactory.Create(header.NavFilePath); } else { EphemerisService = GlobalNavEphemerisService.Instance; } } var ephObj = EphemerisService.Get(SatelliteNumber.G01, reader.GetHeader().StartTime); if (ephObj == null) { EphemerisService = GlobalIgsEphemerisService.Instance; } var table = new ObjectTableStorage(tableName); while (reader.MoveNext()) { var time = reader.Current.ReceiverTime; AddRow(AngleCut, EphemerisService, siteXyz, table, time); } return(table); }
/// <summary> /// 比较大小。用于排序。如果为负数 则表示本对象较小。 /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual int CompareTo(IEphemerisService other) { return(this.TimePeriod.CompareTo(other.TimePeriod)); }
/// <summary> /// 通过文件构建,按照文件坐标计算,按照其采样率输出。 /// </summary> /// <param name="obsFile"></param> /// <param name="EphemerisService"></param> /// <param name="tableName"></param> /// <param name="AngleCut"></param> /// <returns></returns> public static ObjectTableStorage BuildTable(RinexObsFile obsFile, double AngleCut = 12, IEphemerisService EphemerisService = null, string tableName = null) { if (String.IsNullOrWhiteSpace(tableName)) { tableName = obsFile.Header.MarkerName + "-卫星高度角"; } if (EphemerisService == null) { EphemerisService = GlobalNavEphemerisService.Instance; } var siteXyz = obsFile.Header.ApproxXyz; var ephObj = EphemerisService.Get(SatelliteNumber.G01, obsFile.Header.StartTime); if (ephObj == null) { EphemerisService = GlobalIgsEphemerisService.Instance; } var table = new ObjectTableStorage(tableName); foreach (var sec in obsFile) { var time = sec.ReceiverTime; AddRow(AngleCut, EphemerisService, siteXyz, table, time); } return(table); }
/// <summary> /// 构造函数。设置卫星星历,请在本类前执行 观测值的有效性检查与过滤。 /// </summary> public EmissionEphemerisRolverWithCoord(IEphemerisService EphemerisService, DataSourceContext DataSouceProvider, EpochSatellite sat) : base(EphemerisService, DataSouceProvider, sat) { this.Name = "坐标迭代法"; }
/// <summary> /// Création d'un nouveau service /// </summary> public AstroService(IEphemerisService ephemeris) { // Create the engine AstroEngine = new Astro.AstroEngine(ephemeris); }
/// <summary> /// 拟合输出。 /// 当前策略,在众多数据源中,选择包含有效时间段内的进行计算并返回。 /// 待改进:如果有精密星历。。。。。 /// </summary> /// <param name="prn">卫星编号</param> /// <param name="gpsTime">时刻</param> /// <returns></returns> public override Ephemeris Get(SatelliteNumber prn, Time gpsTime) { if (!IsAvailable(gpsTime, prn.SatelliteType)) { return(null); } List <IEphemerisService> sources = this.dic[prn.SatelliteType]; //直接获取之 if (sources.Count == 0) { return(null); } bool caculated = false;//标记是否计算过 //获取星历并赋权 List <Ephemeris> results = new List <Ephemeris>(); foreach (var source in sources) { if (source.TimePeriod.Contains(gpsTime) || (source.TimePeriod.BufferedEnd >= gpsTime && source.TimePeriod.BufferedStart <= gpsTime)) { caculated = true; //是否包含这颗卫星 if (!source.Prns.Contains(prn)) { continue; } var result = source.Get(prn, gpsTime); if (result == null) { continue; } //赋权,只有一个就不用比较了。 if (sources.Count != 1 && result.Rms == null) { result.Rms = EphemerisUtil.GetRms(source.ServiceType); } results.Add(result); } } //别无二家,只能用它 if (results.Count == 1) { return(results[0]); } //根据权重进行选取 if (results.Count != 0) { var result = results[0]; foreach (var item in results) { if (result.Rms.Length > item.Rms.Length) { result = item; } } return(result); } //计算失败了,可能是根本就没有这颗卫星,继续计算仍然将失败。 if (caculated) { return(null); } //以上已经排除在单独文件有效范围内了。 //下面看是否在这些文件有效时间范围间隙内。 //如果在整体时间段内,但不在单独文件范围内,则前后联合起来加密, //如果间隔太远(如超过半天)则效果不好,因此在数据录入时应该判断。 //选择前后最接近的两个文件,这个时间段的起点部分在一个文件时间末尾,结束部分在一个文件的开始时间处。 //检查是否在可用的间隙内 var two = GetNearstService(gpsTime, prn.SatelliteType); IEphemerisService first = two[0]; IEphemerisService second = two[1]; double gap = (double)(two[1].TimePeriod.Start - two[0].TimePeriod.End); if (this.MaxGap.TotalSeconds < gap) { throw new Exception("星历间隙太大:" + TimeSpan.FromSeconds(gap).ToString() + ", 最大允许:" + MaxGap.ToString()); } //合并两者 //获取一个小时的数据,时间间隔为5分钟 List <Ephemeris> infosA = first.Gets(prn, first.TimePeriod.BufferedEnd - 3600, first.TimePeriod.BufferedEnd, 5 * 60); List <Ephemeris> infosB = second.Gets(prn, second.TimePeriod.BufferedStart, second.TimePeriod.BufferedStart + 3600, 5 * 60); List <Ephemeris> infosAList = new List <Ephemeris>(); foreach (var item in infosA) { if (item != null) { infosAList.Add(item); } } foreach (var item in infosB) { if (item != null) { infosAList.Add(item); } } //是否没有该星的服务 if (infosAList.Count == 0) { return(null); } EphemerisInterpolator interp = new EphemerisInterpolator(infosAList); var finalResult = interp.GetEphemerisInfo(gpsTime); return(finalResult);//怎样考虑精度信息????2014.12.26,czs //如果还不行 throw new NotImplementedException("数据源提供的信息暂不支持 " + prn + " 在 " + gpsTime + " 的解算。"); }
public void Init(GnsserConfig GnsserConfig, IEphemerisService ephemerisDataSource, Data.ISimpleClockService clockFile) { this.GnsserConfig = GnsserConfig; this.EphemerisDataSource = ephemerisDataSource; this.ClockFile = clockFile; }
/// <summary> /// 构造函数。设置卫星星历,请在本类前执行 观测值的有效性检查与过滤。 /// </summary> public EmissionEphemerisRolverWithDopplorSpeed(IEphemerisService EphemerisService, DataSourceContext DataSouceProvider, EpochSatellite sat) : base(EphemerisService, DataSouceProvider, sat) { this.Name = "多普勒频率法"; }
/// <summary> /// 构造函数 /// </summary> /// <param name="EphemerisService">星历服务</param> public EphemerisTimePeriodAvailableChecker(IEphemerisService EphemerisService) { this.Name = "星历检核"; this.EphemerisService = EphemerisService; }