Beispiel #1
0
        /// <summary>
        /// 解析,从观测文件。
        /// </summary>
        /// <param name="oFilePath"></param>
        /// <returns></returns>
        public Dictionary <string, string> ParseFromRinexOFile(string oFilePath)
        {
            RinexObsFileReader reader = new RinexObsFileReader(oFilePath, false);
            var header = reader.GetHeader();

            return(GetParamFromHeader(header));
        }
Beispiel #2
0
        /// <summary>
        /// 执行单个
        /// </summary>
        /// <param name="inputPath"></param>
        protected override void Run(string inputPath)
        {
            if (this.IsCancel)
            {
                return;
            }

            var reader = new RinexObsFileReader(inputPath, false);
            var header = reader.GetHeader();
            var coord  = SiteCoordService.Get(header.MarkerName, header.StartTime);

            if (coord == null)
            {
                FailedCount++;
                ShowInfo("Faild:\t" + inputPath);
                log.Error("坐标获取失败,本文件执行取消。 " + inputPath); return;
            }

            var outPath = Path.Combine(this.OutputDirectory, Path.GetFileName(inputPath));
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic[RinexHeaderLabel.APPROX_POSITION_XYZ] = RinexObsFileWriter.BuildApproxXyzLine(coord.Value);
            var replacer = new LineFileReplacer(inputPath, outPath, dic);

            replacer.EndMarkers.Add(RinexHeaderLabel.END_OF_HEADER);

            replacer.AddingLines.Add(RinexObsFileWriter.BuildGnsserCommentLines());
            replacer.AddingLines.Add(RinexObsFileWriter.BuildCommentLine("Approx XYZ updated with " + SiteCoordService.Name + " " + Geo.Utils.DateTimeUtil.GetFormatedDateTimeNow()));
            replacer.Run();
            log.Info("更新成功! " + coord.Value + ", " + inputPath);

            this.ProgressBar.PerformProcessStep();
        }
        /// <summary>
        /// 将结果更新到RINEX头文件中,将覆盖以往的参数。
        /// </summary>
        /// <param name="existOFilePath"></param>
        /// <param name="newOfilePath"></param>
        public void UpdateToRinexOFileHeader(string existOFilePath, string newOfilePath)
        {
            RinexObsFileReader reader = new RinexObsFileReader(existOFilePath, false);
            var header = reader.GetHeader();
            var remainedComments = FilterParamComments(header.Comments);
            remainedComments.AddRange(this.ToMarkedLines());
            header.Comments = remainedComments;

            RinexObsFileReplacer replacer = new RinexObsFileReplacer(existOFilePath);
            replacer.ReplaceHeader(header, newOfilePath);
        }
        /// <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);
        }
Beispiel #5
0
        protected override void Run(string inputPath)
        {
            RinexObsFileReader reader = new RinexObsFileReader(inputPath, false);
            var header = reader.GetHeader();

            StationInfo info = new StationInfo(header.SiteInfo, header.ObsInfo);

            lock (locker)
            {
                StationInfoWriter.Write(info);
            }

            base.Run(inputPath);
        }
Beispiel #6
0
        private void SetCoordFromObsFile()
        {
            var path = fileOpenControl_extractFromOFile.FilePath;

            RinexObsFileReader reader = new RinexObsFileReader(path, false);
            var header = reader.GetHeader();

            if (header.ApproxXyz != null)
            {
                SetXyz(header.ApproxXyz);
            }
            else
            {
                Geo.Utils.FormUtil.ShowWarningMessageBox("很抱歉,所选文件不包含坐标!");
            }
        }
        /// <summary>
        /// 读取数据
        /// </summary>
        private List <RinexObsFileHeader> ReadFileHeaders(string[] filePathes)
        {
            List <RinexObsFileHeader> headers = new List <RinexObsFileHeader>();

            foreach (var obsPath in filePathes)
            {
                RinexObsFileHeader header = null;
                RinexObsFileReader obsFileReader;
                string             lastChar  = Geo.Utils.StringUtil.GetLastChar(obsPath);
                string             lastChar3 = Geo.Utils.StringUtil.GetLastChar(obsPath, 3);
                string             lastChar5 = Geo.Utils.StringUtil.GetLastChar(obsPath, 5);
                if (String.Equals(lastChar, "o", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar3, "rnx", StringComparison.CurrentCultureIgnoreCase))
                {
                    obsFileReader = new RinexObsFileReader(obsPath);
                    header        = obsFileReader.GetHeader();
                }

                if (String.Equals(lastChar, "z", StringComparison.CurrentCultureIgnoreCase) ||
                    String.Equals(lastChar3, "crx", StringComparison.CurrentCultureIgnoreCase) ||
                    String.Equals(lastChar5, "crx.gz", StringComparison.CurrentCultureIgnoreCase)
                    )
                {
                    Geo.IO.InputFileManager inputFileManager = new Geo.IO.InputFileManager(Setting.TempDirectory);
                    var obsPathes = inputFileManager.GetLocalFilePath(obsPath, "*.*o;*.rnx", "*.*");

                    obsFileReader = new RinexObsFileReader(obsPathes);
                    header        = obsFileReader.GetHeader();
                }
                if (header == null)
                {
                    log.Error("不支持输入文件格式!" + obsPath);
                }
                else
                {
                    headers.Add(header);
                    log.Info("成功读入:" + obsPath);
                }
            }
            return(headers);
        }
        private RinexObsFileHeader ReadOriginalHeader(string inFilePath)
        {
            var reader = new RinexObsFileReader(inFilePath);

            return(reader.GetHeader());//以原头文件为蓝本
        }
Beispiel #9
0
        /// <summary>
        /// 是否符合要求
        /// </summary>
        /// <param name="inpath"></param>
        /// <returns></returns>
        public bool IsMatch(string inpath)
        {
            var fileName = Path.GetFileName(inpath);
            var reader   = new RinexObsFileReader(inpath, false);
            var header   = reader.GetHeader();

            //多路径效应,此处采用TEQC分析
            if (Option.MultipathMp1.Enabled || Option.MultipathMp2.Enabled)
            {
                //{
                //    double Mp1 = double.Parse(result.Substring(result.IndexOf("SUM ") + 63, 4).Replace(" ", ""));
                //    double Mp2 = double.Parse(result.Substring(result.IndexOf("SUM ") + 69, 4).Replace(" ", ""));

                //    if (this.Option.MultipathMp1.Enabled)
                //    {
                //        if (Mp1 > this.Option.MultipathMp1.Value)
                //        {
                //            return false;
                //        }
                //    }
                //    if (this.Option.MultipathMp2.Enabled)
                //    {
                //        if (Mp2 > this.Option.MultipathMp2.Value)
                //        {
                //            return false;
                //        }
                //    }

                //}
            }

            //  ObsAnalysisInfo anaInfo = new ObsAnalysisInfo(header);
            //if (this.Option.MultipathMp1.Enabled && anaInfo.HasMultipathFactor)
            //{
            //    if (anaInfo.MultipathFactors[FrequenceType.A] > this.Option.MultipathMp1.Value)
            //    {
            //        return false;
            //    }
            //}

            //if (this.Option.MultipathMp2.Enabled && anaInfo.HasMultipathFactor)
            //{
            //    if (anaInfo.MultipathFactors[FrequenceType.B] > this.Option.MultipathMp2.Value)
            //    {
            //        return false;
            //    }
            //}


            if (Option.IsEnableSatelliteTypes)
            {
                foreach (var satType in Option.SatelliteTypes)
                {
                    if (!header.SatelliteTypes.Contains(satType))
                    {
                        log.Info(fileName + " 不包含系统 " + satType);
                        return(false);
                    }
                }
            }


            if (Option.IsEnableObsCodes)
            {
                var codes = header.ObsCodes;
                foreach (var item in Option.ObsCodes)
                {
                    foreach (var list in codes.Values)
                    {
                        if (!list.Contains(item))
                        {
                            log.Info(fileName + " 不包含 " + item);
                            return(false);
                        }
                    }
                }
            }

            if (Option.IsEnableMinFrequencyCount)
            {
                var codes = header.ObsCodes;

                foreach (var item in codes)
                {
                    var count = MathedCount(item.Value, "L");
                    if (count < Option.MinFrequencyCount)
                    {
                        log.Info(fileName + " 伪距数量少于 " + Option.MinFrequencyCount);
                        return(false);
                    }

                    count = MathedCount(item.Value, new string[] { "C", "P" });
                    if (count < Option.MinFrequencyCount)
                    {
                        log.Info(fileName + " 载波数量少于 " + Option.MinFrequencyCount);
                        return(false);
                    }
                }
            }


            if (Option.IsEnableMinFileSizeMB)
            {
                FileInfo info    = new FileInfo(inpath);
                var      minByte = Option.MinFileSizeMB * 1024L * 1024L;
                if (info.Length < minByte)
                {
                    log.Info(fileName + " 文件小于 " + Option.MinFileSizeMB + " MB");
                    return(false);
                }
            }


            if (Option.IsEnableCenterRegion)
            {
                if (!Option.CenterRegion.Contains(header.ApproxXyz))
                {
                    log.Info(fileName + "  " + header.ApproxXyz + " 不在指定区域内 " + Option.CenterRegion);
                    return(false);
                }
            }

            if (Option.IsEnableExcludeSiteNames)
            {
                if (Option.ExcludeSiteNames.Contains(header.SiteName))
                {
                    log.Info(fileName + " 点名被排除了");
                    return(false);
                }
            }

            if (Option.IsEnableIncludeSiteNames)
            {
                if (!Option.IncludeSiteNames.Contains(header.SiteName))
                {
                    log.Info(fileName + " 点名被排除了");
                    return(false);
                }
            }
            if (Option.IsEnableTimePeriod)
            {
                if (!Option.TimePeriod.Contains(header.StartTime))
                {
                    log.Info(fileName + " 不在指定时段内 " + Option.TimePeriod);
                    return(false);
                }
            }
            //这个比较耗时,放在最后
            if (Option.IsEnableMinEpochCount)
            {
                var count = RinexObsFileReader.ReadGetEpochCount(inpath);
                if (count < Option.MinEpochCount)
                {
                    log.Info(fileName + " 历元数量 " + count + "  少于 " + Option.MinEpochCount);
                    return(false);
                }
            }

            if (Option.IsEnableMinRatioOfSatCount)
            {
                var ratio = RinexObsFileReader.GetRatioOfSatCount(inpath, Option.MinSatCount);
                if (ratio < Option.MinRatioOfSatCount)
                {
                    log.Info(fileName + " 最小卫星数量比率 " + ratio);
                    return(false);
                }
            }

            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// 是否符合要求
        /// </summary>
        /// <param name="inpath"></param>
        /// <returns></returns>
        public bool IsMatch(string inpath)
        {
            var fileName = Path.GetFileName(inpath);
            var reader   = new RinexObsFileReader(inpath, false);
            var header   = reader.GetHeader();

            //多路径效应,此处采用TEQC分析
            if (Option.MultipathMp1.Enabled || Option.MultipathMp2.Enabled)
            {
                #region 利用TEQC分析获取数据多路径值
                var TeqcPath = Setting.GnsserConfig.TeqcPath;
                Gnsser.Interoperation.Teqc.TeqcFunctionCaller call = new Gnsser.Interoperation.Teqc.TeqcFunctionCaller(TeqcPath, Gnsser.Interoperation.Teqc.TeqcFunction.QualityChecking);
                string result = call.Run(inpath)[0];
                //当后台cmd输出流不正常时,说明该测站O文件QC失败!
                if (!result.Contains("SUM ") || ((result.Contains("SUM ")) && result.Substring(result.IndexOf("SUM ") + 63, 4).Replace(" ", "") == "n/a"))
                {
                    //QC失败,还得靠自己算!
                }
                else
                {
                    double Mp1 = double.Parse(result.Substring(result.IndexOf("SUM ") + 63, 4).Replace(" ", ""));
                    double Mp2 = double.Parse(result.Substring(result.IndexOf("SUM ") + 69, 4).Replace(" ", ""));

                    if (this.Option.MultipathMp1.Enabled)
                    {
                        if (Mp1 > this.Option.MultipathMp1.Value)
                        {
                            return(false);
                        }
                    }
                    if (this.Option.MultipathMp2.Enabled)
                    {
                        if (Mp2 > this.Option.MultipathMp2.Value)
                        {
                            return(false);
                        }
                    }
                }

                #endregion
            }

            ObsAnalysisInfo anaInfo = new ObsAnalysisInfo(header);
            //if (this.Option.MultipathMp1.Enabled && anaInfo.HasMultipathFactor)
            //{
            //    if (anaInfo.MultipathFactors[FrequenceType.A] > this.Option.MultipathMp1.Value)
            //    {
            //        return false;
            //    }
            //}

            //if (this.Option.MultipathMp2.Enabled && anaInfo.HasMultipathFactor)
            //{
            //    if (anaInfo.MultipathFactors[FrequenceType.B] > this.Option.MultipathMp2.Value)
            //    {
            //        return false;
            //    }
            //}


            if (Option.IsEnableSatelliteTypes)
            {
                foreach (var satType in Option.SatelliteTypes)
                {
                    if (!header.SatelliteTypes.Contains(satType))
                    {
                        log.Info(fileName + " 不包含系统 " + satType);
                        return(false);
                    }
                }
            }


            if (Option.IsEnableObsCodes)
            {
                var codes = header.ObsCodes;
                foreach (var item in Option.ObsCodes)
                {
                    foreach (var list in codes.Values)
                    {
                        if (!list.Contains(item))
                        {
                            log.Info(fileName + " 不包含 " + item);
                            return(false);
                        }
                    }
                }
            }

            if (Option.IsEnableMinFrequencyCount)
            {
                var codes = header.ObsCodes;

                foreach (var item in codes)
                {
                    var count = MathedCount(item.Value, "L");
                    if (count < Option.MinFrequencyCount)
                    {
                        log.Info(fileName + " 伪距数量少于 " + Option.MinFrequencyCount);
                        return(false);
                    }

                    count = MathedCount(item.Value, new string[] { "C", "P" });
                    if (count < Option.MinFrequencyCount)
                    {
                        log.Info(fileName + " 载波数量少于 " + Option.MinFrequencyCount);
                        return(false);
                    }
                }
            }


            if (Option.IsEnableMinFileSizeMB)
            {
                FileInfo info    = new FileInfo(inpath);
                var      minByte = Option.MinFileSizeMB * 1024L * 1024L;
                if (info.Length < minByte)
                {
                    log.Info(fileName + " 文件小于 " + Option.MinFileSizeMB + " MB");
                    return(false);
                }
            }


            if (Option.IsEnableCenterRegion)
            {
                if (!Option.CenterRegion.Contains(header.ApproxXyz))
                {
                    log.Info(fileName + "  " + header.ApproxXyz + " 不在指定区域内 " + Option.CenterRegion);
                    return(false);
                }
            }

            if (Option.IsEnableExcludeSiteNames)
            {
                if (Option.ExcludeSiteNames.Contains(header.SiteName))
                {
                    log.Info(fileName + " 点名被排除了");
                    return(false);
                }
            }

            if (Option.IsEnableIncludeSiteNames)
            {
                if (!Option.IncludeSiteNames.Contains(header.SiteName))
                {
                    log.Info(fileName + " 点名被排除了");
                    return(false);
                }
            }
            if (Option.IsEnableTimePeriod)
            {
                if (!Option.TimePeriod.Contains(header.StartTime))
                {
                    log.Info(fileName + " 不在指定时段内 " + Option.TimePeriod);
                    return(false);
                }
            }
            //这个比较耗时,放在最后
            if (Option.IsEnableMinEpochCount)
            {
                var count = RinexObsFileReader.ReadGetEpochCount(inpath);
                if (count < Option.MinEpochCount)
                {
                    log.Info(fileName + " 历元数量 " + count + "  少于 " + Option.MinEpochCount);
                    return(false);
                }
            }

            if (Option.IsEnableMinRatioOfSatCount)
            {
                var ratio = RinexObsFileReader.GetRatioOfSatCount(inpath, Option.MinSatCount);
                if (ratio < Option.MinRatioOfSatCount)
                {
                    log.Info(fileName + " 最小卫星数量比率 " + ratio);
                    return(false);
                }
            }

            return(true);
        }