// ReSharper disable once InconsistentNaming public void TestCSVODC() { try { int[] zones = new[] { 0, 1, 2, 3, 4, 5, 6 }; SparseArray <int> referenceArray = new SparseArray <int>(new SparseIndexing() { Indexes = new[] { new SparseSet() { Start = 0, Stop = 6 } } }); float[][][] allData = new float[1][][]; var data = CreateData(zones.Length); CreateCSVFile(zones, data, "Test.csv"); allData[0] = data; var writer = new OdMatrixWriter <int>(referenceArray, 1, 1); writer.LoadCsvTimes("Test.csv", false, 0, 0); writer.Save("Test.odc", false); var odcFloatData = ConvertData(allData, zones.Length, 1, 1); ValidateData(zones, odcFloatData, "Test.odc"); } finally { File.Delete("Test.csv"); File.Delete("Test.odc"); } }
public void TestMultiTimeTypes311ODC() { int times = 3, types = 2; float[][][] allData = new float[times * types][][]; try { int[] zones = new[] { 0, 1, 2, 3, 4, 5, 6 }; SparseArray <int> referenceArray = new SparseArray <int>(new SparseIndexing() { Indexes = new[] { new SparseSet() { Start = 0, Stop = 6 } } }); for (int i = 0; i < allData.Length; i++) { var data = CreateData(zones.Length); Create311File(zones, data, "Test" + i + ".311"); allData[i] = data; } var writer = new OdMatrixWriter <int>(referenceArray, times, types); for (int i = 0; i < types; i++) { for (int j = 0; j < times; j++) { writer.LoadEmme2("Test" + (i * times + j) + ".311", i, j); } } writer.Save("Test.odc", false); var odcFloatData = ConvertData(allData, zones.Length, times, types); ValidateData(zones, odcFloatData, "Test.odc"); } finally { for (int i = 0; i < allData.Length; i++) { File.Delete("Test" + i + ".311"); } File.Delete("Test.odc"); } }
private void Generate(string cacheFile) { // create the data if it doesn't already exist OdMatrixWriter <IZone> creator = new OdMatrixWriter <IZone>(Root.ZoneSystem.ZoneArray, 2, 1) { Year = Year, AdditionalDescription = "Automatically Generated", StartTimesHeader = "ALLDAY", EndTimesHeader = "ALLDAY", TypeHeader = "TravelTime,Cost", Modes = "Auto" }; LoadTimes(creator, AlreadyLoaded ? UpdatedTravelTimeData : BaseTravelTimeData, 0); LoadCosts(creator, AlreadyLoaded ? UpdatedCostData : BaseTravelCostData, 0); creator.Save(cacheFile, false); GC.Collect(); }
private void Generate(string cacheFile) { // create the data if it doesn't already exist OdMatrixWriter <IZone> creator = new OdMatrixWriter <IZone>(Root.ZoneSystem.ZoneArray, 2, 3) { Year = Year, AdditionalDescription = "Automatically Generated", StartTimesHeader = "6:00,15:30,Other", EndTimesHeader = "9:00AM,18:30,Other", TypeHeader = "TravelTime,Cost", Modes = "Auto" }; LoadTimes(creator, AlreadyLoaded ? UpdatedAMTravelTimeData : BaseAMTravelTimeData, 0); LoadTimes(creator, AlreadyLoaded ? UpdatedPMTravelTimeData : BasePMTravelTimeData, 1); LoadTimes(creator, AlreadyLoaded ? UpdatedOffpeakTravelTimeData : BaseOffpeakTravelTimeData, 2); LoadCosts(creator, AlreadyLoaded ? UpdatedAMCostData : BaseAMTravelCostData, 0); LoadCosts(creator, AlreadyLoaded ? UpdatedPMCostData : BasePMTravelCostData, 1); LoadCosts(creator, AlreadyLoaded ? UpdatedOffpeakCostData : BaseOffpeakTravelCostData, 2); creator.Save(cacheFile, false); GC.Collect(); }