Beispiel #1
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);
        }
Beispiel #2
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));
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }