示例#1
0
 private void WriteGenerationFile(float totalProduction, float totalAttraction)
 {
     if (!string.IsNullOrEmpty(GenerationOutputFileName))
     {
         bool first = !File.Exists(GenerationOutputFileName);
         // make sure the directory exists
         var dir = Path.GetDirectoryName(GenerationOutputFileName);
         if (!string.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir))
         {
             Directory.CreateDirectory(dir);
         }
         // if the file name exists try to write to it, appending
         using (StreamWriter writer = new StreamWriter(GenerationOutputFileName, true))
         {
             if (first)
             {
                 writer.WriteLine("Age,Employment,Occupation,Mobility,Production,Attraction,WAH");
             }
             writer.Write(AgeCategoryRange.ToString());
             writer.Write(',');
             writer.Write(EmploymentStatusCategory.ToString());
             writer.Write(',');
             writer.Write(OccupationCategory.ToString());
             writer.Write(',');
             writer.Write(Mobility.ToString());
             writer.Write(',');
             writer.Write(totalProduction);
             writer.Write(',');
             writer.Write(totalAttraction);
             writer.Write(',');
             writer.WriteLine(WorkAtHomeTotal);
         }
     }
 }
示例#2
0
 private void WriteGenerationFile(float totalProduction, float totalAttraction)
 {
     if (!String.IsNullOrEmpty(GenerationOutputFileName))
     {
         var           dir  = Path.GetDirectoryName(GenerationOutputFileName);
         DirectoryInfo info = new DirectoryInfo(dir);
         if (!info.Exists)
         {
             info.Create();
         }
         bool first = !File.Exists(GenerationOutputFileName);
         // if the file name exists try to write to it, appending
         using (StreamWriter writer = new StreamWriter(GenerationOutputFileName, true))
         {
             if (first)
             {
                 writer.WriteLine("Age,Employment,Occupation,Production,Attraction,WAH,IntraZonal");
             }
             writer.Write(AgeCategoryRange.ToString());
             writer.Write(',');
             writer.Write(EmploymentStatusCategory.ToString());
             writer.Write(',');
             writer.Write(OccupationCategory.ToString());
             writer.Write(',');
             writer.Write(totalProduction);
             writer.Write(',');
             writer.Write(totalAttraction);
             writer.Write(',');
             writer.Write(WorkAtHomeTotal);
             writer.Write(',');
             writer.WriteLine(WorkIntrazonalTotal);
         }
     }
 }
示例#3
0
 private void SaveGenerationData(float totalProduction)
 {
     if (!String.IsNullOrEmpty(GenerationOutputFileName))
     {
         bool first = !File.Exists(GenerationOutputFileName);
         // if the file name exists try to write to it, appending
         using (StreamWriter writer = new StreamWriter(GenerationOutputFileName, true))
         {
             if (first)
             {
                 writer.WriteLine("Age,Employment,Occupation,Mobility,Total");
             }
             writer.Write(AgeCategoryRange.ToString());
             writer.Write(',');
             writer.Write(EmploymentStatusCategory.ToString());
             writer.Write(',');
             writer.Write(OccupationCategory.ToString());
             writer.Write(',');
             writer.Write(Mobility.ToString());
             writer.Write(',');
             writer.WriteLine(totalProduction);
         }
     }
 }
示例#4
0
        private void WriteAttractionFile(SparseArray <float> attractions)
        {
            if (!AttractionFileName.ContainsFileName())
            {
                return;
            }
            var           flatAttractions = attractions.GetFlatData();
            bool          first           = !File.Exists(AttractionFileName.GetFileName());
            StringBuilder buildInside     = new StringBuilder();

            buildInside.Append(',');
            buildInside.Append(AgeCategoryRange.ToString());
            buildInside.Append(',');
            buildInside.Append(EmploymentStatusCategory.ToString());
            buildInside.Append(',');
            buildInside.Append(OccupationCategory.ToString());
            buildInside.Append(',');
            buildInside.Append(Mobility.ToString());
            buildInside.Append(',');
            string categoryData = buildInside.ToString();

            using (StreamWriter writer = new StreamWriter(AttractionFileName.GetFileName(), true))
            {
                if (first)
                {
                    // if we are the first thing to generate, then write the header as well
                    writer.WriteLine("Zone,Age,Employment,Occupation,Mobility,Attraction");
                }
                for (int i = 0; i < flatAttractions.Length; i++)
                {
                    writer.Write(attractions.GetSparseIndex(i));
                    writer.Write(categoryData);
                    writer.WriteLine(flatAttractions[i]);
                }
            }
        }