Example #1
0
        private static void ExportRankedWeights(TextWriter writer, int key, IPersisterReader <IZone> zoneReader, IEnumerable <WeightSegmentItem> segmentItems)
        {
            foreach (WeightSegmentItem segmentItem in segmentItems)
            {
                IZone zone = zoneReader.Seek(segmentItem.Id);

                writer.Write(key);
                writer.Write("\t");

                writer.Write(zone.Key);
                writer.Write("\t");

                writer.Write(segmentItem.Value.ToString("f7"));
                writer.WriteLine();
            }
        }
Example #2
0
        private static void RunExport(string path)
        {
            string directory = Path.GetDirectoryName(path);

            if (directory == null)
            {
                return;
            }

            string filename     = Path.GetFileNameWithoutExtension(path);
            string extension    = Path.GetExtension(path);
            int    segmentCount = Global.SegmentZones.GetLength(0);

            IPersisterReader <IZone> zoneReader =
                Global
                .ContainerDaySim.GetInstance <IPersistenceFactory <IZone> >()
                .Reader;

            for (int segment = 0; segment < segmentCount; segment++)
            {
                FileInfo file = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}{2}", filename, segment, extension)));

                using (StreamWriter writer = new StreamWriter(file.Open(FileMode.Create, FileAccess.Write, FileShare.Read))) {
                    SegmentZone[] segmentZones = Global.SegmentZones[segment];
                    int           zoneCount    = segmentZones.GetLength(0);

                    FileInfo     sizesFile   = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}.sizes{2}", filename, segment, extension)));
                    StreamWriter sizesWriter = new StreamWriter(sizesFile.Open(FileMode.Create, FileAccess.Write, FileShare.Read));

                    FileInfo     weightsFile   = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}.weights{2}", filename, segment, extension)));
                    StreamWriter weightsWriter = new StreamWriter(weightsFile.Open(FileMode.Create, FileAccess.Write, FileShare.Read));

                    for (int zoneId = 0; zoneId < zoneCount; zoneId++)
                    {
                        SegmentZone segmentZone = segmentZones[zoneId];

                        if (segmentZone == null)
                        {
                            continue;
                        }

                        IZone zone = zoneReader.Seek(zoneId);

                        writer.Write(zone.Key);
                        writer.Write("\t");
                        writer.Write(segmentZone.TotalSize.ToString("f7"));
                        writer.Write("\t");
                        writer.Write(segmentZone.TotalWeight.ToString("f7"));
                        writer.WriteLine();

                        ExportRankedSizes(sizesWriter, zone.Key, segmentZone.RankedSizes);
                        ExportRankedWeights(weightsWriter, zone.Key, zoneReader, segmentZone.RankedWeights);

                        sizesWriter.Flush();
                        weightsWriter.Flush();
                    }

                    sizesWriter.Dispose();
                    weightsWriter.Dispose();
                }

                Global.PrintFile.WriteFileInfo(file, true);
            }
        }
Example #3
0
 private IEnumerable <IHouseholdDay> LoadHouseholdDaysFromFile()
 {
     return
         (_householdDayReader
          .Seek(Id, "household_fk"));
 }
 private IEnumerable <IPartialHalfTour> LoadPartialHalfToursFromFile()
 {
     return
         (_partialHalfTourReader
          .Seek(Id, "household_day_fk"));
 }
Example #5
0
 private IEnumerable <IPerson> LoadPersonsFromFile()
 {
     return
         (_personReader
          .Seek(Id, "household_fk"));
 }
 private IEnumerable <IFullHalfTour> LoadFullHalfToursFromFile()
 {
     return
         (_fullHalfTourReader
          .Seek(Id, "household_day_fk"));
 }
 private IEnumerable <IJointTour> LoadJointToursFromFile()
 {
     return
         (_jointTourReader
          .Seek(Id, "household_day_fk"));
 }
 private IEnumerable <IPersonDay> LoadPersonDaysFromFile()
 {
     return
         (_personDayReader
          .Seek(Id, "household_day_fk"));
 }
Example #9
0
 private IEnumerable <ITour> LoadToursFromFile()
 {
     return
         (_tourReader
          .Seek(_personDay.Id, "person_day_fk"));
 }
Example #10
0
 private IEnumerable <ITrip> LoadTripsFromFile()
 {
     return
         (_tripReader
          .Seek(_t._tour.Id, "tour_fk"));
 }