/// <summary> /// to RINEX String,自动采用观测文件内容更新时间。 /// </summary> /// <param name="obsFile"></param> /// <param name="minIntervalSeconds">最小采样率</param> public string GetRinexString(RinexObsFile obsFile, double version, int minIntervalSeconds = 0) { if (obsFile == null || obsFile.Count == 0) { return(""); } this.Header = obsFile.Header; obsFile.Header.StartTime = obsFile[0].ReceiverTime; if (obsFile.Count > 1) { obsFile.Header.EndTime = obsFile[obsFile.Count - 1].ReceiverTime; obsFile.Header.Interval = (obsFile[1].ReceiverTime - obsFile[0].ReceiverTime); } StringBuilder sb = new StringBuilder(); sb.Append(ObsHeaderToRinexString(obsFile.Header, version)); //更新采样率 if (obsFile.Header.Interval < minIntervalSeconds) { obsFile.Header.Interval = minIntervalSeconds; } RinexEpochObservation prevEpochObs = null; int i = 0; foreach (var item in obsFile.ToArray()) { if (item.Count == 0) { continue; } if (prevEpochObs == null) { prevEpochObs = item; } //第一次 var differ = item.ReceiverTime - prevEpochObs.ReceiverTime; if (differ >= minIntervalSeconds || i == 0) { if (version >= 3) { sb.Append(GetRecordStringV3(item)); } else { sb.Append(GetRecordStringV2(item)); } prevEpochObs = item;//roll } i++; } return(sb.ToString()); }
public string Build(RinexObsFile file) { var header = file.Header; file.UpdateAndGetHeaderTimePeriodWithContentTime(); file.CheckOrUpdateAndGetHeaderIntervalWithContent(); file.Header.TrySetAndGetContryCodeWithFileName(); return(Build(header)); }
/// <summary> /// 写入文件 /// </summary> /// <param name="obsFile"></param> /// <param name="path"></param> /// <param name="verion"></param> /// <param name="minInterval"></param> public static void Write(RinexObsFile obsFile, string path, double verion = -1, int minInterval = 1) { if (verion < 2) { verion = obsFile.Header.Version; } using (RinexObsFileWriter writer = new RinexObsFileWriter(path, verion)) { writer.Write(obsFile, minInterval); } }
/// <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); }
/// <summary> /// 追加 /// </summary> /// <param name="recs"></param> public void Add(RinexObsFile recs) { this.Header.EndTime = recs.EndTime; Add(recs._data); }
/// <summary> /// 写文件 /// </summary> /// <param name="Writer"></param> /// <param name="obsFile"></param> /// <param name="version"></param> /// <param name="minIntervalSeconds"></param> public void Write(StreamWriter Writer, RinexObsFile obsFile, double version, int minIntervalSeconds = 0) { string rinex = GetRinexString(obsFile, version, minIntervalSeconds); Writer.Write(rinex); }
/// <summary> /// 写入到指定的文件路径 /// </summary> /// <param name="obsFile"></param> /// <param name="minIntervalSeconds"></param> public void Write(RinexObsFile obsFile, int minIntervalSeconds = 0) { Write(Writer, obsFile, obsFile.Header.Version, minIntervalSeconds); }