/// <summary> /// Loads the data from an emme2 311 file into a ODC /// </summary> /// <param name="emme2File">The emm2 file to read from</param> /// <param name="highestZone">The highest numbered zone</param> /// <param name="times">The ammount of distinct times</param> /// <param name="types">The number of types of variables to store per time period</param> /// <param name="odc">Where to save this data</param> /// <param name="offsetTimes">The time offset to use</param> /// <param name="offsetType">The type offset to use</param> public void LoadEMME2(string emme2File, int offsetTimes, int offsetType) { string line; int pos; var ammountOfData = this.Types * this.Times; // do this because highest zone isn't high enough for array indexes using (StreamReader reader = new StreamReader(new FileStream(emme2File, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.SequentialScan))) { int injectIndex = this.Times * offsetType + offsetTimes; while ((line = reader.ReadLine()) != null) { if (line.Length > 0 && line[0] == 'a') { break; } } while ((line = reader.ReadLine()) != null) { int length = line.Length; // don't read blank lines if (length < 7) { continue; } int o = FastParse.ParseFixedInt(line, 0, 7); pos = 7; while (pos + 8 <= length) { int d = FastParse.ParseFixedInt(line, pos, 7); var data = Data[o, d]; if (data == null) { Data[o, d] = data = new float[ammountOfData]; } if (line[pos + 7] == ':') { data[injectIndex] = FastParse.ParseFixedFloat(line, pos + 8, 5); } else { data[injectIndex] = FastParse.ParseFixedFloat(line, pos + 8, (length > ((pos + 8) + 9) ? 9 : (length - (pos + 8)))); } pos += 13; } } } }
/// <summary> /// Loads the data from an emme2 311 file into a ODC /// </summary> /// <param name="emme2File">The emm2 file to read from</param> /// <param name="highestZone">The highest numbered zone</param> /// <param name="times">The ammount of distinct times</param> /// <param name="types">The number of types of variables to store per time period</param> /// <param name="odc">Where to save this data</param> /// <param name="offsetTimes">The time offset to use</param> /// <param name="offsetType">The type offset to use</param> public void LoadEMME2(string emme2File, int offsetTimes, int offsetType) { string line; int pos; // do this because highest zone isn't high enough for array indexes HighestZone += 1; using (StreamReader reader = new StreamReader(new FileStream(emme2File, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.SequentialScan))) { FilesLoaded.Add(new DimensionInfo(emme2File, offsetType, offsetTimes, true, false, false)); int injectIndex = this.Times * offsetType + offsetTimes; while ((line = reader.ReadLine()) != null) { if (line.Length > 0 && line[0] == 'a') { break; } } while ((line = reader.ReadLine()) != null) { int length = line.Length; // don't read blank lines if (length < 7) { continue; } int o = FastParse.ParseFixedInt(line, 0, 7); if (o > Data.Length) { continue; } if (Data[o] == null) { Data[o] = new float[HighestZone][]; for (int k = HighestZone - 1; k >= 0; k--) { Data[o][k] = new float[AmmountOfData]; } HasData[o] = new bool[HighestZone]; for (int i = 0; i < HighestZone; i++) { HasData[o][i] = false; } } pos = 7; while (pos + 13 <= length) { int d = FastParse.ParseFixedInt(line, pos, 7); if (d < Data.Length) { if (line[pos + 7] == ':') { Data[o][d][injectIndex] = FastParse.ParseFixedFloat(line, pos + 8, 5); } else { Data[o][d][injectIndex] = FastParse.ParseFixedFloat(line, pos + 8, 9); } HasData[o][d] = true; } pos += 13; } } } }