/// <summary> /// 读取 /// </summary> /// <returns></returns> public ObjectTableStorage Read() { using (StreamReader reader = new StreamReader(Stream, this.Encoding)) { //记录第一次出现的数据类型,后续依此转换 var name = Path.GetFileNameWithoutExtension(FilePath); ObjectTableStorage storage = new ObjectTableStorage(name); string [] titles = null; var line = ""; int index = -1; while ((line = reader.ReadLine()) != null) { if (String.IsNullOrWhiteSpace(line)) { continue; } index++; if (index == 0)//tittle { titles = line.Split(Spliters, StringSplitOptions); ColTypes.InitNames(titles); continue; } var vals = line.Split(Spliters, StringSplitOptions);//, StringSplitOptions.RemoveEmptyEntries); storage.NewRow(); int length = Math.Min(titles.Length, vals.Length); for (int i = 0; i < length; i++) { var title = titles[i].Trim(); var type = ColTypes[title]; var val = vals[i]; object newVal = null; if (!Appeared.Contains(i)) { type.ValueType = ValueTypeHelper.GetValueType(val); Appeared.Add(i); } if (type.ValueType == ValueType.Unknown) { type.ValueType = ValueTypeHelper.GetValueType(val); } newVal = type.GetValue(val); if (newVal != null)//更新类型 { // type.ValueType = ValueTypeHelper.GetValueType(currentVal); storage.AddItem(title, newVal); } } //storage.AddItem(titles, vals); storage.EndRow(); } return(storage); } }
/// <summary> /// 通过缓存,按照系统类型,转换为表格,以便统计。 /// </summary> /// <returns></returns> private Dictionary <SatelliteType, ObjectTableStorage> BuildObsCodeTables(Dictionary <SatelliteType, List <string> > ObsCodes) { var SatelliteTypes = ObsCodes.Keys; var buffer = this.BufferedStream.MaterialBuffers; var tables = new Dictionary <SatelliteType, ObjectTableStorage>(); foreach (var epoch in buffer) { foreach (var sat in epoch) { var satType = sat.Prn.SatelliteType; //如果已经过滤则不考虑了 if (!SatelliteTypes.Contains(satType)) { continue; } if (!tables.ContainsKey(satType)) { tables.Add(satType, new ObjectTableStorage()); } ObjectTableStorage table = tables[satType]; table.NewRow(); var types = ObsCodes[satType]; foreach (var obsType in sat.ObsTypes) { if (!types.Contains(obsType)) { continue; } table.AddItem(obsType.ToString(), sat.TryGetValue(obsType)); } table.EndRow(); } } return(tables); }