Ejemplo n.º 1
0
        private static void BuildCoordInfoText(RinexObsFileHeader header, StringBuilder sb)
        {
            if (header.ApproxXyz != null)
            {
                var xyz = header.ApproxXyz;
                var rinexApproxXyzLine = BuildApproxXyzLine(xyz);

                sb.AppendLine(rinexApproxXyzLine);
            }
            if (header.Hen != null)
            {
                sb.AppendLine(StringUtil.FillSpace(
                                  StringUtil.FillSpaceLeft(header.Hen.H.ToString("0.0000"), 14) +
                                  StringUtil.FillSpaceLeft(header.Hen.E.ToString("0.0000"), 14) +
                                  StringUtil.FillSpaceLeft(header.Hen.N.ToString("0.0000"), 14), 60
                                  ) + RinexHeaderLabel.ANTENNA_DELTA_H_E_N);
            }
            if (header.AntDeltaXyz != null)
            {
                sb.AppendLine(StringUtil.FillSpace(
                                  StringUtil.FillSpaceLeft(header.AntDeltaXyz.X.ToString("0.0000"), 14) +
                                  StringUtil.FillSpaceLeft(header.AntDeltaXyz.Y.ToString("0.0000"), 14) +
                                  StringUtil.FillSpaceLeft(header.AntDeltaXyz.Z.ToString("0.0000"), 14), 60
                                  ) + RinexHeaderLabel.ANTENNA_DELTA_XYZ);
            }
        }
Ejemplo n.º 2
0
        public void ReplaceHeader(RinexObsFileHeader header, string outPath)
        {
            using (StreamWriter writer = new StreamWriter(outPath))
            {
                var headerStr = RinexObsFileWriter.ObsHeaderToRinexString(header, header.Version);

                writer.WriteLine(headerStr);
                using (StreamReader reader = new StreamReader(FilePath))
                {
                    string line      = null;
                    bool   isContent = false;
                    while (((line = reader.ReadLine()) != null))
                    {
                        if (line.Contains(RinexHeaderLabel.END_OF_HEADER))
                        {
                            isContent = true;
                            continue;
                        }

                        if (isContent)
                        {
                            writer.WriteLine(line);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void BuildDateTimeInfo(RinexObsFileHeader header, StringBuilder sb)
        {
            sb.AppendLine(
                StringUtil.FillSpace(
                    StringUtil.FillSpaceLeft(header.StartTime.Year.ToString(), 6) +
                    StringUtil.FillSpaceLeft(header.StartTime.Month.ToString(), 6) +
                    StringUtil.FillSpaceLeft(header.StartTime.Day.ToString(), 6) +
                    StringUtil.FillSpaceLeft(header.StartTime.Hour.ToString(), 6) +
                    StringUtil.FillSpaceLeft(header.StartTime.Minute.ToString(), 6) +
                    StringUtil.FillSpaceLeft(header.StartTime.Seconds.ToString("0.0000000"), 13) +
                    StringUtil.FillSpaceLeft(header.TimeSystem, 8),
                    60) + RinexHeaderLabel.TIME_OF_FIRST_OBS);

            if (header.EndTime > header.StartTime && header.EndTime != Time.Default && header.EndTime != Time.MaxValue && header.EndTime != Time.MinValue)
            {
                sb.AppendLine(
                    StringUtil.FillSpace(
                        StringUtil.FillSpaceLeft(header.EndTime.Year.ToString(), 6) +
                        StringUtil.FillSpaceLeft(header.EndTime.Month.ToString(), 6) +
                        StringUtil.FillSpaceLeft(header.EndTime.Day.ToString(), 6) +
                        StringUtil.FillSpaceLeft(header.EndTime.Hour.ToString(), 6) +
                        StringUtil.FillSpaceLeft(header.EndTime.Minute.ToString(), 6) +
                        StringUtil.FillSpaceLeft(header.EndTime.Seconds.ToString("0.0000000"), 13) +
                        StringUtil.FillSpaceLeft(header.TimeSystem, 8),
                        60) + RinexHeaderLabel.TIME_OF_LAST_OBS);
            }
            sb.AppendLine(StringUtil.FillSpace(StringUtil.FillSpaceLeft(header.LeapSeconds, 6), 60) + RinexHeaderLabel.LEAP_SECONDS);
        }
Ejemplo n.º 4
0
 private static void BuildHeaderLine(RinexObsFileHeader header, double version, StringBuilder sb)
 {
     // HeaderLabel.RINEX_VERSION_TYPE:
     sb.Append(StringUtil.FillSpace(StringUtil.FillSpaceLeft(version, 9), 20));
     sb.Append(StringUtil.FillSpace("OBSERVATION DATA", 20));
     sb.Append(StringUtil.FillSpace(header.GetSatTypeMarker().ToString(), 20));
     sb.AppendLine(RinexHeaderLabel.RINEX_VERSION_TYPE);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 写头部文件
        /// </summary>
        /// <param name="header"></param>
        public void WriteHeader(RinexObsFileHeader header)
        {
            if (header == null)
            {
                return;
            }
            this.Header = header;
            var str = ObsHeaderToRinexString(header, Version);

            this.Writer.Write(str);
        }
Ejemplo n.º 6
0
        private static void BuildSystemPhaseShiftText(RinexObsFileHeader header, StringBuilder sb)
        {
            var sameTypePrns = header.GetCodeSatTypedPrns();

            foreach (var typeKv in sameTypePrns)
            {
                foreach (var prnKv in typeKv.Value)
                {
                    var satType  = typeKv.Key;
                    int satCount = prnKv.Value.Count;
                    var code     = prnKv.Key;
                    var val      = header.GetSystemPhaseShift(prnKv.Value[0], code);

                    StringBuilder ssb = new StringBuilder();
                    ssb.Append(satType);
                    ssb.Append(" ");
                    ssb.Append(code);
                    ssb.Append(" ");
                    var valStr = StringUtil.FillSpaceLeft(val.ToString("0.00000"), 8);
                    ssb.Append(valStr);
                    ssb.Append(" ");
                    var satCountStr = StringUtil.FillSpaceLeft(satCount, 3);
                    ssb.Append(satCountStr);
                    int i = -1;
                    foreach (var prn in prnKv.Value)
                    {
                        i++;
                        if (i % 10 == 0 && i != 0)
                        {
                            var line = StringUtil.FillSpace(ssb.ToString(), 60) + RinexHeaderLabel.SYS_PHASE_SHIFT;
                            sb.AppendLine(line);
                            ssb.Clear();

                            ssb.Append(StringUtil.FillSpaceLeft(0, 18));
                        }

                        ssb.Append(" ");
                        ssb.Append(prn);
                    }
                    if (ssb.Length > 0)
                    {
                        var line = StringUtil.FillSpace(ssb.ToString(), 60) + RinexHeaderLabel.SYS_PHASE_SHIFT;
                        sb.AppendLine(line);
                        ssb.Clear();

                        ssb.Append(StringUtil.FillSpaceLeft(0, 18));
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 重写头部信息
        /// </summary>
        /// <param name="header"></param>
        public void ReWriteHeader(RinexObsFileHeader header)
        {
            this.Dispose();
            //读取
            RinexObsFile obsFile = null;

            using (RinexObsFileReader reader = new RinexObsFileReader(this.FilePath))
            {
                obsFile         = reader.ReadObsFile();
                header.ObsCodes = obsFile.Header.ObsCodes;
                obsFile.Header  = header;
            }
            //重写
            this.Writer = new StreamWriter(FilePath, false, Encoding.ASCII);
            this.Write(obsFile);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取 RINEX2.0 形式的观测码文本行。多系统情况下还需要解决。!!2015.10.28
        /// </summary>
        /// <param name="header"></param>
        /// <param name="sb"></param>
        private static void BuildObsCodeLineRinexV2(RinexObsFileHeader header, StringBuilder sb)
        {
            List <string> obsTypes    = header.GetObsCodesV2();// new List<string>();
            int           allSatCount = obsTypes.Count;
            ////每一类型卫星遍历
            //foreach (var satType in header.SatelliteTypes)
            //{
            //    var types = header.GetOrInitObsCodes(satType);
            //    obsTypes.AddRange(types);
            //    allSatCount += types.Count;
            //}
            //第一行
            StringBuilder lineSb = new StringBuilder();

            lineSb.Append(StringUtil.FillSpaceRight("", 3));              //3个空格
            lineSb.Append(StringUtil.FillSpaceLeft(allSatCount + "", 3)); //3 个字符

            //一行最多13个
            int i = 0;

            foreach (var valType in obsTypes)
            {
                //此处还需要做转换
                var val = valType;
                if (val.Length == 3)
                {
                    val = val.Substring(0, 2);
                }
                lineSb.Append(StringUtil.FillSpaceLeft(val, 6));


                if (i % 8 == 0 && i != 0) //换行
                {
                    sb.AppendLine(StringUtil.FillSpaceRight(lineSb.ToString(), 60) + RinexHeaderLabel.TYPES_OF_OBSERV);
                    lineSb.Clear();
                    lineSb.Append(StringUtil.FillSpaceLeft("", 6));
                }
                i++;
            }

            if (lineSb.Length != 0)
            {
                sb.AppendLine(StringUtil.FillSpaceRight(lineSb.ToString(), 60) + RinexHeaderLabel.TYPES_OF_OBSERV);
                lineSb.Clear();
            }
        }
Ejemplo n.º 9
0
        private static void BuildReceiverAntennaInfoText(RinexObsFileHeader header, StringBuilder sb)
        {
            //HeaderLabel.MARKER_NAME:
            sb.AppendLine(StringUtil.FillSpace(header.SiteInfo.SiteName, 60) + RinexHeaderLabel.MARKER_NAME);
            sb.AppendLine(StringUtil.FillSpace(header.SiteInfo.MarkerNumber, 60) + RinexHeaderLabel.MARKER_NUMBER);
            if (header.MarkerType != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.MarkerType, 60) + RinexHeaderLabel.MARKER_TYPE);
            }
            sb.AppendLine(StringUtil.FillSpace(header.ObsInfo.ObserverAgence, 60) + RinexHeaderLabel.OBSERVER_AGENCY);
            sb.Append(StringUtil.FillSpace(header.SiteInfo.ReceiverNumber, 20));
            sb.Append(StringUtil.FillSpace(header.SiteInfo.ReceiverType, 20));
            sb.AppendLine(StringUtil.FillSpace(header.SiteInfo.ReceiverVersion, 20) + RinexHeaderLabel.REC_NUM_TYPE_VERS);

            sb.Append(StringUtil.FillSpace(header.SiteInfo.AntennaNumber, 20));
            sb.AppendLine(StringUtil.FillSpace(header.SiteInfo.AntennaType, 40) + RinexHeaderLabel.ANT_NUM_TYPE);
        }
Ejemplo n.º 10
0
        public string Build(RinexObsFileHeader header)
        {
            this.StationName = header.MarkerName;

            this.TimeResolution = TimeUnit.Hour;
            this.RinexFileType  = Rinex.RinexFileType.O;
            ContryCode          = header.CountryCode;
            DataSource          = "R";
            Period        = GetPeriodCode(header.TimePeriod.TimeSpan);
            Interval      = header.Interval.ToString("00") + "S";
            ContentType   = header.SatTypeMarker + "O";
            FileFormat    = "rnx";
            Compression   = "crx";
            IsCompression = false;

            return(Build(header.StartTime));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 具体的执行.
        /// </summary>
        /// <param name="fileInPath"></param>
        /// <param name="fileOutPath"></param>
        protected override void Execute(string fileInPath, string fileOutPath)
        {
            Gnsser.Data.Rinex.RinexObsFileReader reader = new Data.Rinex.RinexObsFileReader(fileInPath);
            var oldHeader = reader.GetHeader();
            var processer = new SatCycleSlipAnalyst(new List <SatelliteType>()
            {
                SatelliteType.G
            }, oldHeader.Interval);

            //写入到流
            EpochInfoToRinex EpochInfoToRinex = new Domain.EpochInfoToRinex(this.CurrentParam.OutputVersion, false);

            Gnsser.Data.Rinex.RinexObsFileWriter writer    = new Data.Rinex.RinexObsFileWriter(fileOutPath, this.CurrentParam.OutputVersion);
            Gnsser.Data.Rinex.RinexObsFileHeader newHeader = null;
            int maxBufferEpoch = 200;
            int i = 0;

            foreach (var item in reader)
            {
                //标记
                var obs = Domain.EpochInformation.Parse(item, item.Header.SatelliteTypes);
                processer.Revise(ref obs);

                //写入文件
                var epochObs = EpochInfoToRinex.Build(obs);
                if (newHeader == null)
                {
                    newHeader = epochObs.Header;
                    writer.WriteHeader(newHeader);
                }
                writer.WriteEpochObservation(EpochInfoToRinex.Build(obs));

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

            processer.SatSequentialPeriod.SaveSatPeriodText(fileOutPath + "_CycleSlip.txt");
            File.WriteAllText(fileOutPath + "__cycleSlipPeriod.txt", processer.SatSequentialPeriod.ToFormatedString(), Encoding.UTF8);
        }
Ejemplo n.º 12
0
        private static void BuildGlonassCodePhaseBiasText(RinexObsFileHeader header, StringBuilder sb)
        {
            int    length = header.GlonassCodePhaseBias.Count;
            string line   = "";
            int    i      = 0;

            foreach (var kv in header.GlonassCodePhaseBias)
            {
                if (i % 4 == 0 && i != 0)
                {
                    sb.AppendLine(StringUtil.FillSpace(line, 60) + RinexHeaderLabel.GLONASS_COD_PHS_BIS);
                    line = "";
                }
                line += " " + kv.Key + " " + Geo.Utils.StringUtil.FillSpaceLeft(kv.Value.ToString("0.000"), 8);
                i++;
            }
            if (line.Length > 1) //最后检查一次
            {
                sb.AppendLine(StringUtil.FillSpace(line, 60) + RinexHeaderLabel.GLONASS_COD_PHS_BIS);
            }
        }
Ejemplo n.º 13
0
        private static void BuildGlonassSlotFreqNumsText(RinexObsFileHeader header, StringBuilder sb)
        {
            int    length = header.GlonassSlotFreqNums.Count;
            string line   = Geo.Utils.StringUtil.FillSpaceLeft(length + "", 3) + " ";
            int    i      = 0;

            foreach (var kv in header.GlonassSlotFreqNums)
            {
                if (i % 8 == 0 && i != 0)
                {
                    sb.AppendLine(StringUtil.FillSpace(line, 60) + RinexHeaderLabel.GLONASS_SLOT_FRQ);
                    line = "    ";
                }
                line += kv.Key + " " + Geo.Utils.StringUtil.FillSpaceLeft(kv.Value, 2) + " ";//3 + 1 + 2 + 1
                i++;
            }
            if (line.Length > 4)//最后检查一次
            {
                sb.AppendLine(StringUtil.FillSpace(line, 60) + RinexHeaderLabel.GLONASS_SLOT_FRQ);
            }
        }
Ejemplo n.º 14
0
        private static void BuildObsCodeLineRinexV3(RinexObsFileHeader header, StringBuilder sb)
        {
            //每一类型卫星遍历
            foreach (var satType in header.SatelliteTypes)
            {
                //第一行
                var           types  = header.GetOrInitObsCodes(satType);
                StringBuilder lineSb = new StringBuilder();
                lineSb.Append(StringUtil.FillSpaceRight(satType.ToString(), 3));
                var count = types.Count;
                lineSb.Append(StringUtil.FillSpaceLeft(count + "", 3));
                double lineCount = Math.Ceiling(count / 13.0d);
                //一行最多13个
                int i = 0;
                foreach (var valType in types)
                {
                    //此处还需要做转换
                    var val = new ObservationCode(valType).GetRinexCode(3);
                    lineSb.Append(StringUtil.FillSpaceLeft(val, 4));

                    i++;

                    if (i % 13 == 0 && i != 0)
                    {
                        sb.AppendLine(StringUtil.FillSpaceRight(lineSb.ToString(), 60) + RinexHeaderLabel.SYS_OBS_TYPES);
                        lineSb.Clear();
                        lineSb.Append(StringUtil.FillSpaceLeft("", 6));
                    }
                }
                if (lineSb.Length != 0)
                {
                    sb.AppendLine(StringUtil.FillSpaceRight(lineSb.ToString(), 60) + RinexHeaderLabel.SYS_OBS_TYPES);
                    lineSb.Clear();
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        ///  RINEX文件的头文件。
        /// </summary>
        /// <param name="header">头部文件</param>
        /// <param name="version">版本</param>
        /// <returns></returns>
        public static string ObsHeaderToRinexString(RinexObsFileHeader header, double version)
        {
            StringBuilder sb = new StringBuilder();

            BuildHeaderLine(header, version, sb);
            // return "";

            // HeaderLabel.PGM_RUN_BY_DATE:
            BuildProgramRunByDateLine(sb);

            // HeaderLabel.COMMENT:
            sb.AppendLine(BuildGnsserCommentLines());

            foreach (var item in header.Comments)
            {
                if (item.Contains("Gnsser"))
                {
                    continue;
                }                                          //不重复写Gnsser信息。
                if (String.IsNullOrWhiteSpace(item))
                {
                    continue;
                }
                sb.AppendLine(StringUtil.FillSpace(item, 60) + RinexHeaderLabel.COMMENT);
            }

            BuildReceiverAntennaInfoText(header, sb);

            BuildCoordInfoText(header, sb);

            if (version >= 3)
            {
                BuildObsCodeLineRinexV3(header, sb);
            }
            else
            {
                BuildObsCodeLineRinexV2(header, sb);
            }

            sb.AppendLine(StringUtil.FillSpace(
                              StringUtil.FillSpaceLeft(header.Interval.ToString("0.000"), 10),
                              60) + RinexHeaderLabel.INTERVAL);

            BuildDateTimeInfo(header, sb);

            //SYS / PHASE SHIFT
            if (header.SystemPhaseShift != null && header.SystemPhaseShift.Count > 0)
            {
                BuildSystemPhaseShiftText(header, sb);
            }

            //RINEX 3.3
            if (header.GlonassSlotFreqNums != null && header.GlonassSlotFreqNums.Count > 0)
            {
                BuildGlonassSlotFreqNumsText(header, sb);
            }

            //GLONASS_COD_PHS_BIS
            // C1C    0.000 C1P    0.000 C2C    0.000 C2P    0.000        GLONASS COD/PHS/BIS
            if (header.GlonassCodePhaseBias != null && header.GlonassCodePhaseBias.Count > 0)
            {
                BuildGlonassCodePhaseBiasText(header, sb);
            }
            //end header
            sb.AppendLine(StringUtil.FillSpace("", 60) + RinexHeaderLabel.END_OF_HEADER);
            return(sb.ToString());
        }
Ejemplo n.º 16
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());
            }
        }