public static void CreateODC(string fileName, string xmlTemplate, string dataDirectory) { XmlSerializer deserializer = new XmlSerializer(typeof(CacheGenerationInfo)); TextReader textReader = new StreamReader(xmlTemplate); CacheGenerationInfo info = (CacheGenerationInfo)deserializer.Deserialize(textReader); textReader.Close(); ODCCreator odcCreator = new ODCCreator(info.HighestZone, info.Types, info.Times, info.Gap); foreach (var dimensionInfo in info.CacheInfo) { string fname = Path.Combine(dataDirectory, dimensionInfo.FileName); if (dimensionInfo.Is311) { odcCreator.LoadEMME2(fname, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } else { if (dimensionInfo.SaveInTimes) { odcCreator.LoadCSVTimes(fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } else { odcCreator.LoadCSVTypes(fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } } } odcCreator.Save(fileName, false); }
public void ReGenerate(string dataDirectory, string outputDirectory) { string fileName = Path.GetFileNameWithoutExtension(this.FileName); string path = Path.GetDirectoryName(this.FileName); string xmlFile = Path.Combine(path, fileName + ".xml"); XmlSerializer deserializer = new XmlSerializer(typeof(CacheGenerationInfo)); TextReader textReader = new StreamReader(xmlFile); CacheGenerationInfo info = (CacheGenerationInfo)deserializer.Deserialize(textReader); textReader.Close(); ODCCreator odcCreator = new ODCCreator(this.HighestZone, this.Types, this.Times, this.Indexes.Length); foreach (var dimensionInfo in info.CacheInfo) { string fname = Path.Combine(dataDirectory, dimensionInfo.FileName); if (dimensionInfo.Is311) { odcCreator.LoadEMME2(fname, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } else { if (dimensionInfo.SaveInTimes) { odcCreator.LoadCSVTimes(fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } else { odcCreator.LoadCSVTypes(fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex); } } } odcCreator.Save(Path.Combine(outputDirectory, Path.GetFileName(this.FileName)), true); }
public void Generate() { /* * TRANSIT * Structure for now will be: * 0: train in vehicle time * 1: train wait time * 2: train walk time * 3: train fare */ ODCCreator creator = new ODCCreator( this.Root.ZoneSystem.ZoneArray.Top + 1, 4, 3, 1 ); creator.LoadEMME2( FailIfNotExist( this.trnivttAM ), 0, 0 ); creator.LoadEMME2( FailIfNotExist( this.fin_trnwaitAM ), 0, 1 ); creator.LoadEMME2( FailIfNotExist( this.trnwalkAM ), 0, 2 ); creator.LoadEMME2( FailIfNotExist( this.trnivttPM ), 1, 0 ); creator.LoadEMME2( FailIfNotExist( this.fin_trnwaitPM ), 1, 1 ); creator.LoadEMME2( FailIfNotExist( this.trnwalkPM ), 1, 2 ); creator.LoadEMME2( FailIfNotExist( this.trnivttOP ), 2, 0 ); creator.LoadEMME2( FailIfNotExist( this.fin_trnwaitOP ), 2, 1 ); creator.LoadEMME2( FailIfNotExist( this.trnwalkOP ), 2, 2 ); if ( !String.IsNullOrWhiteSpace( this.transitfares ) ) { creator.LoadEMME2( FailIfNotExist( this.transitfares ), 0, 3 ); creator.LoadEMME2( FailIfNotExist( this.transitfares ), 1, 3 ); creator.LoadEMME2( FailIfNotExist( this.transitfares ), 2, 3 ); } creator.Save( GetFullPath( this.ODC ), false ); creator = null; GC.Collect(); }
public void ReGenerate(string dataDirectory, string outputDirectory) { string fileName = Path.GetFileNameWithoutExtension( this.FileName ); string path = Path.GetDirectoryName( this.FileName ); string xmlFile = Path.Combine( path, fileName + ".xml" ); XmlSerializer deserializer = new XmlSerializer( typeof( CacheGenerationInfo ) ); TextReader textReader = new StreamReader( xmlFile ); CacheGenerationInfo info = (CacheGenerationInfo)deserializer.Deserialize( textReader ); textReader.Close(); ODCCreator odcCreator = new ODCCreator( this.HighestZone, this.Types, this.Times, this.Indexes.Length ); foreach ( var dimensionInfo in info.CacheInfo ) { string fname = Path.Combine( dataDirectory, dimensionInfo.FileName ); if ( dimensionInfo.Is311 ) { odcCreator.LoadEMME2( fname, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } else { if ( dimensionInfo.SaveInTimes ) { odcCreator.LoadCSVTimes( fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } else { odcCreator.LoadCSVTypes( fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } } } odcCreator.Save( Path.Combine( outputDirectory, Path.GetFileName( this.FileName ) ), true ); }
public static void CreateODC(string fileName, string xmlTemplate, string dataDirectory) { XmlSerializer deserializer = new XmlSerializer( typeof( CacheGenerationInfo ) ); TextReader textReader = new StreamReader( xmlTemplate ); CacheGenerationInfo info = (CacheGenerationInfo)deserializer.Deserialize( textReader ); textReader.Close(); ODCCreator odcCreator = new ODCCreator( info.HighestZone, info.Types, info.Times, info.Gap ); foreach ( var dimensionInfo in info.CacheInfo ) { string fname = Path.Combine( dataDirectory, dimensionInfo.FileName ); if ( dimensionInfo.Is311 ) { odcCreator.LoadEMME2( fname, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } else { if ( dimensionInfo.SaveInTimes ) { odcCreator.LoadCSVTimes( fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } else { odcCreator.LoadCSVTypes( fname, dimensionInfo.Header, dimensionInfo.TimeIndex, dimensionInfo.TypeIndex ); } } } odcCreator.Save( fileName, false ); }