/// <summary> /// 合并 /// </summary> /// <param name="textA"></param> /// <param name="textB"></param> /// <param name="berFileType"></param> /// <returns></returns> public static IBerFile Merge(string textA, string textB, BerFileType berFileType) { IBerFile a = null, b = null; switch (berFileType) { case BerFileType.ABB: a = AbbFile.ParseText(textA); b = AbbFile.ParseText(textB); break; case BerFileType.STA: a = StaFile.ParseText(textA); b = StaFile.ParseText(textB); break; case BerFileType.CRD: a = CrdFile.ParseText(textA); b = CrdFile.ParseText(textB); break; case BerFileType.VEL: a = VelFile.ParseText(textA); b = VelFile.ParseText(textB); break; default: break; } return(Merge(a, b, berFileType)); }
/// <summary> /// 创建 /// </summary> /// <param name="oDir"></param> /// <param name="berFileType"></param> /// <returns></returns> public static IBerFile Create(string oDir, BerFileType berFileType) { IBerFile o = null; switch (berFileType) { case BerFileType.ABB: o = AbbFile.CreateFromODir(oDir); break; case BerFileType.STA: o = StaFile.CreateFromODir(oDir); break; case BerFileType.CRD: o = CrdFile.CreateFromODir(oDir); break; case BerFileType.VEL: o = VelFile.CreateFromODir(oDir); break; default: break; } return(o); }
/// <summary> /// 合并 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="berFileType"></param> /// <returns></returns> public static IBerFile Merge(IBerFile a, IBerFile b, BerFileType berFileType) { IBerFile o = null; switch (berFileType) { case BerFileType.ABB: o = AbbFile.Merger(a as AbbFile, b as AbbFile); break; case BerFileType.STA: o = StaFile.Merger(a as StaFile, b as StaFile); break; case BerFileType.CRD: o = CrdFile.Merger(a as CrdFile, b as CrdFile); break; case BerFileType.VEL: o = VelFile.Merger(a as VelFile, b as VelFile); break; default: break; } return(o); }
/// <summary> /// 合并两个 STA 文件。 /// </summary> /// <param name="one"></param> /// <param name="another"></param> /// <returns></returns> public static StaFile Merger(StaFile one, StaFile another) { StaFile newOne = new StaFile(); newOne.Name = "Mergered"; newOne.Items = new List <StaInfoItem>(); newOne.Items.AddRange(one.Items); foreach (var item in another.Items) { newOne.Add(item); } return(newOne); }
/// <summary> /// 解析字符串。 /// </summary> /// <param name="txt"></param> /// <returns></returns> public static StaFile ParseText(string txt) { //String[] lines = txt.Split(new char[] { '\r', '\north' }, // StringSplitOptions.RemoveEmptyEntries); StaFile file = new StaFile(); file.Items = new List <StaInfoItem>(); using (StreamReader r = new StreamReader(new MemoryStream(ASCIIEncoding.ASCII.GetBytes(txt)))) { string line = null; while ((line = r.ReadLine()) != null) { // //TYPE 002: STATION INFORMATION //----------------------------- // //STATION NAME FLG FROM TO RECEIVER TYPE ANTENNA TYPE REC # ANT # NORTH EAST UP DESCRIPTION REMARK //**************** *** YYYY MM DD HH MM SS YYYY MM DD HH MM SS ******************** ******************** ****** ****** ***.**** ***.**** ***.**** ********************** ************************ //AIRA 21742S001 001 //............. //ZWEN 12330M001 001 1980 01 06 00 00 00 2099 12 31 00 00 00 AOA SNR-8000 ACT AOAD/M_T 279 342 0.0000 0.0000 0.0460 From ZWEN1430.02O // // //TYPE 003: HANDLING OF STATION PROBLEMS if (line.Contains("TYPE 002: STATION INFORMATION")) { line = r.ReadLine(); line = r.ReadLine(); line = r.ReadLine(); line = r.ReadLine(); while ((line = r.ReadLine()) != null) { if (line.Trim() == "" || line.Contains("TYPE 003")) { break; } StaInfoItem item = StaInfoItem.ParseLine(line); file.Items.Add(item); } break; } } } return(file); }
/// <summary> /// 从 包含 O 文件的文件夹中读取、解析,并创建 StaFile 对象。 /// </summary> /// <param name="oDir"></param> /// <returns></returns> public static StaFile CreateFromODir(string oDir) { StaFile file = new StaFile(); file.Items = new List <StaInfoItem>(); string[] files = Directory.GetFiles(oDir, Setting.RinexOFileFilter); foreach (var path in files) { Data.Rinex.RinexObsFileHeader h = new Data.Rinex.RinexObsFileReader(path).GetHeader(); string name = h.MarkerName.Length > 4 ? h.MarkerName.Substring(0, 4).ToUpper() : h.MarkerName.ToUpper(); //是否已经添加同名测站 if (file.Items.Find(m => m.MakerName == name) != null) { continue; } StaInfoItem sta = new StaInfoItem(name, h.SiteInfo, path); file.Items.Add(sta); } return(file); }