/// <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); }
/// <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); }