/// <summary> /// 读取数据 /// </summary> public static Data.Rinex.RinexObsFile ReadFile(string ObsPath) { Data.Rinex.RinexObsFile ObsFile = null; string lastChar = Geo.Utils.StringUtil.GetLastChar(ObsPath); string lastChar3 = Geo.Utils.StringUtil.GetLastChar(ObsPath, 3); string lastChar5 = Geo.Utils.StringUtil.GetLastChar(ObsPath, 5); if (String.Equals(lastChar, "o", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar3, "rnx", StringComparison.CurrentCultureIgnoreCase)) { var obsFileReader = new RinexObsFileReader(ObsPath); ObsFile = obsFileReader.ReadObsFile(); } if (String.Equals(lastChar, "z", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar3, "crx", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar5, "crx.gz", StringComparison.CurrentCultureIgnoreCase) ) { Geo.IO.InputFileManager inputFileManager = new Geo.IO.InputFileManager(Setting.TempDirectory); ObsPath = inputFileManager.GetLocalFilePath(ObsPath, "*.*o;*.rnx", "*.*"); var obsFileReader = new RinexObsFileReader(ObsPath); ObsFile = obsFileReader.ReadObsFile(); } if (String.Equals(lastChar, "s", StringComparison.CurrentCultureIgnoreCase)) { ObsFile = new TableObsFileReader(ObsPath).Read(); } if (ObsFile == null) { throw new Exception("不支持输入文件格式!"); return(ObsFile); } return(ObsFile); }
/// <summary> /// 读取数据 /// </summary> private void ReadFile() { string lastChar = Geo.Utils.StringUtil.GetLastChar(ObsPath); string lastChar3 = Geo.Utils.StringUtil.GetLastChar(ObsPath, 3); string lastChar5 = Geo.Utils.StringUtil.GetLastChar(ObsPath, 5); if (String.Equals(lastChar, "o", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar3, "rnx", StringComparison.CurrentCultureIgnoreCase)) { obsFileReader = new RinexObsFileReader(ObsPath); ObsFile = obsFileReader.ReadObsFile(); } if (String.Equals(lastChar, "z", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar3, "crx", StringComparison.CurrentCultureIgnoreCase) || String.Equals(lastChar5, "crx.gz", StringComparison.CurrentCultureIgnoreCase) ) { Geo.IO.InputFileManager inputFileManager = new Geo.IO.InputFileManager(Setting.TempDirectory); this.ObsPath = inputFileManager.GetLocalFilePath(ObsPath, "*.*o;*.rnx", "*.*"); obsFileReader = new RinexObsFileReader(ObsPath); ObsFile = obsFileReader.ReadObsFile(); } if (String.Equals(lastChar, "s", StringComparison.CurrentCultureIgnoreCase)) { ObsFile = new TableObsFileReader(ObsPath).Read(); } if (ObsFile == null) { Geo.Utils.FormUtil.ShowWarningMessageBox("不支持输入文件格式!"); return; } this.bindingSource_obsInfo.DataSource = ObsFile; var prns = ObsFile.GetPrns(); prns.Sort(); this.bindingSource_sat.DataSource = prns; this.attributeBox1.DataGridView.DataSource = Geo.Utils.ObjectUtil.GetAttributes(ObsFile.Header, false); string msg = ""; msg += "首次观测时间:" + ObsFile.Header.StartTime + "\r\n"; msg += "最后观测时间:" + ObsFile.Header.EndTime + "\r\n"; msg += "采样间隔:" + ObsFile.Header.Interval + " 秒" + "\r\n"; this.textBox_show.Text = msg; }
protected override void Run(string inputPath) { TableObsFileReader reader = new TableObsFileReader(inputPath); var ObsFile = new TableObsFileReader(inputPath).Read(); var outPath = Path.Combine(this.OutputDirectory, Path.GetFileName(inputPath).Replace(FileNames.TextExcelFileExtension, "")); var Writer = new RinexObsFileWriter(outPath, namedFloatControl1Vertion.Value); Writer.WriteHeader(ObsFile.Header); foreach (var item in ObsFile) { Writer.WriteEpochObservation(item); } Writer.Dispose(); base.Run(inputPath); }