/// <summary>
        /// 尝试加载NGA星历
        /// </summary>
        /// <param name="obsTime"></param>
        /// <param name="isWithTwoDays"></param>
        public void TryAddNgaEphemeris(Time obsTime, bool isWithTwoDays)
        {
            //NGA 预报星历
            if (ObservationDataSources != null && (CurrentService == null || CurrentService.SatCount == 0))
            {
                if (isWithTwoDays)//两天内
                {
                    StringBuilder sb = new StringBuilder();
                    //sb.Append("p");
                    sb.Append("NGA");
                    sb.Append(obsTime.GpsWeek);
                    sb.Append((int)obsTime.DayOfWeek);
                    sb.Append("1");
                    sb.Append(".sp3");
                    var fileName = sb.ToString();

                    string localDirectory = Setting.GnsserConfig.Nga9DayGPSpredsDirectory;
                    //首先检查本地是否已有星历,或者今天(24小时内)已经下载过
                    var fs = Directory.GetFiles(localDirectory, "*.sp3");
                    foreach (var item in fs)
                    {
                        if (item.Contains(fileName) && new FileInfo(item).CreationTimeUtc > (DateTime.UtcNow - TimeSpan.FromDays(1)))
                        {
                            this.CurrentService = EphemerisDataSourceFactory.Create(item);
                            var msg = "采用了NGA预报星历。" + this.CurrentService;
                            log.Info(msg);
                            break;
                        }
                    }

                    if (isWithTwoDays && (CurrentService == null || CurrentService.SatCount == 0))
                    {       //每天UTC正午12点前更新当天和后8天的数据
                        string url   = "ftp://ftp.nga.mil/pub2/gps/predictions/9DayGPSpreds/";
                        var    files = Geo.Utils.NetUtil.DownloadFtpDirecotryOrFile(url, "*.*", localDirectory, "anonymous", "");
                        var    sp3s  = new List <string>();
                        foreach (var item in files)
                        {
                            if (!File.Exists(item))
                            {
                                continue;
                            }
                            var destPath = item + ".sp3";
                            Geo.Utils.FileUtil.MoveFile(item, destPath, true);
                            sp3s.Add(destPath);
                        }

                        foreach (var item in sp3s)
                        {
                            if (item.Contains(fileName))
                            {
                                this.CurrentService = EphemerisDataSourceFactory.Create(item);
                                var msg = "新下载并采用了NGA预报星历。" + this.CurrentService;
                                log.Info(msg);
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        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();
            }
        }
        private void fileOpenControl_eph_FilePathSetted(object sender, EventArgs e)
        {
            var path = this.fileOpenControl_eph.FilePath;

            if (!System.IO.File.Exists(path))
            {
                return;
            }
            dataSourse = EphemerisDataSourceFactory.Create(path);
            this.timePeriodControl1.SetTimePerid(dataSourse.TimePeriod);
        }
Example #4
0
        /// <summary>
        /// 具体的执行
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="outPath"></param>
        protected override void Execute(string inPath, string outPath)
        {
            if (this.IsCancel)
            {
                return;
            }
            var Solver = new SingleSiteGnssSolveStreamer();

            if (PathUtil.IsValidPath(CurrentParam.EphemerisPath))
            {
                if (this.EphemerisDataSource == null || this.EphemerisDataSource.Name != Path.GetFileName(CurrentParam.EphemerisPath))
                {
                    var sp3 = InputFileManager.GetLocalFilePath(CurrentParam.EphemerisPath, "*.sp3");
                    if (PathUtil.IsValidPath(sp3))
                    {
                        this.EphemerisDataSource   = EphemerisDataSourceFactory.Create(sp3);
                        Solver.EphemerisDataSource = this.EphemerisDataSource;
                    }
                }
            }
            if (PathUtil.IsValidPath(CurrentParam.ClockPath))
            {
                if (this.ClockFile == null || this.ClockFile.Name != Path.GetFileName(CurrentParam.ClockPath))
                {
                    var clk = InputFileManager.GetLocalFilePath(CurrentParam.ClockPath, "*.clk");
                    if (PathUtil.IsValidPath(clk))
                    {
                        this.ClockFile   = new Data.SimpleClockService(clk);
                        Solver.ClockFile = this.ClockFile;
                    }
                }
            }
            if (Option == null)
            {
                Option = GnssProcessOptionManager.Instance[GnssSolverType.无电离层组合PPP];
            }
            //Solver.InfoProduced += Solver_InfoProduced;
            //Solver.ResultProduced += Solver_ResultProduced;
            //Solver.EpochEntityProduced += Solver_EpochEntityProduced;
            Solver.Completed += Solver_Completed;
            Solver.Option     = Option;
            Solver.Option.IsOutputEpochResult = false;
            Solver.Init(inPath);

            var count = Solver.DataSource.ObsInfo.Count;

            //串行进度条初始化,阶段计算的第一个
            //if (!ParallelConfig.EnableParallel) { this.ProgressBar.InitFirstProcessCount(count); }

            log.Info(Solver.Name + " 初始化完毕,开始计算。");

            Solver.Run();
            log.Info(Solver.Name + " 计算完成。");
        }
Example #5
0
 /// <summary>
 /// 尝试加载自带的星历文件。
 /// </summary>
 public void TryLoadEphemerisServices()
 {
     EphemerisServices = new BaseDictionary <string, IEphemerisService>();
     foreach (var item in DataSources)
     {
         if (System.IO.File.Exists(item.NavPath))
         {
             var eph = EphemerisDataSourceFactory.Create(item.NavPath);
             EphemerisServices[item.Name] = eph;
         }
     }
 }
Example #6
0
        private void Init()
        {
            navFile = EphemerisDataSourceFactory.Create(FilePath);
            this.bindingSource_satsPrn.DataSource = navFile.Prns;

            sathelper = new SatInfoCaculator(
                navFile,
                StationPos);

            this.dateTimePicker_from.Value   = navFile.TimePeriod.Start.DateTime;
            this.dateTimePicker_to.Value     = navFile.TimePeriod.End.DateTime;
            this.dateTimePicker_moment.Value = this.dateTimePicker_from.Value;
        }
Example #7
0
        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);
        }
Example #8
0
        /// <summary>
        /// 数据源读取
        /// </summary>
        private void LoadDataSource()
        {
            startTime = DateTime.Now;

            //星历数据源
            ephemerisDataSource = null;
            if (IsSetEphemerisFile)//读取星历数据
            {
                string            ephemerisPath = this.textBox_navPath.Text;
                FileEphemerisType ephType       = EphemerisDataSourceFactory.GetFileEphemerisTypeFromPath(ephemerisPath);
                ephemerisDataSource = EphemerisDataSourceFactory.Create(ephemerisPath);
            }
            //加载文件数据
            this.rovPath          = this.textBox_obsFile_rov.Text;
            this.RefObsDataSource = new RinexFileObsDataSource(this.textBox_obsPath_ref.Text);
            this.RovObsDataSource = new RinexFileObsDataSource(rovPath);

            //使用外部设置的概略坐标。
            if (this.rmsedXyzControl_rov.IsEnabled)
            {
                this.RovObsDataSource.SiteInfo.SetApproxXyz(this.rmsedXyzControl_rov.RmsedXyz.Value);
                this.RovObsDataSource.SiteInfo.EstimatedXyzRms = this.rmsedXyzControl_rov.RmsedXyz.Rms;
            }
            //概略坐标显示到界面上。
            rmsedXyzControl_rov.SetRmsedXyz(new RmsedXYZ(RovObsDataSource.SiteInfo.ApproxXyz, RovObsDataSource.SiteInfo.EstimatedXyzRms));


            //使用外部设置的概略坐标。
            if (this.rmsedXyzControl_ref.IsEnabled)
            {
                this.RefObsDataSource.SiteInfo.SetApproxXyz(this.rmsedXyzControl_ref.RmsedXyz.Value);
                this.RefObsDataSource.SiteInfo.EstimatedXyzRms = this.rmsedXyzControl_ref.RmsedXyz.Rms;
            }
            //概略坐标显示到界面上。
            rmsedXyzControl_ref.SetRmsedXyz(new RmsedXYZ(RefObsDataSource.SiteInfo.ApproxXyz, RefObsDataSource.SiteInfo.EstimatedXyzRms));



            //检查是否读取钟差数据
            clockFile = null;
            if (this.checkBox_enableClockFile.Checked)
            {
                clockFile = new Data.SimpleClockService(this.textBox_ClockPath.Text);
            }

            TimeSpan span = DateTime.Now - startTime;

            ShowInfo("数据已读入,时间(秒):" + span.TotalSeconds);
        }
Example #9
0
        private void fileOpenControl1_FilePathSetted(object sender, EventArgs e)
        {
            string navPath = this.fileOpenControl_ephe.FilePath;

            if (!System.IO.File.Exists(navPath))
            {
                return;
            }
            try
            {
                var phe = EphemerisDataSourceFactory.Create(navPath);
                this.timeLoopControl1.TimePeriodControl.SetTimePerid(phe.TimePeriod);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #10
0
 /// <summary>
 /// 数据源读取
 /// </summary>
 private static void ReadFiles(GnsserConfig config)
 {
     //加载文件数据
     observationDataSource = new RinexFileObsDataSource(config.ObsPath);
     SiteInfo = observationDataSource.SiteInfo;
     //是否读取星历文件,如果设置了,且存在则读取只
     if (File.Exists(config.NavPath))
     {
         ephemerisDataSource = EphemerisDataSourceFactory.Create(config.NavPath);
     }
     //是否有精密星历
     if (File.Exists(config.ClkPath))
     {
         clockFile = new ClockService(config.ClkPath);
     }
 }
        private void button_read_Click(object sender, EventArgs e)
        {
            //try
            //{
            var path = this.fileOpenControl_eph.FilePath;

            if (!System.IO.File.Exists(path))
            {
                Geo.Utils.FormUtil.ShowWarningMessageBox("文件不存在!" + path);
                return;
            }
            dataSourse = EphemerisDataSourceFactory.Create(path);
            this.dataGridView1.DataSource  = bindingSource1;
            this.bindingSource1.DataSource = dataSourse.Gets();


            bindingSource_prn.DataSource = dataSourse.Prns;


            arrayCheckBoxControl_prns.Init(dataSourse.Prns);


            //设置时间间隔
            this.timePeriodControl1.SetTimePerid(dataSourse.TimePeriod);
            //}
            //catch (Exception ex)
            //{
            //    Geo.Utils.FormUtil.HandleException(ex, ex.Message);
            //}
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Path.GetFileName(path) + ",卫星数量 : " + dataSourse.Prns.Count);

            var types = SatelliteNumber.GetSatTypes(dataSourse.Prns);

            types.Sort();
            foreach (var type in types)
            {
                var prns = dataSourse.GetPrns(type);
                prns.Sort();
                sb.AppendLine(type + " ,共" + prns.Count + " 颗:" + Geo.Utils.EnumerableUtil.ToString(prns, ","));
            }

            log.Info(sb.ToString());
        }
Example #12
0
        /// <summary>
        /// 创建单点定位
        /// </summary>
        /// <param name="obsPath">测站信息</param>
        /// <param name="startTime">起始计算时间</param>
        /// <returns></returns>
        private IonFreeDoubleDifferPositioner BuildPositioner(string obsPath, RinexFileObsDataSource refStationPath, BufferedTimePeriod startTime)
        {
            GnssProcessOption PositionOption = GetModel(startTime);

            #region 星历钟差数据源配置
            #region 星历数据配置
            FileEphemerisService ephemerisDataSource = null;
            if (IsSetEphemerisFile)
            {
                string ephemerisPath = this.textBox_navPath.Text;
                if (!File.Exists(ephemerisPath))
                {
                    throw new FileNotFoundException("指定星历文件不存在!\r\n" + ephemerisPath);
                }
                FileEphemerisType ephType = EphemerisDataSourceFactory.GetFileEphemerisTypeFromPath(ephemerisPath);
                ephemerisDataSource = EphemerisDataSourceFactory.Create(ephemerisPath);
            }
            #endregion
            #region 钟差数据配置
            Data.ISimpleClockService clock = null;
            if (this.checkBox_enableClockFile.Checked)
            {
                clock = new Data.SimpleClockService(this.textBox_ClockPath.Text);
            }
            #endregion
            #endregion

            #region 定位器构造


            //加载文件数据
            RinexFileObsDataSource refObservationDataSource = (refStationPath);

            var rovObservationDataSource = new RinexFileObsDataSource(obsPath);

            DataSourceContext             context = DataSourceContext.LoadDefault(PositionOption, rovObservationDataSource, ephemerisDataSource, clock);
            IonFreeDoubleDifferPositioner pp      = new IonFreeDoubleDifferPositioner(context, PositionOption);

            //pp.Produced += pp_ProgressIncreased;
            return(pp);

            #endregion
        }
Example #13
0
        /// <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);
        }
Example #14
0
        private void button_read_Click(object sender, EventArgs e)
        {
            try
            {
                ephemerisA = EphemerisDataSourceFactory.Create(this.textBox_pathA.Text, FileEphemerisType.Unkown, false);
                ephemerisB = EphemerisDataSourceFactory.Create(this.textBox_pathB.Text, FileEphemerisType.Unkown, false);
                List <SatelliteNumber> commonPrns = ephemerisA.Prns.FindAll(m => ephemerisB.Prns.Contains(m));

                if (commonPrns.Count == 0)
                {
                    Geo.Utils.FormUtil.ShowWarningMessageBox("没有共同卫星,无法比较!");
                }

                this.bindingSource_prns.DataSource = commonPrns;
                this.bindingSource1.DataSource     = ephemerisA.Gets();
                this.bindingSource2.DataSource     = ephemerisB.Gets();
                //设置时间间隔
                this.dateTimePicker_from.Value = ephemerisA.TimePeriod.Start.DateTime > ephemerisB.TimePeriod.Start.DateTime ? ephemerisA.TimePeriod.Start.DateTime : ephemerisB.TimePeriod.Start.DateTime;
                this.dateTimePicker_to.Value   = ephemerisA.TimePeriod.End.DateTime < ephemerisB.TimePeriod.End.DateTime ? ephemerisA.TimePeriod.End.DateTime : ephemerisB.TimePeriod.End.DateTime;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #15
0
        /// <summary>
        /// 初始化
        /// </summary>
        public override void Init()
        {
            //缓存的数据可能被过滤或删除,因此必须大于最小历元数加上断裂数量
            this.BufferSize = this.Option.MinEpochCount + this.Option.MaxBreakCount + 5;

            //构建数据流
            base.Init();
            if (Option.IndicatedEphemeris.Enabled && File.Exists(Option.IndicatedEphemeris.Value))
            {
                EphemerisService = EphemerisDataSourceFactory.Create(Option.IndicatedEphemeris.Value);
            }
            if (EphemerisService == null)
            {
                EphemerisService = GlobalNavEphemerisService.Instance;
            }

            var OldHeader = ReadOriginalHeader(FilePath);

            this.Option.Interval    = Math.Max(Option.Interval, OldHeader.Interval);
            this.InputTimeInMinutes = (OldHeader.EndTime - OldHeader.StartTime) / 60.0;
            this.CurrentStartTime   = OldHeader.StartTime;
            this.OldHeader          = OldHeader;
            this.TableTextManager   = new ObjectTableManager(10000, OutputDirectory);
            this.TableTextManager.Clear();

            this.NumericalAlignerManagerPhaseA = new NumericalAlignerManager <SatelliteNumber, Time>(this.Option.Interval * 3, m => m.SecondsOfWeek);
            this.NumericalAlignerManagerPhaseB = new NumericalAlignerManager <SatelliteNumber, Time>(this.Option.Interval * 3, m => m.SecondsOfWeek);
            this.PhaseAAmenderAligner          = new NumericalAlignerManager <SatelliteNumber, Time>(this.Option.Interval * 3, m => m.SecondsOfWeek);

            PhaseACycleSlipAmender = new TimeNumeralWindowDataManager <SatelliteNumber>(this.BufferSize - 2, this.Option.Interval * 3);
            PhaseBCycleSlipAmender = new TimeNumeralWindowDataManager <SatelliteNumber>(this.BufferSize - 2, this.Option.Interval * 3);

            LastEpoch = this.OldHeader.EndTime;
            //医学院, 75-112,33, 900-9500,学区房,五证全

            SmallObsPeriodRemover = new SmallObsPeriodRemover <RinexEpochObservation>(BufferedStream, Option.MinEpochCount, Option.MaxBreakCount, LastEpoch, this.OldHeader.Interval);
        }
Example #16
0
        /// <summary>
        /// 检查并更新
        /// </summary>
        /// <param name="ephFilePath"></param>
        /// <param name="clkFilePath"></param>
        /// <param name="isForceToUpdate"></param>
        public void CheckOrUpdateEphAndClkService(string ephFilePath, string clkFilePath, bool isForceToUpdate = false)
        {
            if ((this.EphemerisService == null || this.EphemerisService.SatCount == 0) ||
                isForceToUpdate)
            {
                FileEphemerisService ephemerisDataSource = null;
                if (File.Exists(ephFilePath))
                {
                    ephemerisDataSource   = EphemerisDataSourceFactory.Create(ephFilePath, FileEphemerisType.Unkown, true, Option.MinSuccesiveEphemerisCount);
                    this.EphemerisService = ephemerisDataSource;
                }
            }

            if ((this.SimpleClockService == null || this.EphemerisService.SatCount == 0) ||
                isForceToUpdate)
            {
                ISimpleClockService ClockService = null;
                if (File.Exists(clkFilePath))
                {
                    ClockService = new SimpleClockService(clkFilePath);
                }
                this.SimpleClockService = ClockService;
            }
        }
Example #17
0
        /// <summary>
        /// 具体的执行
        /// </summary>
        /// <param name="baseline"></param>
        /// <param name="outPath"></param>
        protected void Execute(Baseline baseline, string outPath)
        {
            if (PathUtil.IsValidPath(CurrentParam.EphemerisPath))
            {
                if (this.EphemerisDataSource == null || this.EphemerisDataSource.Name != Path.GetFileName(CurrentParam.EphemerisPath))
                {
                    var sp3 = InputFileManager.GetLocalFilePath(CurrentParam.EphemerisPath, "*.sp3");
                    if (PathUtil.IsValidPath(sp3))
                    {
                        this.EphemerisDataSource = EphemerisDataSourceFactory.Create(sp3);
                    }
                }
            }
            if (PathUtil.IsValidPath(CurrentParam.ClockPath))
            {
                if (this.ClockFile == null || this.ClockFile.Name != Path.GetFileName(CurrentParam.ClockPath))
                {
                    var clk = InputFileManager.GetLocalFilePath(CurrentParam.ClockPath, "*.clk");
                    if (PathUtil.IsValidPath(clk))
                    {
                        this.ClockFile = new Data.SimpleClockService(clk);
                    }
                }
            }

            var refPath = ObsFiles.Find(m => m.ToLower().Contains(baseline.StartName.ToLower()));
            var rovPath = ObsFiles.Find(m => m.ToLower().Contains(baseline.EndName.ToLower()));

            if (refPath == null || rovPath == null)
            {
                throw new ArgumentException("没有找到基线对应的文件!" + baseline.ToString());
                return;
            }
            var inputPathes = new string[] { refPath, rovPath };

            RinexFileObsDataSource refObsDataSource = new RinexFileObsDataSource(refPath, true);
            RinexFileObsDataSource rovObsDataSource = new RinexFileObsDataSource(rovPath, true);

            if (SiteInfoDics != null)
            {
                var siteName = baseline.StartName.ToUpper();
                if (SiteInfoDics.ContainsKey(siteName))
                {
                    refObsDataSource.SiteInfo.SetApproxXyz(SiteInfoDics[siteName].EstimatedXyz);
                }
                siteName = baseline.EndName.ToUpper();
                if (SiteInfoDics.ContainsKey(siteName))
                {
                    rovObsDataSource.SiteInfo.SetApproxXyz(SiteInfoDics[siteName].EstimatedXyz);
                }
            }

            GnssProcessOption option = GnssProcessOption.GetDefault(GnsserConfig, refObsDataSource.ObsInfo);

            option.GnssSolverType = GnssSolverType.无电离层双差;

            var source = new MultiSiteObsStream(inputPathes, BaseSiteSelectType.GeoCenter, true, "");
            DataSourceContext context = DataSourceContext.LoadDefault(option, source, EphemerisDataSource, ClockFile);

            IntegralGnssFileSolver Solver = new IntegralGnssFileSolver();

            Solver.Completed += Solver_Completed;
            Solver.Option     = option;
            Solver.IsCancel   = false;
            Solver.Solver     = GnssSolverFactory.Create(context, option);;

            Solver.Init(inputPathes);

            Solver.Run();
            var last = Solver.CurrentGnssResult;

            lock (locker)
            {
                Geo.Utils.FileUtil.CheckOrCreateDirectory(Path.GetDirectoryName(outPath));
                SaveLastResult(last);
            }
        }
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            var prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' });
            Dictionary <SatelliteNumber, StreamWriter> prnWritersOfBroadcast      = new Dictionary <SatelliteNumber, StreamWriter>();
            Dictionary <SatelliteNumber, StreamWriter> prnWritersOfBroadcastError = new Dictionary <SatelliteNumber, StreamWriter>();

            FileEphemerisService coll;
            FileEphemerisService coll0;
            ClockService         collOfPrecise;

            string[] pathes          = this.textBox_Broadcast.Lines;
            string[] pathesOfPrecise = this.textBox_Pathes.Lines;
            string   firstDayOfWeek  = GetDayOfWeekFromBroadcastFileName(pathes[0]);
            string   lastDayOfWeek   = GetDayOfWeekFromBroadcastFileName(pathes[pathes.Length - 1]);
            string   filename        = Path.GetFileNameWithoutExtension(pathesOfPrecise[0]).Substring(0, 3) + GetFileEphemerisTypeFromPath(pathesOfPrecise[0]).ToString();;

            foreach (var item in prns)
            {
                var pathOfBroadcast      = Path.Combine(directory, item.ToString() + "Broadcast" + "-" + firstDayOfWeek + "-" + lastDayOfWeek + ".txt");
                var pathOfBroadcastError = Path.Combine(directory, item.ToString() + "BroadcastError" + "-" + filename + firstDayOfWeek + "-" + lastDayOfWeek + ".txt");
                prnWritersOfBroadcast[item]      = new StreamWriter(new FileStream(pathOfBroadcast, FileMode.Create));
                prnWritersOfBroadcastError[item] = new StreamWriter(new FileStream(pathOfBroadcastError, FileMode.Create));
            }

            List <string> listPath = new List <string> ();

            for (int i = 0; i < pathesOfPrecise.Length; i++)
            {
                listPath.Add(pathesOfPrecise[i]);
            }

            #region
            coll0 = EphemerisDataSourceFactory.Create(pathes[0]);
            foreach (var pathItem in pathes)
            {
                coll = EphemerisDataSourceFactory.Create(pathItem);
                string dayOfWeek = GetDayOfWeekFromBroadcastFileName(pathItem);
                for (int index = 0; index < listPath.Count; index++)
                {
                    if (listPath[index].Contains(dayOfWeek))
                    {
                        collOfPrecise = new ClockService(listPath[index]);
                        Time end = collOfPrecise.TimePeriod.End;
                        foreach (var prn in prns)
                        {
                            var writerOfBroadcast      = prnWritersOfBroadcast[prn];
                            var writerOfBroadcastError = prnWritersOfBroadcastError[prn];
                            var allOfBroadcast         = coll.Gets(prn, coll.TimePeriod.Start, end);
                            var allOfBroadcast0        = coll0.Gets(prn, coll0.TimePeriod.Start, coll0.TimePeriod.End);
                            var allOfPrecise           = collOfPrecise.GetClocks(prn);
                            if (allOfBroadcast == null)// || allOfPrecise == null || allOfPrecise.Count==0)
                            {
                                continue;
                            }
                            allOfBroadcast.Sort();
                            allOfBroadcast0.Sort();
                            if (prn.SatelliteType == SatelliteType.E)
                            {
                            }
                            int  interval = 0;
                            Time start0   = collOfPrecise.TimePeriod.Start;
                            switch (prn.SatelliteType)
                            {
                            case SatelliteType.E: interval = 600; break;

                            case SatelliteType.C: interval = 3600; break;

                            case SatelliteType.G: interval = 7200; break;

                            case SatelliteType.R: interval = 1800; start0 = collOfPrecise.TimePeriod.Start + 900; break;

                            case SatelliteType.J: interval = 896; break;

                            default: break;
                            }
                            for (Time i = start0; i <= end; i += interval)
                            {
                                var findOfPrecise   = allOfPrecise.SingleOrDefault(m => m.Time == i);
                                var findOfBroadcast = allOfBroadcast.SingleOrDefault(m => m.Time == i);
                                if (findOfBroadcast == null)
                                {
                                    findOfBroadcast = allOfBroadcast0.SingleOrDefault(m => m.Time == i);
                                }
                                if (findOfPrecise == null || findOfBroadcast == null)
                                {
                                    findOfPrecise = new AtomicClock()
                                    {
                                        Time = i, Prn = prn, ClockBias = 9999999999.0
                                    };

                                    if (findOfBroadcast == null)
                                    {
                                        findOfBroadcast = new Ephemeris()
                                        {
                                            Time = i, Prn = prn, ClockBias = 9999999999.0
                                        }
                                    }
                                    ;
                                }
                                else
                                {
                                    findOfPrecise.ClockBias = findOfPrecise.ClockBias - findOfBroadcast.ClockBias;
                                }

                                if (findOfBroadcast.ClockBias == 9999999999.0 && prn.SatelliteType == SatelliteType.G)
                                {
                                    findOfBroadcast = allOfBroadcast.FirstOrDefault(m => Math.Abs((m.Time - i) * 1.0) < 60);
                                    if (findOfBroadcast == null)
                                    {
                                        findOfBroadcast = allOfBroadcast0.FirstOrDefault(m => Math.Abs((m.Time - i) * 1.0) < 60);
                                    }
                                    if (findOfBroadcast == null)
                                    {
                                        findOfBroadcast = new Ephemeris()
                                        {
                                            Time = i, Prn = prn, ClockBias = 9999999999.0
                                        }
                                    }
                                    ;
                                }
                                writerOfBroadcast.WriteLine(findOfBroadcast.GetSimpleTabValues());
                                writerOfBroadcastError.WriteLine(findOfPrecise.GetTabValues());
                            }


                            //for (Time i = collOfPrecise.TimePeriod.Start; i <= end1; i = i + intervalSec)
                            //{
                            //    var findOfBroadcast = allOfBroadcast.SingleOrDefault(m => m.Time == i);
                            //    var findOfPrecise = allOfBroadcast.SingleOrDefault(m => m.Time == i);
                            //    if (findOfBroadcast == null || findOfPrecise == null)
                            //    {
                            //        if (!fillWithZero) continue;

                            //        findOfBroadcast = new Ephemeris() { Time = i, Prn = prn };
                            //    }
                            //    writerOfBroadcast.WriteLine(findOfBroadcast.GetTabValues());
                            //    findOfPrecise.ClockBias = findOfPrecise.ClockBias - findOfBroadcast.ClockBias;
                            //    writerOfBroadcastError.WriteLine(findOfPrecise.GetTabValues());
                            //}
                        }
                        coll0 = EphemerisDataSourceFactory.Create(pathItem);
                        listPath.RemoveAt(index);
                        break;
                    }
                }
            }


            #endregion

            foreach (var item in prnWritersOfBroadcast)
            {
                item.Value.Flush();
                item.Value.Close();
            }
            foreach (var item in prnWritersOfBroadcastError)
            {
                item.Value.Flush();
                item.Value.Close();
            }

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Example #19
0
        protected override void Run(string[] inputPathes)
        {
            string navFile = fileOpenControl_nav.GetFilePath();


            //输出的采样间隔
            TimeLooper looper  = timeLoopControl1.GetTimeLooper();
            var        builder = new SatElevatoinTableBuilder(inputPathes, this.SatelliteTypes, looper, namedFloatControl1AngleCut.Value);

            builder.OutputDirectory = this.OutputDirectory;
            builder.ProgressViewer  = this.ProgressBar;
            if (File.Exists(navFile))
            {
                var ephService = EphemerisDataSourceFactory.Create(navFile);
                builder.EphemerisService = ephService;
                log.Info("采用了星历服务 " + ephService);
            }
            var tableMgr = builder.Build();

            if (checkBox_enableStatistics.Checked)
            {
                int angleStep = 10;
                var table     = tableMgr.First;
                #region  卫星历元数统计
                var eleTable = new ObjectTableStorage(table.Name + "_不同高度截止角的历元数量统计");
                for (int i = 0; i <= 30; i = i + angleStep)
                {
                    eleTable.NewRow();
                    eleTable.AddItem("Elevation", i);
                    var count = table.GetCount(new Func <double, bool>(val => val >= i));
                    eleTable.AddItem(count);
                    eleTable.EndRow();
                }
                #endregion

                #region 卫星颗数统计
                var rowCountDics = new Dictionary <int, Dictionary <DateTime, int> >();
                for (int i = 0; i <= 30; i = i + angleStep)
                {
                    rowCountDics[i] = table.GetEachRowCount <DateTime>(new Func <double, bool>(val => val >= i));
                }

                var satCountTable = new ObjectTableStorage(table.Name + "_可用卫星数量统计");
                var first         = rowCountDics[0];
                foreach (var item in first)
                {
                    var index = item.Key;
                    satCountTable.NewRow();
                    satCountTable.AddItem("Epoch", index);
                    foreach (var rows in rowCountDics)
                    {
                        var val = rows.Value[index];
                        satCountTable.AddItem(rows.Key, val);
                    }
                    satCountTable.EndRow();
                }
                #endregion

                #region 卫星连续历元数统计
                var maxValTable             = new ObjectTableStorage(table.Name + "_最大数据统计");
                var maxSequentialCountTable = new ObjectTableStorage(table.Name + "_最大连续历元数量统计");
                var minSequentialCountTable = new ObjectTableStorage(table.Name + "_最小连续历元数量统计");
                var satPeriodCountTable     = new ObjectTableStorage(table.Name + "_卫星出现次数统计");
                for (int i = 0; i <= 30; i = i + angleStep)
                {
                    maxSequentialCountTable.NewRow();
                    maxSequentialCountTable.AddItem("Elevation", i);

                    minSequentialCountTable.NewRow();
                    minSequentialCountTable.AddItem("Elevation", i);

                    satPeriodCountTable.NewRow();
                    satPeriodCountTable.AddItem("Elevation", i);

                    maxValTable.NewRow();
                    maxValTable.AddItem("Elevation", i);

                    var dic = table.GetSequentialCountOfAllCol <DateTime>(new Func <double, bool>(val => val >= i));
                    foreach (var item in dic)
                    {
                        item.Value.Sort(new Comparison <Segment <DateTime> >((one, two) => (int)((two.End - two.Start) - (one.End - one.Start)).TotalSeconds));
                        //最大时段
                        var max     = item.Value[0];
                        var maxSpan = (max.End - max.Start).TotalHours;
                        maxSequentialCountTable.AddItem(item.Key, maxSpan);

                        //最大值
                        var maxval = table.GetMaxValue(item.Key, max.Start, max.End);
                        maxValTable.AddItem(item.Key, maxval);


                        //最小时段
                        var lastIndex = item.Value.Count - 1;
                        var min       = item.Value[lastIndex];
                        var minSpan   = (min.End - min.Start).TotalHours;
                        if (lastIndex == 0)
                        {
                            minSpan = 0;
                        }
                        minSequentialCountTable.AddItem(item.Key, minSpan);
                        //时段次数输出
                        satPeriodCountTable.AddItem(item.Key, item.Value.Count);
                    }

                    maxValTable.EndRow();
                    maxSequentialCountTable.EndRow();
                    minSequentialCountTable.EndRow();
                    satPeriodCountTable.EndRow();
                }

                #endregion


                if (checkBox_sortPrnSatistics.Checked)
                {
                    maxValTable.SortColumns();
                    eleTable.SortColumns();
                    maxSequentialCountTable.SortColumns();
                    minSequentialCountTable.SortColumns();
                    satPeriodCountTable.SortColumns();
                }

                tableMgr.Add(maxValTable);
                tableMgr.Add(satCountTable);
                tableMgr.Add(eleTable);
                tableMgr.Add(maxSequentialCountTable);
                tableMgr.Add(minSequentialCountTable);
                tableMgr.Add(satPeriodCountTable);
            }

            BindTableA(tableMgr.First);

            tableMgr.WriteAllToFileAndClearBuffer(tableMgr.First);
        }
Example #20
0
        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();
        }
Example #21
0
        /// <summary>
        /// 具体的执行
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="outPath"></param>
        protected override void Execute(string inPath, string outPath)
        {
            this.EphemerisDataSource = EphemerisDataSourceFactory.Create(CurrentParam.EphemerisPath);
            if (File.Exists(CurrentParam.ClockPath))
            {
                this.ClockFile = new Data.SimpleClockService(CurrentParam.ClockPath);
            }

            RinexFileObsDataSource obsDataSource = new RinexFileObsDataSource(inPath, true);
            GnssProcessOption      option        = GnssProcessOption.GetDefault(GnsserConfig, obsDataSource.ObsInfo);

            DataSourceContext      DataSourceContext = DataSourceContext.LoadDefault(option, obsDataSource, this.EphemerisDataSource, ClockFile);
            EpochInfoReviseManager reviser           = new EpochInfoReviseManager(DataSourceContext, option);

            //写入到流
            Gnsser.Data.Rinex.RinexObsFileWriter writer = new Data.Rinex.RinexObsFileWriter(outPath, CurrentParam.OutputVersion);
            EpochInfoToRinex EpochInfoToRinex           = new Domain.EpochInfoToRinex(this.CurrentParam.OutputVersion, true);

            //直接写入数据流,并不存储,以节约空间。
            Gnsser.Data.Rinex.RinexObsFileHeader newHeader = null;
            int maxBufferEpoch = 200;
            int i = 0;

            foreach (var item in obsDataSource)
            {
                //预处理在此进行!!!
                var processed = item;
                reviser.Revise(ref processed);

                if (processed != null)
                {
                    var epochObs = EpochInfoToRinex.Build(processed);
                    if (newHeader == null)
                    {
                        newHeader = epochObs.Header;
                        writer.WriteHeader(newHeader);
                    }

                    writer.WriteEpochObservation(epochObs);

                    if (i > maxBufferEpoch)
                    {
                        writer.Writer.Flush();
                    }
                }
                i++;
            }
            writer.Writer.Close();

            TimeSpan      span = DateTime.Now - startTime;
            StringBuilder sb   = new StringBuilder();

            sb.Append("耗时:" + DateTimeUtil.GetFloatString(span));
            sb.AppendLine(",输出到 " + outPath);

            //信息汇总
            lock (locker)
            {
                var path = Path.Combine(Path.GetDirectoryName(outPath), "PositionPreprocess.summery");

                Geo.Utils.FileUtil.CheckOrCreateDirectory(Path.GetDirectoryName(path));
                File.AppendAllText(path, sb.ToString());
            }
        }
Example #22
0
        /// <summary>
        /// 获取服务,根据设置自动判断。
        /// </summary>
        /// <returns></returns>
        public override IEphemerisService GetService()
        {
            //检查当前,避免重复加载
            if (IsCurrentEphemerisServiceAvailable())
            {
                log.Info("返回已有星历服务 " + CurrentService);
                return(CurrentService);
            }

            if (ProcessOption.IsUseUniqueEphemerisFile)
            {
                this.CurrentService = EphemerisDataSourceFactory.Create(ProcessOption.EphemerisFilePath);
                log.Info("成功载入选项指定星历文件:  " + ProcessOption.EphemerisFilePath);
                return(CurrentService);
            }

            if (ProcessOption.IsIndicatedEphemerisPathes) //优先指定的星历文件
            {
                var ephePathes = ProcessOption.GetIndicatedEphemerisPathes();

                this.CurrentService = new IndicatedEphemerisService(ephePathes, ProcessOption, DataSourceOption.GetIgsProductSourceOption(CurrentSession));
                //EphemerisDataSourceFactory.Create(ProcessOption.EphemerisFilePath);
                StringBuilder sb = new StringBuilder();
                foreach (var item in ephePathes)
                {
                    sb.AppendLine(item.Key + ":" + item.Value);
                }
                log.Info("成功载入选项指定星历文件:\r\n " + sb.ToString());
                return(CurrentService);
            }



            //如果不需要精密星历,且数据文件夹中有导航文件,则加载之
            if (ObservationDataSources != null && !this.ProcessOption.IsPreciseEphemerisFileRequired)
            {
                ObservationDataSources.TryLoadEphemerisServices();
                if (ObservationDataSources.EphemerisServices.Count > 0)
                {
                    this.CurrentService = ObservationDataSources.EphemerisServices.First;

                    var msg = "设置没有指定星历,也不需要精密星历,发现了导航星历,因此采用此一个导航星历。" + this.CurrentService;
                    log.Info(msg);
                    return(CurrentService);
                }
            }

            //自动匹配精密星历
            if (DataSourceOption.EnableAutoFindingFile)
            {
                // new IgsEphemerisServiceAutoProvider(DataSourceOption.GetIgsProductSourceOption(CurrentSession)).GetEphemerisService();
                GlobalIgsEphemerisService.Instance.IgsEphAutoProvider.IsConnectIgsProduct = this.ProcessOption.IsConnectIgsDailyProduct;

                //尝试获取一个,如果失败则表示不可用
                if (CurrentSession.SatelliteTypes.Count == 0)
                {
                    log.Error("请指定GNSS系统类型");
                }
                else if (GlobalIgsEphemerisService.Instance.IsAvailable(this.CurrentSession.TimePeriod.Start, this.CurrentSession.SatelliteTypes[0]))
                {
                    this.CurrentService = GlobalIgsEphemerisService.Instance;

                    if (this.CurrentService == null || CurrentService.SatCount == 0)
                    {
                        log.Info("没有匹配上星历文件 " + CurrentService);
                    }
                    else
                    {
                        //设置拟合阶次,放在此处不是很合理,2019.05.15,czs
                        GlobalIgsEphemerisService.Instance.IgsEphAutoProvider.InerpolateOrder = this.ProcessOption.EphemerisInterpolationOrder;

                        log.Info("成功自动匹配星历文件 " + CurrentService);
                        return(CurrentService);
                    }
                }
            }
            //自动匹配精密星历
            //if (DataSourceOption.EnableAutoFindingFile)
            //{
            //    this.EphemerisService = new IgsEphemerisServiceAutoProvider(DataSourceOption.GetIgsProductSourceOption(CurrentSession)).GetEphemerisService();

            //    if (this.EphemerisService == null || EphemerisService.SatCount == 0) { log.Info("没有匹配上星历文件 " + EphemerisService); }
            //    else
            //    {
            //        log.Info("成功自动匹配星历文件 " + EphemerisService);
            //        return EphemerisService;
            //    }
            //}

            //NGA星历匹配
            if (ProcessOption.IsEnableNgaEphemerisSource && DataSourceOption.EnableAutoFindingFile && Setting.EnableNet)
            {
                Time obsTime       = CurrentSession.TimePeriod.Start;
                Time time          = Time.UtcNow;
                var  span          = (time - obsTime); //与当前的时间差
                var  isWithTwoDays = span < 48 * 3600; //IGS快速星历服务
                                                       //NGA只有预报星历,取消之。应急采用。
                TryAddNgaEphemeris(obsTime, isWithTwoDays);
                if (this.CurrentService == null || CurrentService.SatCount == 0)
                {
                    log.Info("没有匹配上星历文件 " + CurrentService);
                }
                else
                {
                    log.Info("成功自动匹配 NGA 星历文件 " + CurrentService);
                    return(CurrentService);
                }
            }


            //还没有匹配上,寻找导航文件
            if ((CurrentService == null || CurrentService.SatCount == 0))
            {
                ObservationDataSources.TryLoadEphemerisServices();
                if (ObservationDataSources.EphemerisServices.Count > 0)
                {
                    this.CurrentService = ObservationDataSources.EphemerisServices.First;

                    var msg = "最后时刻,采用了一个导航星历。" + this.CurrentService;
                    log.Info(msg);
                }
            }

            if ((CurrentService == null || CurrentService.SatCount == 0))
            {
                this.CurrentService = GlobalIgsEphemerisService.Instance;
                var msg = "星历服务匹配失败!!!,仍然尝试用全局星历!";
                log.Error(msg);
                //     throw new ArgumentException(msg);
            }

            return(this.CurrentService);
        }
Example #23
0
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = int.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            var prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' });
            Dictionary <SatelliteNumber, StreamWriter> prnWriters = new Dictionary <SatelliteNumber, StreamWriter>();


            string[] pathes         = this.textBox_Pathes.Lines;
            string   fileName       = Path.GetFileName(pathes[0]).Substring(0, 3);
            string   firstDayOfWeek = Path.GetFileNameWithoutExtension(pathes[0]).Substring(3, 5);
            string   lastDayOfWeek  = Path.GetFileNameWithoutExtension(pathes[pathes.Length - 1]).Substring(3, 5);
            string   timePeriod     = firstDayOfWeek + "-" + lastDayOfWeek;

            string type = EphemerisDataSourceFactory.GetFileEphemerisTypeFromPath(pathes[0]).ToString();

            foreach (var item in prns)
            {
                var path = Path.Combine(directory, item.ToString() + "-" + fileName + "." + type + timePeriod + ".txt");
                prnWriters[item] = new StreamWriter(new FileStream(path, FileMode.Create));
            }

            Time start = Time.MaxValue;

            foreach (var path in pathes)
            {
                singleColl = EphemerisDataSourceFactory.Create(path);
                Time start0 = singleColl.TimePeriod.Start;
                Time end0   = singleColl.TimePeriod.End + intervalSec;
                if (start < start0)
                {
                    start0 = start;
                }
                foreach (var prn in prns)
                {
                    var writer = prnWriters[prn];

                    var all = singleColl.Gets(prn, start0, end0);
                    if (all == null)
                    {
                        continue;
                    }
                    for (Time i = start0; i < end0; i = i + intervalSec)
                    {
                        var find = all.SingleOrDefault(m => m.Time == i);
                        if (find == null)
                        {
                            if (!fillWithZero)
                            {
                                continue;
                            }

                            find = new Ephemeris()
                            {
                                Time = i, Prn = prn
                            };
                        }
                        writer.WriteLine(find.GetTabValues());
                    }
                }
                start = end0;
            }

            foreach (var item in prnWriters)
            {
                item.Value.Flush();
                item.Value.Close();
            }

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Example #24
0
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = int.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            var prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' });
            Dictionary <SatelliteNumber, StreamWriter> prnWriters            = new Dictionary <SatelliteNumber, StreamWriter>();
            Dictionary <SatelliteNumber, StreamWriter> prnWritersOfPredicted = new Dictionary <SatelliteNumber, StreamWriter>();

            foreach (var item in prns)
            {
                var path            = Path.Combine(directory, item.ToString() + "IGU-O" + ".xls");
                var pathOfPredicted = Path.Combine(directory, item.ToString() + "IGU-P" + ".xls");
                prnWriters[item]            = new StreamWriter(new FileStream(path, FileMode.Create));
                prnWritersOfPredicted[item] = new StreamWriter(new FileStream(pathOfPredicted, FileMode.Create));
            }


            FileEphemerisService coll;

            string[] pathes = this.textBox_Pathes.Lines;
            var      st1    = int.Parse(pathes[0].Substring(pathes[0].Length - 6, 2));
            var      st2    = int.Parse(pathes[1].Substring(pathes[0].Length - 6, 2));

            #region  进行合并,即没有重合部分
            if (st2 - st1 == 0)
            {
                foreach (var pathItem in pathes)
                {
                    coll = EphemerisDataSourceFactory.Create(pathItem);
                    Time end1 = coll.TimePeriod.Start + 24 * 3600 - intervalSec;
                    Time end  = coll.TimePeriod.End;
                    foreach (var prn in prns)
                    {
                        var writer         = prnWriters[prn];
                        var writer1        = prnWritersOfPredicted[prn];
                        var all            = coll.Gets(prn, coll.TimePeriod.Start, end1);
                        var allOfPredicted = coll.Gets(prn, end1 + intervalSec, end);
                        for (Time i = coll.TimePeriod.Start; i <= end1; i = i + intervalSec)
                        {
                            var find = all.SingleOrDefault(m => m.Time == i);
                            if (find == null)
                            {
                                if (!fillWithZero)
                                {
                                    continue;
                                }

                                find = new Ephemeris()
                                {
                                    Time = i, Prn = prn
                                };
                            }
                            writer.WriteLine(find.GetTabValues());
                        }
                        for (Time i = end1 + intervalSec; i <= end; i = i + intervalSec)
                        {
                            var find = allOfPredicted.SingleOrDefault(m => m.Time == i);
                            if (find == null)
                            {
                                if (!fillWithZero)
                                {
                                    continue;
                                }

                                find = new Ephemeris()
                                {
                                    Time = i, Prn = prn
                                };
                            }
                            writer1.WriteLine(find.GetTabValues());
                        }
                    }
                }
            }

            #endregion
            #region 合并,即每个文件选取最新的6小时或12小时、18小时等
            else
            {
                foreach (var pathItem in pathes)
                {
                    coll = EphemerisDataSourceFactory.Create(pathItem);
                    Time end1             = coll.TimePeriod.Start + (st2 - st1) * 3600 - intervalSec;
                    Time end              = coll.TimePeriod.Start + (st2 - st1 + 24) * 3600 - intervalSec;
                    Time startOfPredicted = coll.TimePeriod.Start + 24 * 3600 - intervalSec;
                    foreach (var prn in prns)
                    {
                        var writer         = prnWriters[prn];
                        var writer1        = prnWritersOfPredicted[prn];
                        var all            = coll.Gets(prn, coll.TimePeriod.Start, end1);
                        var allOfPredicted = coll.Gets(prn, startOfPredicted, end);
                        for (Time i = coll.TimePeriod.Start; i <= end1; i = i + intervalSec)
                        {
                            var find = all.SingleOrDefault(m => m.Time == i);
                            if (find == null)
                            {
                                if (!fillWithZero)
                                {
                                    continue;
                                }

                                find = new Ephemeris()
                                {
                                    Time = i, Prn = prn
                                };
                            }
                            writer.WriteLine(find.GetTabValues());
                        }
                        for (Time i = startOfPredicted; i <= end; i = i + intervalSec)
                        {
                            var find = allOfPredicted.SingleOrDefault(m => m.Time == i);
                            if (find == null)
                            {
                                if (!fillWithZero)
                                {
                                    continue;
                                }

                                find = new Ephemeris()
                                {
                                    Time = i, Prn = prn
                                };
                            }
                            writer1.WriteLine(find.GetTabValues());
                        }
                    }
                }
            }
            #endregion
            foreach (var item in prnWriters)
            {
                item.Value.Flush();
                item.Value.Close();
            }
            foreach (var item in prnWritersOfPredicted)
            {
                item.Value.Flush();
                item.Value.Close();
            }

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }