Exemplo n.º 1
0
        /// <summary>
        /// 读取记录体,V3。
        /// </summary>
        /// <param name="sr"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        public static GlonassNavRecord ReadRecordBodyV3(StreamReader sr, GlonassNavRecord record)
        {
            string line = sr.ReadLine();

            line = line.Replace('D', 'E');
            double x   = double.Parse(line.Substring(4, 19));
            double vx  = double.Parse(line.Substring(23, 19));
            double ddx = double.Parse(line.Substring(42, 19));

            record.Health = double.Parse(line.Substring(61, 19));

            line = sr.ReadLine();
            line = line.Replace('D', 'E');
            double y   = double.Parse(line.Substring(4, 19));
            double vy  = double.Parse(line.Substring(23, 19));
            double ddy = double.Parse(line.Substring(42, 19));

            record.FrequencyNumber = double.Parse(line.Substring(61, 19));

            line = sr.ReadLine();
            line = line.Replace('D', 'E');
            double z   = double.Parse(line.Substring(4, 19));
            double vz  = double.Parse(line.Substring(23, 19));
            double ddz = double.Parse(line.Substring(42, 19));

            record.AgeOfOper = double.Parse(line.Substring(61, 19));

            record.XYZ             = new XYZ(x, y, z) * 1000.0;       // km -> m
            record.XyzVelocity     = new XYZ(vx, vy, vz) * 1000.0;    // km -> m
            record.XyzAcceleration = new XYZ(ddx, ddy, ddz) * 1000.0; // km -> m

            return(record);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Glonass星历数据构建
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public static string BuildRinexRecordV4(GlonassNavRecord record)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(record.Prn.ToString());
            sb.Append(" ");
            sb.Append(TimeIoUtil.ToRinexV3String(record.Time));
            sb.Append(DoubleUtil.ScientificFomate(record.ClockBias, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.RelativeFrequencyBias, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.MessageTime, "E19.12", false));
            sb.AppendLine();

            sb.Append("    ");
            sb.Append(DoubleUtil.ScientificFomate(record.XYZ.X / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzVelocity.X / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzAcceleration.X / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.Health, "E19.12", false));
            sb.AppendLine();

            sb.Append("    ");
            sb.Append(DoubleUtil.ScientificFomate(record.XYZ.Y / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzVelocity.Y / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzAcceleration.Y / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.FrequencyNumber / 1000, "E19.12", false));
            sb.AppendLine();

            sb.Append("    ");
            sb.Append(DoubleUtil.ScientificFomate(record.XYZ.Z / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzVelocity.Z / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.XyzAcceleration.Z / 1000, "E19.12", false));
            sb.Append(DoubleUtil.ScientificFomate(record.AgeOfOper, "E19.12", false));
            sb.AppendLine();

            return(sb.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// GNSS导航文件的读取
        /// </summary>
        /// <param name="navFilePath"></param>
        /// <returns></returns>
        public MixedNavFile ReadGnssNavFlie()
        {
            MixedNavFile f = new MixedNavFile();

            f.SetHeader(ParamNavFileReader.ReadHeader(RinexFileName));
            //测试版本
            if (f.Header.Version == 0)
            {
                using (StreamReader sr = new StreamReader(RinexFileName, UnicodeEncoding.UTF8))
                {
                    RinexUtil.SkipHeader(sr);
                }
            }

            using (StreamReader sr = new StreamReader(RinexFileName, UnicodeEncoding.UTF8))
            {
                RinexUtil.SkipHeader(sr);

                if (f.Header.Version < 3.0)
                {
                    while (sr.Peek() != -1)
                    {
                        EphemerisParam record = ParamNavFileReader.ReadRecordV2(sr, f.Header);
                        f.Add(record);
                    }
                }
                else if (f.Header.Version >= 3.0 && f.Header.Version < 4.0)
                {
                    while (sr.Peek() != -1)
                    {
                        string line = sr.ReadLine();
                        if (string.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        SatClockBias recordHeader = ParamNavFileReader.ParseFirstLineV3(line, f.Header);
                        //轨道参数
                        var satType = recordHeader.Prn.SatelliteType;
                        if (EphemerisUtil.IsEphemerisParam(satType))
                        {
                            var record = new EphemerisParam(recordHeader);

                            ParamNavFileReader.ReadRecordBodyV3(sr, record);

                            f.Add(record);
                        }
                        else
                        {
                            var record2 = new GlonassNavRecord(recordHeader);
                            GlonassNaviFileReader.ParseFirstLineV3(line, record2);
                            GlonassNaviFileReader.ReadRecordBodyV3(sr, record2);
                            f.Add(record2);
                        }
                    }
                }
            }

            return(f);
        }
Exemplo n.º 4
0
        /// <summary>
        /// RINEX 3.0 记录读取。
        /// </summary>
        /// <param name="sr">数据流</param>
        /// <param name="header">头部信息</param>
        /// <returns></returns>
        public static GlonassNavRecord ReadRecordV3(StreamReader sr, NavFileHeader header)
        {
            GlonassNavRecord record = new GlonassNavRecord();
            string           line   = sr.ReadLine();

            GlonassNaviFileReader.ParseFirstLineV3(line, record);

            return(ReadRecordBodyV3(sr, record));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 分解第一行。V3
        /// </summary>
        /// <param name="line">行</param>
        /// <param name="header">头部</param>
        /// <param name="record">钟差</param>
        public static void ParseFirstLineV3(string line, GlonassNavRecord record)
        {
            line        = line.Replace('D', 'E');
            record.Prn  = SatelliteNumber.Parse(line.Substring(0, 3));
            record.Time = Time.Parse(line.Substring(4, 19));
            string val = line.Substring(23, 19);

            record.ClockBias             = double.Parse(val);
            record.RelativeFrequencyBias = double.Parse(line.Substring(42, 19));
            record.MessageTime           = double.Parse(line.Substring(61, 19));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 分解第一行。V2
        /// </summary>
        /// <param name="line">行</param>
        /// <param name="header">头部</param>
        /// <param name="record">钟差</param>
        public static void ParseFirstLineV2(string line, NavFileHeader header, GlonassNavRecord record)
        {
            line        = line.Replace('D', 'E');
            record.Prn  = SatelliteNumber.Parse(line.Substring(0, 2), header.SatelliteType);
            record.Time = Time.Parse(line.Substring(2, 20));
            string val = line.Substring(22, 19);

            record.ClockBias             = double.Parse(val);
            record.RelativeFrequencyBias = double.Parse(line.Substring(41, 19));
            record.MessageTime           = double.Parse(line.Substring(60, 19));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 检查,如果该星历步存在,则添加星历参数并返回true。
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public bool CheckAndAppendEphemerisParam(GlonassNavRecord para)
        {
            if (!LatestNavEphDic.ContainsKey(para.Prn) || !LatestNavEphDic[para.Prn].Equals(para.Time))
            {
                LatestNavEphDic[para.Prn] = para.Time;

                AppendEphemerisParam(para);
                return(true);
            }

            log.Debug("缓存星历已存在,略过了 " + para.Prn + ", " + para.Time);
            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 读取GLONASS导航文件
        /// </summary>
        /// <param name="navFilePath">路径</param>
        /// <returns></returns>
        public static GlonassNavFile ReadFileV2V3(string navFilePath)
        {
            GlonassNavFile f = new GlonassNavFile();

            f.Header = ParamNavFileReader.ReadHeader(navFilePath);

            //测试版本
            if (f.Header.Version == 0)
            {
                using (StreamReader sr = new StreamReader(navFilePath, UnicodeEncoding.UTF8))
                {
                    RinexUtil.SkipHeader(sr);
                    try
                    {
                        GlonassNaviFileReader.ReadRecordV2(sr, f.Header);
                        GlonassNaviFileReader.ReadRecordV2(sr, f.Header);
                        //  f.Header.Version = 2.0;
                    }
                    catch
                    {
                        f.Header.Version = 1.0;
                    }
                }
            }

            using (StreamReader sr = new StreamReader(navFilePath, UnicodeEncoding.UTF8))
            {
                RinexUtil.SkipHeader(sr);

                while (sr.Peek() != -1)
                {
                    GlonassNavRecord record = null;
                    if (f.Header.Version < 3)
                    {
                        record = GlonassNaviFileReader.ReadRecordV2(sr, f.Header);
                    }
                    else if (f.Header.Version >= 3)
                    {
                        record = GlonassNaviFileReader.ReadRecordV3(sr, f.Header);
                    }
                    else
                    {
                        throw new ArgumentException(" 导航文件版本 " + f.Header.Version);
                    }
                    f.Add(record);
                }
            }
            return(f);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 读取记录
        /// </summary>
        /// <param name="sr">数据流读取器</param>
        /// <param name="header">头部信息</param>
        /// <returns></returns>
        public static GlonassNavRecord ReadRecordV2(StreamReader sr, NavFileHeader header)
        {
            GlonassNavRecord record = new GlonassNavRecord();
            string           line   = sr.ReadLine();

            GlonassNaviFileReader.ParseFirstLineV2(line, header, record);

            line = sr.ReadLine();
            line = line.Replace('D', 'E');
            double x   = double.Parse(line.Substring(3, 19));
            double vx  = double.Parse(line.Substring(22, 19));
            double vvx = double.Parse(line.Substring(41, 19));

            record.Health = double.Parse(line.Substring(60, 19));

            line = sr.ReadLine();
            line = line.Replace('D', 'E');
            double y   = double.Parse(line.Substring(3, 19));
            double vy  = double.Parse(line.Substring(22, 19));
            double vvy = double.Parse(line.Substring(41, 19));

            record.FrequencyNumber = double.Parse(line.Substring(60, 19));

            line = sr.ReadLine();
            line = line.Replace('D', 'E');
            double z   = double.Parse(line.Substring(3, 19));
            double vz  = double.Parse(line.Substring(22, 19));
            double vvz = double.Parse(line.Substring(41, 19));

            record.FrequencyNumber = double.Parse(line.Substring(60, 19));
            record.AgeOfOper       = double.Parse(line.Substring(60, 19));

            record.XYZ             = new XYZ(x, y, z) * 1000.0;       // km -> m
            record.XyzVelocity     = new XYZ(vx, vy, vz) * 1000.0;    // km -> m
            record.XyzAcceleration = new XYZ(vvx, vvy, vvz) * 1000.0; // km -> m
            return(record);
        }
Exemplo n.º 10
0
 /// <summary>
 /// 添加星历参数
 /// </summary>
 /// <param name="para"></param>
 public void AppendEphemerisParam(GlonassNavRecord para)
 {
     StringBuilder.Append(BuildRinexRecordV4(para));
 }
Exemplo n.º 11
0
 internal void Add(GlonassNavRecord record2)
 {
     this.GlonassNavFile.Add(record2);
 }