Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void ReGenerate(string dataDirectory, string outputDirectory)
        {
            string fileName = Path.GetFileNameWithoutExtension(FileName);

            string path = Path.GetDirectoryName(FileName);

            if (path == null)
            {
                throw new IOException($"Unable to find the Directory name of {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(HighestZone, Types, Times, 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);
                    }
                }
            }
            var localFileName = Path.GetFileName(FileName);

            if (localFileName == null)
            {
                throw new IOException($"Unable to get the file name of {FileName}!");
            }
            odcCreator.Save(Path.Combine(outputDirectory, localFileName), true);
        }
Exemplo n.º 3
0
 internal void DumpToCreator(OdcCreator odcCreator)
 {
     foreach (var originBlock in Indexes)
     {
         for (int o = originBlock.Start; o < originBlock.End; o++)
         {
             foreach (var destinationBlock in originBlock.SubIndexes)
             {
                 for (int d = destinationBlock.Start; d < destinationBlock.End; d++)
                 {
                     odcCreator.Set(o, d, this);
                 }
             }
         }
     }
 }