示例#1
0
void LinkSum::Write_Group (void)
{
	int i, j, nrec, group, index;
	String buffer, base;
	double factor;
	Units_Type units;

	Doubles vmt, vht;
	Int_Set *set_ptr;
	Int_Set_Itr itr;
	Int_Map_Itr map_itr;

	Show_Message (String ("Writing %s -- Record") % group_file.File_Type ());
	Set_Progress ();

	if (Metric_Flag ()) {
		factor = 1.0 / 1000.0;
		base = "K";
		units = KILOMETERS;
	} else {
		factor = 1.0 / MILETOFEET;
		base = "M";
		units = MILES;
	}

	//---- set the data fields and file header ----

	group_file.Add_Field ("GROUP", DB_INTEGER, 10);

	for (i=0; i < num_inc; i++) {
		buffer = base + sum_periods.Range_Label (i);

		group_file.Add_Field (buffer, DB_DOUBLE, 16.2, units);

		buffer [0] = 'H';

		group_file.Add_Field (buffer, DB_DOUBLE, 16.2, HOURS);
	}
	group_file.Write_Header ();

	//---- process each group ----

	nrec = 0;

	for (group=1; group <= zone_equiv.Num_Groups (); group++) {
		Show_Progress ();

		set_ptr = zone_equiv.Group_List (group);
		if (set_ptr == 0) continue;

		vmt.assign (num_inc, 0.0);
		vht.assign (num_inc, 0.0);

		//---- process each zone in the group ----

		for (itr = set_ptr->begin (); itr != set_ptr->end (); itr++) {
			map_itr = zone_list.find (*itr);
			if (map_itr == zone_list.end ()) continue;

			index = map_itr->second;

			for (i=0; i < num_inc; i++) {
				vmt [i] += zone_vmt [i] [index];
				vht [i] += zone_vht [i] [index];
			}
		}

		//---- save the group data ----

		group_file.Put_Field (0, group);

		for (i=0, j=1; i < num_inc; i++) {
			group_file.Put_Field (j++, UnRound (vmt [i] * factor));
			group_file.Put_Field (j++, vht [i] / 3600.0);
		}
		if (!group_file.Write ()) {
			Error (String ("Writing %s") % group_file.File_Type ());
		}
		nrec++;
	}
	End_Progress ();

	Print (2, "Number of Group Travel Records = ") << nrec;
}
示例#2
0
void LinkSum::Perf_Detail_Report (void)
{
	int i, j, k, k1, lanes, max_lanes, tod_list, index, flow_index;
	double base_time, loaded_time, length, len, base, diff, value, percent, flow, factor;
	Dtime low, high, tod;
	bool connect_flag;
	String units, vmt, lane_mi;

	Link_Itr link_itr;
	Dir_Data *dir_ptr;
	Link_Perf_Period_Itr period_itr;
	Link_Perf_Array *period_ptr;
	Link_Perf_Data perf_data;
	Flow_Time_Period_Itr turn_itr;
	Flow_Time_Array *compare_ptr;
	Flow_Time_Data *turn_ptr;
	Lane_Use_Period *use_ptr;
	Connect_Data *connect_ptr;
	Doubles_Itr itr;

	Show_Message ("Creating the Network Performance Details Report -- Record");
	Set_Progress ();

	//---- clear the summary bins -----

	for (j=0, itr = sum_bin.begin (); itr != sum_bin.end (); itr++, j++) {
		itr->assign (NUM_SUM_BINS, 0.0);
	}	
	connect_flag = System_Data_Flag (CONNECTION) && (turn_perf_array.size () > 0) && (compare_turn_array.size () > 0);

	//---- process each link ----

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		Show_Progress ();

		if (select_flag && link_itr->Use () == 0) continue;

		length = UnRound (link_itr->Length ());
		len = 0;

		for (i=0; i < 2; i++) {
			if (i) {
				if (link_itr->Use () == -1) continue;
				index = link_itr->BA_Dir ();
			} else {
				if (link_itr->Use () == -2) continue;
				index = link_itr->AB_Dir ();
			}
			if (index < 0) continue;
			dir_ptr = &dir_array [index];
			flow_index = dir_ptr->Flow_Index ();

			base_time = dir_ptr->Time0 ();
			if (base_time <= 0.0) continue;

			tod_list = dir_ptr->First_Lane_Use ();

			max_lanes = dir_ptr->Lanes ();
			if (max_lanes < 1) max_lanes = 1;
			lanes = max_lanes;

			if (len == 0) {
				len = length;
			} else {
				len = 0;
			}

			//---- process each time period ----

			for (j=0, period_itr = link_perf_array.begin (); period_itr != link_perf_array.end (); period_itr++, j++) {
				if (tod_list >= 0) {

					//---- get the time period ----

					sum_periods.Period_Range (j, low, high);
					tod = (low + high + 1) / 2;

					lanes = max_lanes;
					k = tod_list;

					for (use_ptr = &use_period_array [k]; ; use_ptr = &use_period_array [++k]) {
						if (use_ptr->Start () <= tod && tod < use_ptr->End ()) {
							lanes = use_ptr->Lanes0 () + use_ptr->Lanes1 ();
							break;
						}
						if (use_ptr->Periods () == 0) break;
					}
				}
				perf_data = period_itr->Total_Link_Perf (index, flow_index);

				loaded_time = perf_data.Time ();
				flow = perf_data.Flow ();

				sum_bin [j] [LINKS] += 1;
				sum_bin [j] [LENGTH] += len;
				sum_bin [j] [LANES] += lanes * length;
				sum_bin [j] [VMT] += flow * length;
				sum_bin [j] [VHT] += flow * loaded_time;
				sum_bin [j] [VHD] += flow * (loaded_time - base_time);
				sum_bin [j] [TIME_RATIO] += (double) loaded_time / base_time;
				sum_bin [j] [DENSITY] += perf_data.Density ();
				sum_bin [j] [MAX_DEN] = MAX (sum_bin [j] [MAX_DEN], perf_data.Max_Density ());
				sum_bin [j] [QUEUE] += perf_data.Queue ();
				sum_bin [j] [MAX_QUEUE] = MAX (sum_bin [j] [MAX_QUEUE], perf_data.Max_Queue ());
				sum_bin [j] [FAILURE] += perf_data.Failure ();

				if (Ratio_Flag ()) {
					sum_bin [j] [CONG_VMT] += perf_data.Ratio_VMT ();
					sum_bin [j] [CONG_VHT] += perf_data.Ratio_VHT ();
					sum_bin [j] [CONG_TIME] += perf_data.Ratio_Count ();
					sum_bin [j] [COUNT] += perf_data.Occupancy ();
				}

				if (compare_flag) {
					period_ptr = &compare_link_array [j];
					perf_data = period_ptr->Total_Link_Perf (index, flow_index);

					loaded_time = perf_data.Time ();
					flow = perf_data.Flow ();

					sum_bin [j] [VMT+PREV] += flow * length;
					sum_bin [j] [VHT+PREV] += flow * loaded_time;
					sum_bin [j] [VHD+PREV] += flow * (loaded_time - base_time);
					sum_bin [j] [TIME_RATIO+PREV] += (double) loaded_time / base_time;
					sum_bin [j] [DENSITY+PREV] += perf_data.Density ();
					sum_bin [j] [MAX_DEN+PREV] = MAX (sum_bin [j] [MAX_DEN+PREV], perf_data.Max_Density ());
					sum_bin [j] [QUEUE+PREV] += perf_data.Queue ();
					sum_bin [j] [MAX_QUEUE+PREV] = MAX (sum_bin [j] [MAX_QUEUE+PREV], perf_data.Max_Queue ());
					sum_bin [j] [FAILURE+PREV] += perf_data.Failure ();

					if (Ratio_Flag ()) {
						sum_bin [j] [CONG_VMT+PREV] += perf_data.Ratio_VMT ();
						sum_bin [j] [CONG_VHT+PREV] += perf_data.Ratio_VHT ();
						sum_bin [j] [CONG_TIME+PREV] += perf_data.Ratio_Count ();
						sum_bin [j] [COUNT+PREV] += perf_data.Occupancy ();
					}
				}
			}

			//---- get the turning movements ----

			if (connect_flag) {
				for (k=dir_ptr->First_Connect (); k >= 0; k = connect_ptr->Next_Index ()) {
					connect_ptr = &connect_array [k];

					if (connect_ptr->Type () != LEFT && connect_ptr->Type () != RIGHT &&
						connect_ptr->Type () != UTURN) continue;

					for (j=0, turn_itr = turn_perf_array.begin (); turn_itr != turn_perf_array.end (); turn_itr++, j++) {
						turn_ptr = &turn_itr->at (k);

						sum_bin [j] [TURNS] += turn_ptr->Flow ();

						if (compare_flag) {
							compare_ptr = &compare_turn_array [j];
							turn_ptr = &compare_ptr->at (k);

							sum_bin [j] [TURNS+PREV] += turn_ptr->Flow ();
						}
					}
				}
			}
		}
	}
	End_Progress ();

	//---- print the report ----

	Header_Number (PERF_DETAIL);

	if (!Break_Check (num_inc * 16)) {
		Print (1);
		Perf_Detail_Header ();
	}
	if (Metric_Flag ()) {
		factor = 1.0 / 1000.0;
		units = "Kilometers";
		vmt = "VKT";
		lane_mi = "km";
	} else {
		factor = 1.0 / MILETOFEET;
		units = "Miles";
		vmt = "VMT";
		lane_mi = "mi";
	}
	tod.Hours (1);

	for (i=0; i <= num_inc; i++) {
		len = sum_bin [i] [LINKS];
		if (len == 0.0) continue;

		if (i < num_inc) {
			for (k = 0; k <= COUNT; k++) {
				k1 = k + PREV;
				if (k < VMT) {
					sum_bin [num_inc] [k] = MAX (sum_bin [i] [k], sum_bin [num_inc] [k]);

					if (compare_flag) {
						sum_bin [num_inc] [k1] = MAX (sum_bin [i] [k1], sum_bin [num_inc] [k1]);
					}
				} else {
					sum_bin [num_inc] [k] += sum_bin [i] [k];

					if (compare_flag) {
						sum_bin [num_inc] [k1] += sum_bin [i] [k1];
					}
				}
			}
		}
		if (i < num_inc && sum_bin [i] [VHT] == 0.0 && (!compare_flag || sum_bin [i] [VHT+PREV] == 0.0)) continue;
		if (i) {
			if (!Break_Check ((Ratio_Flag () ? 19 : 16))) {
				Print (1);
			}
		}
		Print (1, String ("Time Period%22c") % BLANK);
		if (i == num_inc) {
			Print (0, "       Total");
			len *= num_inc;
		} else {
			Print (0, String ("%12.12s") % sum_periods.Range_Format (i));
		}
		Print (1, String ("Number of Links                 %13.2lf") % sum_bin [i] [LINKS]);
		Print (1, String ("Number of Roadway %-10.10s    %13.2lf") % units % (sum_bin [i] [LENGTH] * factor));
		Print (1, String ("Number of Lane %-10.10s       %13.2lf") % units % (sum_bin [i] [LANES] * factor));
		Print (1, String ("Vehicle %-20.20s    %13.2lf") % (units + " of Travel") % (sum_bin [i] [VMT] * factor));
		if (compare_flag) {
			base = sum_bin [i] [VMT+PREV] * factor;
			diff = sum_bin [i] [VMT] * factor - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Vehicle Hours of Travel         %13.2lf") % (sum_bin [i] [VHT] / tod));
		if (compare_flag) {
			base = sum_bin [i] [VHT+PREV] / tod;
			diff = sum_bin [i] [VHT] / tod - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}	
		Print (1, String ("Vehicle Hours of Delay          %13.2lf") % (sum_bin [i] [VHD] / tod));
		if (compare_flag) {
			base = sum_bin [i] [VHD+PREV] / tod;
			diff = sum_bin [i] [VHD] / tod - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Queued Vehicles       %13.2lf") % UnRound (sum_bin [i] [QUEUE]));
		if (compare_flag) {
			base = sum_bin [i] [QUEUE+PREV];
			diff = sum_bin [i] [QUEUE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Maximum Queued Vehicles         %13.2lf") % sum_bin [i] [MAX_QUEUE]);
		if (compare_flag) {
			base = sum_bin [i] [MAX_QUEUE+PREV];
			diff = sum_bin [i] [MAX_QUEUE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Cycle Failures        %13.2lf") % sum_bin [i] [FAILURE]);
		if (compare_flag) {
			base = sum_bin [i] [FAILURE+PREV];
			diff = sum_bin [i] [FAILURE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Turning Movements     %13.2lf") % sum_bin [i] [TURNS]);
		if (compare_flag) {
			base = sum_bin [i] [TURNS+PREV];
			diff = sum_bin [i] [TURNS] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Average Link Time Ratio         %13.2lf") % (sum_bin [i] [TIME_RATIO] / len));
		if (compare_flag) {
			base = sum_bin [i] [TIME_RATIO+PREV] / len;
			diff = sum_bin [i] [TIME_RATIO] / len - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Average Link Density (/ln-%s)   %13.2lf") % lane_mi % UnRound (sum_bin [i] [DENSITY] / len));
		if (compare_flag) {
			base = UnRound (sum_bin [i] [DENSITY+PREV] / len);
			diff = UnRound (sum_bin [i] [DENSITY] / len) - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Maximum Link Density (/ln-%s)   %13.2lf") % lane_mi % UnRound (sum_bin [i] [MAX_DEN]));
		if (compare_flag) {
			base = UnRound (sum_bin [i] [MAX_DEN+PREV]);
			diff = UnRound (sum_bin [i] [MAX_DEN]) - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		length = sum_bin [i] [VMT] * factor;
		loaded_time = sum_bin [i] [VHT] / tod;
		if (loaded_time == 0.0) {
			loaded_time = length;
		} else {
			loaded_time = length / loaded_time;
		}
		Print (1, String ("Average %-19.19s     %13.2lf") % (units + " per Hour") % loaded_time);
		if (compare_flag) {
			length = sum_bin [i] [VMT+PREV] * factor;
			base = sum_bin [i] [VHT+PREV] / tod;
			if (base == 0.0) {
				base = length;
			} else {
				base = length / base;
			}
			diff = loaded_time - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}

		if (Ratio_Flag ()) {
			value = sum_bin [i] [VMT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_VMT] / value;

			Print (1, String ("Percent %s Congested           %13.2lf") % vmt % percent);
			if (compare_flag) {
				value = sum_bin [i] [VMT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_VMT+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
			value = sum_bin [i] [VHT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_VHT] / value;

			Print (1, String ("Percent VHT Congested           %13.2lf") % percent);
			if (compare_flag) {
				value = sum_bin [i] [VHT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_VHT+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
			value = sum_bin [i] [COUNT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_TIME] / value;

			Print (1, String ("Percent Time Congested          %13.2lf") % percent);
			if (compare_flag) {
				value = sum_bin [i] [COUNT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_TIME+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
		}
	}
	Header_Number (0);
}
示例#3
0
bool Data_Service::Get_Lane_Use_Data (Lane_Use_File &file, Lane_Use_Data &lane_use_rec)
{
	int link, dir, lanes, offset, dir_index, low, high;
	double rate;

	Link_Data *link_ptr;
	Int_Map_Itr map_itr;

	//---- check/convert the link number and direction ----

	link = file.Link ();
	if (link <= 0) return (false);

	dir = file.Dir ();
	offset = Round (file.Offset ());

	link_ptr = Set_Link_Direction (file, link, dir, offset);

	if (link_ptr == 0) return (false);

	if (dir) {
		dir_index = link_ptr->BA_Dir ();
	} else {
		dir_index = link_ptr->AB_Dir ();
	}
	if (dir_index < 0) {
		Warning (String ("Lane Use %d Link %d Direction %s was Not Found") % Progress_Count () % link_ptr->Link () % ((dir) ? "BA" : "AB"));
		return (false);
	}
	lane_use_rec.Dir_Index (dir_index);

	//---- set the restriction type ----

	lane_use_rec.Type (file.Type ());
	lane_use_rec.Use (file.Use ());

	//---- convert the vehicle type range ----

	low = file.Min_Veh_Type ();
	high = file.Max_Veh_Type ();

	if (low > 0) {
		map_itr = veh_type_map.find (low);
		if (map_itr == veh_type_map.end ()) {
			map_itr = veh_type_map.lower_bound (low);
			if (map_itr == veh_type_map.end ()) {
				Warning (String ("Lane Use %d Vehicle Type %d was Not Found") % Progress_Count () % low);
				low = -1;
			} else {
				low = map_itr->second;
			}
		} else {
			low = map_itr->second;
		}
	} else {
		low = -1;
	}
	if (high > 0) {
		map_itr = veh_type_map.find (high);
		if (map_itr == veh_type_map.end ()) {
			int h = high;
			while (h > 0) {
				map_itr = veh_type_map.find (--h);
				if (map_itr != veh_type_map.end ()) break;
			}
			if (h >= 0) {
				high = map_itr->second;
			} else {
				Warning (String ("Lane Use %d Vehicle Type %d was Not Found") % Progress_Count () % high);
				high = -1;
			}
		} else {
			high = map_itr->second;
		}
		if (high >= 0 && low < 0) low = 0;
	} else {
		high = -1;
	}
	if (low > high) {
		if (high == -1) {
			high = low;
		} else {
			Warning (String ("Lane Use %d Vehicle Type Range %d-%d is Illegal") % Progress_Count () % file.Min_Veh_Type () % file.Max_Veh_Type ());
			high = low;
		}
	}
	lane_use_rec.Min_Veh_Type (low);
	lane_use_rec.Max_Veh_Type (high);

	//---- convert the traveler type range ----

	low = file.Min_Traveler ();
	high = file.Max_Traveler ();

	if (low <= 0) low = -1;
	if (high > 0) {
		if (low < 0) low = 0;
	} else {
		high = -1;
	}
	if (low > high) {
		if (high == -1) {
			high = low;
		} else {
			Warning (String ("Lane Use %d Traveler Type Range %d-%d is Illegal") % Progress_Count () % file.Min_Traveler () % file.Max_Traveler ());
			high = low;
		}
	}
	lane_use_rec.Min_Traveler (low);
	lane_use_rec.Max_Traveler (high);

	//----- length and offset ----

	lane_use_rec.Length (file.Length ());

	if (lane_use_rec.Length () > 0) {
		if (offset > 0 || lane_use_rec.Length () < link_ptr->Length ()) {
			lane_use_rec.Offset (offset);
		} else {
			lane_use_rec.Offset (0);
			lane_use_rec.Length (0);
		}
	} else {
		lane_use_rec.Offset (0);
	}

	//---- lane number ----

	lanes = file.Lanes ();

	if (file.Version () <= 40 && lanes > 0) {
		low = high = lanes - 1;
	} else {
		Convert_Lane_Range (dir_index, lanes, low, high);
	}
	lane_use_rec.Low_Lane (low);
	lane_use_rec.High_Lane (high);

	//----- optional fields ----

	lane_use_rec.Start (file.Start ());
	lane_use_rec.End (file.End ());
	if (lane_use_rec.End () == 0) lane_use_rec.End (Model_End_Time ());

	lane_use_rec.Toll (Round (file.Toll ()));
	lane_use_rec.Toll_Rate (file.Toll_Rate ());

	if (lane_use_rec.Toll_Rate () > 0) {
		rate = UnRound (lane_use_rec.Toll_Rate ());

		if (Metric_Flag ()) {
			rate /= 1000.0;
		} else {
			rate /= MILETOFEET;
		}
		lane_use_rec.Toll (lane_use_rec.Toll () + DTOI (rate * link_ptr->Length ()));
	}
	lane_use_rec.Min_Delay (file.Min_Delay ());
	lane_use_rec.Max_Delay (file.Max_Delay ());
	lane_use_rec.Speed (file.Speed ());	
	lane_use_rec.Spd_Fac (file.Speed_Factor ());
	lane_use_rec.Capacity (file.Capacity ());
	lane_use_rec.Cap_Fac (file.Cap_Factor ());
	lane_use_rec.Notes (file.Notes ());

	return (true);
}
示例#4
0
int Data_Service::Put_Lane_Use_Data (Lane_Use_File &file, Lane_Use_Data &data)
{
	double rate, toll;

	Dir_Data *dir_ptr;
	Link_Data *link_ptr;
	Veh_Type_Data *veh_type_ptr;

	dir_ptr = &dir_array [data.Dir_Index ()];
	link_ptr = &link_array [dir_ptr->Link ()];

	file.Link (link_ptr->Link ());
	file.Dir (dir_ptr->Dir ());

	file.Lanes (Make_Lane_Range (dir_ptr, data.Low_Lane (), data.High_Lane ()));

	file.Use (data.Use ());
	file.Type (data.Type ());

	if (data.Min_Veh_Type () < 0) {
		file.Min_Veh_Type (0);
	} else if (veh_type_array.size () > 0) {
		veh_type_ptr = &veh_type_array [data.Min_Veh_Type ()];
		file.Min_Veh_Type (veh_type_ptr->Type ());
	} else {
		file.Min_Veh_Type (data.Min_Veh_Type ());
	}
	if (data.Max_Veh_Type () < 0) {
		file.Max_Veh_Type (0);
	} else if (veh_type_array.size () > 0) {
		veh_type_ptr = &veh_type_array [data.Max_Veh_Type ()];
		file.Max_Veh_Type (veh_type_ptr->Type ());
	} else {
		file.Max_Veh_Type (data.Max_Veh_Type ());
	}
	file.Min_Traveler (MAX (data.Min_Traveler (), 0)); 
	file.Max_Traveler (MAX (data.Max_Traveler (), 0));

	file.Start (data.Start ());
	file.End (data.End ());
	file.Length (UnRound (data.Length ()));
	file.Offset (UnRound (data.Offset ()));

	toll = UnRound (data.Toll ());
	rate = UnRound (data.Toll_Rate ());

	if (rate > 0) {
		if (Metric_Flag ()) {
			rate /= 1000.0;
		} else {
			rate /= MILETOFEET;
		}
		toll -= DTOI (rate * link_ptr->Length ());
	}
	file.Toll (DTOI (toll));
	file.Toll_Rate (rate);

	file.Min_Delay (UnRound (data.Min_Delay ()));
	file.Max_Delay (UnRound (data.Max_Delay ()));
	file.Speed (UnRound (data.Speed ()));
	file.Speed_Factor (UnRound (data.Spd_Fac ()) / 10.0);
	file.Capacity (data.Capacity ());
	file.Cap_Factor (UnRound (data.Cap_Fac ()) / 10.0);
	file.Notes (data.Notes ());

	if (!file.Write ()) {
		Error (String ("Writing %s") % file.File_Type ());
	}
	return (1);
}
示例#5
0
void LinkSum::Perf_Detail_File (void)
{
	int i, j, k, k1, lanes, max_lanes, tod_list, index, flow_index;
	int text_field, value_field, compare_field;
	double base_time, loaded_time, length, len, value, percent, flow, factor;
	String buffer, units, vmt, lane_mi;
	bool connect_flag;
	Dtime low, high, tod;

	Link_Itr link_itr;
	Dir_Data *dir_ptr;
	Link_Perf_Period_Itr period_itr;
	Link_Perf_Array *period_ptr;
	Link_Perf_Data perf_data;
	Flow_Time_Period_Itr turn_itr;
	Flow_Time_Array *compare_ptr;
	Flow_Time_Data *turn_ptr;
	Lane_Use_Period *use_ptr;
	Connect_Data *connect_ptr;
	Doubles_Itr itr;

	Show_Message ("Writing Performance Data File -- Record");
	Set_Progress ();

	text_field = detail_file.Field_Number ("MEASURE");
	value_field = detail_file.Field_Number ("VALUE");
	compare_field = detail_file.Field_Number ("COMPARE");

	//---- clear the summary bins -----

	for (itr = sum_bin.begin (); itr != sum_bin.end (); itr++) {
		itr->assign (NUM_SUM_BINS, 0.0);
	}
	connect_flag = System_Data_Flag (CONNECTION) && (turn_perf_array.size () > 0) && (compare_turn_array.size () > 0);

	//---- process each link ----

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		Show_Progress ();

		if (select_flag && link_itr->Use () == 0) continue;

		len = UnRound (link_itr->Length ());

		for (i=0; i < 2; i++) {
			if (i) {
				if (link_itr->Use () == -1) continue;
				index = link_itr->BA_Dir ();
			} else {
				if (link_itr->Use () == -2) continue;
				index = link_itr->AB_Dir ();
			}
			if (index < 0) continue;
			dir_ptr = &dir_array [index];
			flow_index = dir_ptr->Flow_Index ();

			base_time = dir_ptr->Time0 ().Seconds ();
			if (base_time <= 0.0) continue;

			tod_list = dir_ptr->First_Lane_Use ();

			max_lanes = dir_ptr->Lanes ();
			if (max_lanes < 1) max_lanes = 1;
			lanes = max_lanes;

			for (j=0, period_itr = link_perf_array.begin (); period_itr != link_perf_array.end (); period_itr++, j++) {
				if (tod_list >= 0) {

					//---- get the time period ----

					sum_periods.Period_Range (j, low, high);
					tod = (low + high + 1) / 2;

					lanes = max_lanes;
					k = tod_list;

					for (use_ptr = &use_period_array [k]; ; use_ptr = &use_period_array [++k]) {
						if (use_ptr->Start () <= tod && tod < use_ptr->End ()) {
							lanes = use_ptr->Lanes0 () + use_ptr->Lanes1 ();
							break;
						}
						if (use_ptr->Periods () == 0) break;
					}
				}
				perf_data = period_itr->Total_Link_Perf (index, flow_index);

				loaded_time = perf_data.Time ().Seconds ();
				flow = perf_data.Flow ();

				sum_bin [j] [LINKS] += 1;
				sum_bin [j] [LENGTH] += len;
				sum_bin [j] [LANES] += lanes * len;
				sum_bin [j] [VMT] += flow * len;
				sum_bin [j] [VHT] += flow * loaded_time;
				sum_bin [j] [VHD] += flow * (loaded_time - base_time);
				sum_bin [j] [TIME_RATIO] += (double) loaded_time / base_time;
				sum_bin [j] [DENSITY] += perf_data.Density ();
				sum_bin [j] [MAX_DEN] = MAX (sum_bin [j] [MAX_DEN], perf_data.Max_Density ());
				sum_bin [j] [QUEUE] += perf_data.Queue ();
				sum_bin [j] [MAX_QUEUE] = MAX (sum_bin [j] [MAX_QUEUE], perf_data.Max_Queue ());
				sum_bin [j] [FAILURE] += perf_data.Failure ();

				if (Ratio_Flag ()) {
					sum_bin [j] [CONG_VMT] += perf_data.Ratio_VMT ();
					sum_bin [j] [CONG_VHT] += perf_data.Ratio_VHT ();
					sum_bin [j] [CONG_TIME] += perf_data.Ratio_Count ();
					sum_bin [j] [COUNT] += perf_data.Occupancy ();
				}

				if (compare_flag) {
					period_ptr = &compare_link_array [j];

					perf_data = period_ptr->Total_Link_Perf (index, flow_index);

					loaded_time = perf_data.Time ();
					flow = perf_data.Flow ();

					sum_bin [j] [VMT+PREV] += flow * len;
					sum_bin [j] [VHT+PREV] += flow * loaded_time;
					sum_bin [j] [VHD+PREV] += flow * (loaded_time - base_time);
					sum_bin [j] [TIME_RATIO+PREV] += (double) loaded_time / base_time;
					sum_bin [j] [DENSITY+PREV] += perf_data.Density ();
					sum_bin [j] [MAX_DEN+PREV] = MAX (sum_bin [j] [MAX_DEN+PREV], perf_data.Max_Density ());
					sum_bin [j] [QUEUE+PREV] += perf_data.Queue ();
					sum_bin [j] [MAX_QUEUE+PREV] = MAX (sum_bin [j] [MAX_QUEUE+PREV], perf_data.Max_Queue ());
					sum_bin [j] [FAILURE+PREV] += perf_data.Failure ();

					if (Ratio_Flag ()) {
						sum_bin [j] [CONG_VMT+PREV] += perf_data.Ratio_VMT ();
						sum_bin [j] [CONG_VHT+PREV] += perf_data.Ratio_VHT ();
						sum_bin [j] [CONG_TIME+PREV] += perf_data.Ratio_Count ();
						sum_bin [j] [COUNT+PREV] += perf_data.Occupancy ();
					}
				}
			}

			//---- get the turning movements ----

			if (connect_flag) {
				for (k=dir_ptr->First_Connect (); k >= 0; k = connect_ptr->Next_Index ()) {
					connect_ptr = &connect_array [k];

					if (connect_ptr->Type () != LEFT && connect_ptr->Type () != RIGHT &&
						connect_ptr->Type () != UTURN) continue;

					for (j=0, turn_itr = turn_perf_array.begin (); turn_itr != turn_perf_array.end (); turn_itr++, j++) {
						turn_ptr = &turn_itr->at (k);

						sum_bin [j] [TURNS] += turn_ptr->Flow ();

						if (compare_flag) {
							compare_ptr = &compare_turn_array [j];
							turn_ptr = &compare_ptr->at (k);

							sum_bin [j] [TURNS+PREV] += turn_ptr->Flow ();
						}
					}
				}
			}
		}
	}
	End_Progress ();

	//---- write the data ----
	
	if (Metric_Flag ()) {
		factor = 1.0 / 1000.0;
		units = "Kilometers";
		vmt = "VKT";
		lane_mi = "km)";
	} else {
		factor = 1.0 / MILETOFEET;
		units = "Miles";
		vmt = "VMT";
		lane_mi = "mi)";
	}
	tod.Hours (1);

	for (j=0; j <= num_inc; j++) {
		len = sum_bin [j] [LINKS];
		if (len == 0.0) continue;

		if (j == num_inc) {
			buffer = "Time Period Total";
			len *= num_inc;
		} else {
			buffer = String ("Time Period %12.12s") % sum_periods.Range_Format (j);

			for (k = 0; k <= COUNT; k++) {
				k1 = k + PREV;
				if (k < VMT) {
					sum_bin [num_inc] [k] = MAX (sum_bin [j] [k], sum_bin [num_inc] [k]);

					if (compare_flag) {
						sum_bin [num_inc] [k1] = MAX (sum_bin [j] [k1], sum_bin [num_inc] [k1]);
					}
				} else {
					sum_bin [num_inc] [k] += sum_bin [j] [k];

					if (compare_flag) {
						sum_bin [num_inc] [k1] += sum_bin [j] [k1];
					}
				}
			}
		}
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, 0.0);
		if (compare_flag) detail_file.Put_Field (compare_field, 0.0);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Number of Links"));
		detail_file.Put_Field (value_field, sum_bin [j] [LINKS]);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [LINKS]);
		detail_file.Write ();

		buffer = "Number of Roadway " + units;
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, sum_bin [j] [LENGTH] * factor);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [LENGTH] * factor);
		detail_file.Write ();

		buffer = "Number of Lane " + units;
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, sum_bin [j] [LANES] * factor);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [LANES] * factor);
		detail_file.Write ();

		buffer = "Vehicle " + units + " of Travel";
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, sum_bin [j] [VMT] * factor);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [VMT+PREV] * factor);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Vehicle Hours of Travel"));
		detail_file.Put_Field (value_field, sum_bin [j] [VHT] / tod);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [VHT+PREV] / tod);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Vehicle Hours of Delay"));
		detail_file.Put_Field (value_field, sum_bin [j] [VHD] / tod);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [VHD+PREV] / tod);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Number of Queued Vehicles"));
		detail_file.Put_Field (value_field, UnRound (sum_bin [j] [QUEUE]));
		if (compare_flag) detail_file.Put_Field (compare_field, UnRound (sum_bin [j] [QUEUE+PREV]));
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Maximum Queued Vehicles"));
		detail_file.Put_Field (value_field, sum_bin [j] [MAX_QUEUE]);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [MAX_QUEUE+PREV]);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Number of Cycle Failures"));
		detail_file.Put_Field (value_field, sum_bin [j] [FAILURE]);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [FAILURE+PREV]);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Number of Turning Movements"));
		detail_file.Put_Field (value_field, sum_bin [j] [TURNS]);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [TURNS+PREV]);
		detail_file.Write ();

		detail_file.Put_Field (text_field, String ("Average Link Time Ratio"));
		detail_file.Put_Field (value_field, sum_bin [j] [TIME_RATIO] / len);
		if (compare_flag) detail_file.Put_Field (compare_field, sum_bin [j] [TIME_RATIO+PREV] / len);
		detail_file.Write ();

		buffer = "Average Link Density (/ln-" + lane_mi;
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, UnRound (sum_bin [j] [DENSITY] / len));
		if (compare_flag) detail_file.Put_Field (compare_field, UnRound (sum_bin [j] [DENSITY+PREV] / len));
		detail_file.Write ();

		buffer = "Maximum Link Density (/ln-" + lane_mi;
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, UnRound (sum_bin [j] [MAX_DEN]));
		if (compare_flag) detail_file.Put_Field (compare_field, UnRound (sum_bin [j] [MAX_DEN+PREV]));
		detail_file.Write ();

		length = sum_bin [j] [VMT] * factor;
		loaded_time = sum_bin [j] [VHT] / tod;
		if (loaded_time == 0.0) {
			loaded_time = length;
		} else {
			loaded_time = length / loaded_time;
		}
		buffer = "Average " + units + " Per Hour";
		detail_file.Put_Field (text_field, buffer);
		detail_file.Put_Field (value_field, loaded_time);

		if (compare_flag) {
			length = sum_bin [j] [VMT+PREV] * factor;
			loaded_time = sum_bin [j] [VHT+PREV] / tod;
			if (loaded_time == 0.0) {
				loaded_time = length;
			} else {
				loaded_time = length / loaded_time;
			}
			detail_file.Put_Field (compare_field, loaded_time);
		}
		detail_file.Write ();

		if (Ratio_Flag ()) {
			value = sum_bin [j] [VMT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [j] [CONG_VMT] / value;

			if (Metric_Flag ()) {
				buffer = "Percent VKT Congested";
			} else {
				buffer = "Percent VMT Congested";
			}
			detail_file.Put_Field (text_field, buffer);
			detail_file.Put_Field (value_field, percent);
			if (compare_flag) {
				value = sum_bin [j] [VMT+PREV];
				if (value == 0.0) value = 1.0;
				percent = 100.0 * sum_bin [j] [CONG_VMT+PREV] / value;

				detail_file.Put_Field (compare_field, percent);
			}
			detail_file.Write ();

			value = sum_bin [j] [VHT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [j] [CONG_VHT] / value;

			detail_file.Put_Field (text_field, String ("Percent VHT Congested"));
			detail_file.Put_Field (value_field, percent);
			if (compare_flag) {
				value = sum_bin [j] [VHT+PREV];
				if (value == 0.0) value = 1.0;
				percent = 100.0 * sum_bin [j] [CONG_VHT+PREV] / value;

				detail_file.Put_Field (compare_field, percent);
			}
			detail_file.Write ();

			value = sum_bin [j] [COUNT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [j] [CONG_TIME] / value;

			detail_file.Put_Field (text_field, String ("Percent Time Congested"));
			detail_file.Put_Field (value_field, percent);
			if (compare_flag) {
				value = sum_bin [j] [COUNT+PREV];
				if (value == 0.0) value = 1.0;
				percent = 100.0 * sum_bin [j] [CONG_TIME+PREV] / value;

				detail_file.Put_Field (compare_field, percent);
			}
			detail_file.Write ();
		}
	}
}
示例#6
0
int Data_Service::Put_Link_Data (Link_File &file, Link_Data &data)
{
	if (file.Model_Format () == TPPLUS) {
		int a, b, count;
		double length;
		Dir_Data *dir_ptr;

		if (data.Length () == 0) return (0);

		count = 0;
		a = data.Anode ();
		b = data.Bnode ();
		length = UnRound (data.Length ());

		if (System_Data_Flag (NODE)) {
			a = node_array [a].Node ();
			b = node_array [b].Node ();
		}
		if (data.AB_Dir () >= 0) {
			file.Node_A (a);
			file.Node_B (b);
			file.Length (length);
			file.Type (data.Type ());

			dir_ptr = &dir_array [data.AB_Dir ()];

			file.Lanes_AB (dir_ptr->Lanes ());
			file.Speed_AB (UnRound (dir_ptr->Speed ()));
			file.Cap_AB (dir_ptr->Capacity ());

			if (file.Dbase_Format () == ARCVIEW) {
				Link_Shape (&data, 0, *((Arc_Link_File *) &file));
			}
			if (!file.Write_Record ()) {
				Error (String ("Writing %s") % file.File_Type ());
			}
			count++;
		}
		if (data.BA_Dir () >= 0) {
			file.Node_A (b);
			file.Node_B (a);
			file.Length (length);
			file.Type (data.Type ());

			dir_ptr = &dir_array [data.BA_Dir ()];

			file.Lanes_AB (dir_ptr->Lanes ());
			file.Speed_AB (UnRound (dir_ptr->Speed ()));
			file.Cap_AB (dir_ptr->Capacity ());

			if (file.Dbase_Format () == ARCVIEW) {
				Link_Shape (&data, 1, *((Arc_Link_File *) &file));
			}
			if (!file.Write_Record ()) {
				Error (String ("Writing %s") % file.File_Type ());
			}
			count++;
		}
		return (count);
	}
	Dir_Data *dir_ptr;

	if (data.Length () == 0) return (0);

	file.Link (data.Link ());
	file.Name (data.Name ());
	file.Node_A (node_array [data.Anode ()].Node ());
	file.Node_B (node_array [data.Bnode ()].Node ());
	file.Length (UnRound (data.Length ()));
	file.Setback_A (UnRound (data.Aoffset ()));
	file.Setback_B (UnRound (data.Boffset ()));
	file.Type (data.Type ());
	file.Divided (data.Divided ());
	file.Area_Type (data.Area_Type ());
	file.Use (data.Use ());
	file.Grade (UnRound (data.Grade ()));
	file.Notes (data.Notes ());

	if (data.AB_Dir () >= 0) {
		dir_ptr = &dir_array [data.AB_Dir ()];

		file.Lanes_AB (dir_ptr->Lanes ());
		file.Speed_AB (UnRound (dir_ptr->Speed ()));

		if (dir_ptr->Time0 () > 0) {
			file.Fspd_AB ((double) data.Length () / dir_ptr->Time0 ());
		} else {
			file.Fspd_AB (UnRound (dir_ptr->Speed ()));
		}
		if (file.Fspd_AB () > file.Speed_AB () && file.Speed_AB () > 0) {
			if ((file.Fspd_AB () - file.Speed_AB ()) > 0.5) {
				if (Metric_Flag ()) {
					Warning (String ("Link %d Free Flow Speed %.1lf > Maximum Speed %.1lf") % data.Link () % External_Units (file.Fspd_AB (), MPH) % 
						External_Units (file.Speed_AB (), MPH));
				} else {
					Warning (String ("Link %d Free Flow Speed %.1lf > Maximum Speed %.1lf") % data.Link () % External_Units (file.Fspd_AB (), MPH) % 
						External_Units (file.Speed_AB (), MPH));
				}
			}
			file.Fspd_AB (file.Speed_AB ());
		}
		file.Cap_AB (dir_ptr->Capacity ());
		file.Bearing_A (dir_ptr->In_Bearing ());
		file.Bearing_B (dir_ptr->Out_Bearing ());
	} else {
		file.Lanes_AB (0);
		file.Speed_AB (0);
		file.Fspd_AB (0);
		file.Cap_AB (0);
	}
	if (data.BA_Dir () >= 0) {
		dir_ptr = &dir_array [data.BA_Dir ()];

		file.Lanes_BA (dir_ptr->Lanes ());
		file.Speed_BA (UnRound (dir_ptr->Speed ()));

		if (dir_ptr->Time0 () > 0) {
			file.Fspd_BA ((double) data.Length () / dir_ptr->Time0 ());
		} else {
			file.Fspd_BA (UnRound (dir_ptr->Speed ()));
		}
		if (file.Fspd_BA () > file.Speed_BA () && file.Speed_BA () > 0) {
			if ((file.Fspd_BA () - file.Speed_BA ()) > 0.5) {
				if (Metric_Flag ()) {
					Warning (String ("Link %d Free Flow Speed %.1lf > Maximum Speed %.1lf") % data.Link () % External_Units (file.Fspd_BA (), MPH) % 
						External_Units (file.Speed_BA (), MPH));
				} else {
					Warning (String ("Link %d Free Flow Speed %.1lf > Maximum Speed %.1lf") % data.Link () % External_Units (file.Fspd_BA (), MPH) % 
						External_Units (file.Speed_BA (), MPH));
				}
			}
			file.Fspd_BA (file.Speed_BA ());
		}
		file.Cap_BA (dir_ptr->Capacity ());
		if (data.AB_Dir () < 0) {
			file.Bearing_B (compass.Flip (dir_ptr->In_Bearing ()));
			file.Bearing_A (compass.Flip (dir_ptr->Out_Bearing ()));
		}
	} else {
		file.Lanes_BA (0);
		file.Speed_BA (0);
		file.Fspd_BA (0);
		file.Cap_BA (0);
	}
	if (file.Dbase_Format () == ARCVIEW) {
		Link_Shape (&data, 0, *((Arc_Link_File *) &file));
	}
	if (!file.Write_Record ()) {
		Error (String ("Writing %s") % file.File_Type ());
	}
	return (1);
}
示例#7
0
void LineSum::Program_Control (void)
{
	int i, num_files, anode, bnode;
	bool arcview_flag, z_flag, m_flag;
	String key, format;
	Strings ab_strings, node_pairs;
	Str_Itr str_itr, ab_itr;
	Db_Header *fh = 0;
	File_Itr file_itr;
	Line_Report_Data line_report_data;
	Link_Report_Data link_report_data;
	On_Off_Report_Data on_off_report_data;
	Access_Report_Data access_report_data;
	Stop_Report_Data stop_report_data;
	Total_Report_Data total_report_data;
	Link_Rider_Data link_rider_data;
	Dtime hour;

	//---- process the global control keys ----

	Execution_Service::Program_Control ();

	Metric_Flag (false);
	hour.Hours (1.0);

	//---- get the projection data ----

	projection.Read_Control ();

	//---- get the z coordinate flag ----

	m_flag = projection.M_Flag ();
	z_flag = projection.Z_Flag ();

	Print (2, String ("%s Control Keys:") % Program ());

	//---- initialize the peak file list ----

	num_files = Highest_Control_Group (PEAK_RIDERSHIP_FILE, 0);

	if (num_files > 0) {
		peak_list.Initialize (num_files);
		Print (1);

		//---- open each file ----

		for (i=1; i <= num_files; i++) {

			//---- open the peak ridership file ----

			key = Get_Control_String (PEAK_RIDERSHIP_FILE, i);
			if (key.empty ()) continue;
	
			fh = peak_list [i-1];

			fh->File_Type (String ("Peak Ridership File #%d") % i);
			fh->File_ID (String ("Peak%d") % i);

			//---- get the file format ----

			if (Check_Control_Key (PEAK_RIDERSHIP_FORMAT, i)) {
				fh->Dbase_Format (Get_Control_String (PEAK_RIDERSHIP_FORMAT, i));
			}
			fh->Open (Project_Filename (key));
		}
	}

	//---- initialize the offpeak file list ----

	num_files = Highest_Control_Group (OFFPEAK_RIDERSHIP_FILE, 0);

	if (num_files > 0) {
		offpeak_list.Initialize (num_files);
		Print (1);

		//---- open each file ----

		for (i=1; i <= num_files; i++) {

			//---- open the offpeak ridership file ----

			key = Get_Control_String (OFFPEAK_RIDERSHIP_FILE, i);
			if (key.empty ()) continue;
	
			fh = offpeak_list [i-1];

			fh->File_Type (String ("Offpeak Ridership File #%d") % i);
			fh->File_ID (String ("Offpeak%d") % i);

			//---- get the file format ----

			if (Check_Control_Key (OFFPEAK_RIDERSHIP_FORMAT, i)) {
				fh->Dbase_Format (Get_Control_String (OFFPEAK_RIDERSHIP_FORMAT, i));
			}
			fh->Open (Project_Filename (key));
		}
	}
	if (peak_list.size () == 0 && offpeak_list.size () == 0) {
//		Error ("No Peak or Offpeak Ridership File Keys were Found");
	}

	//---- open the new peak ridership file ----

	key = Get_Control_String (NEW_PEAK_RIDERSHIP_FILE);

	if (!key.empty ()) {
		Print (1);
		if (peak_list.size () == 0) {
			Error ("Input Peak Ridership Files are Required");
		}
		fh = 0;

		for (file_itr = peak_list.begin (); file_itr != peak_list.end (); file_itr++) {
			if ((*file_itr)->Is_Open ()) {
				fh = *file_itr;
				break;
			}
		}
		if (fh == 0) Error ("Peak Input files are Not Open");

		new_peak_file.File_Type ("New Peak Ridership File");
		new_peak_file.File_ID ("NewPeak");

		//---- get the file format ----

		if (Check_Control_Key (NEW_PEAK_RIDERSHIP_FORMAT)) {
			new_peak_file.Dbase_Format (Get_Control_String (NEW_PEAK_RIDERSHIP_FORMAT));
		}
		new_peak_file.Header_Lines (fh->Header_Lines ());

		new_peak_file.Replicate_Fields (fh);

		new_peak_file.Create (Project_Filename (key));
	}

	//---- open the new offpeak ridership file ----

	key = Get_Control_String (NEW_OFFPEAK_RIDERSHIP_FILE);

	if (!key.empty ()) {
		Print (1);
		if (offpeak_list.size () == 0) {
			Error ("Input Offpeak Ridership Files are Required");
		}
		fh = 0;

		for (file_itr = offpeak_list.begin (); file_itr != offpeak_list.end (); file_itr++) {
			if ((*file_itr)->Is_Open ()) {
				fh = *file_itr;
				break;
			}
		}
		if (fh == 0) Error ("Offpeak Input files are Not Open");

		new_offpeak_file.File_Type ("New Offpeak Ridership File");
		new_offpeak_file.File_ID ("NewOffpeak");

		//---- get the file format ----

		if (Check_Control_Key (NEW_OFFPEAK_RIDERSHIP_FORMAT)) {
			new_offpeak_file.Dbase_Format (Get_Control_String (NEW_OFFPEAK_RIDERSHIP_FORMAT));
		}
		new_offpeak_file.Header_Lines (fh->Header_Lines ());

		new_offpeak_file.Replicate_Fields (fh);

		new_offpeak_file.Create (Project_Filename (key));
	}

	//---- open the new total ridership file ----

	key = Get_Control_String (NEW_TOTAL_RIDERSHIP_FILE);

	if (!key.empty ()) {
		Print (1);
		if (peak_list.size () == 0 || offpeak_list.size () == 0) {
			Error ("Input Peak and Offpeak Ridership Files are Required");
		}
		fh = 0;

		for (file_itr = peak_list.begin (); file_itr != peak_list.end (); file_itr++) {
			if ((*file_itr)->Is_Open ()) {
				fh = *file_itr;
				break;
			}
		}
		if (fh == 0) Error ("Peak Input files are Not Open");

		new_total_file.File_Type ("New Total Ridership File");
		new_total_file.File_ID ("NewTotal");

		//---- get the file format ----

		if (Check_Control_Key (NEW_TOTAL_RIDERSHIP_FORMAT)) {
			new_total_file.Dbase_Format (Get_Control_String (NEW_TOTAL_RIDERSHIP_FORMAT));
		}
		new_total_file.Header_Lines (fh->Header_Lines ());

		new_total_file.Replicate_Fields (fh);

		new_total_file.Create (Project_Filename (key));
	}

	//---- open the stop name file ----

	key = Get_Control_String (STOP_NAME_FILE);
	if (!key.empty ()) {
		Print (1);
		stop_name_file.File_Type ("Stop Name File");
		stop_name_file.File_ID ("StopName");
		station_flag = true;

		//---- get the file format ----

		if (Check_Control_Key (STOP_NAME_FORMAT)) {
			stop_name_file.Dbase_Format (Get_Control_String (STOP_NAME_FORMAT));
		}
		stop_name_file.Open (Project_Filename (key));
	}

	//---- line report data ----

	num_files = Highest_Control_Group (LINE_REPORT_LINES);

	if (num_files > 0) {

		//---- read the line report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (LINE_REPORT_LINES, i)) continue;
			Print (1);

			//---- report number and title ----

			line_report_data.number = i;
			line_report_data.title = Get_Control_Text (LINE_REPORT_TITLE, i);

			//---- line range ----
			
			key = Get_Control_Text (LINE_REPORT_LINES, i);
			if (key.empty ()) continue;

			key.Parse (line_report_data.lines);

			//---- selected modes ----

			key = Get_Control_Text (LINE_REPORT_MODES, i);
			line_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				line_report_data.all_modes = false;
				if (!line_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				line_report_data.all_modes = true;
			}

			//---- report all nodes ----

			line_report_data.node_flag = Get_Control_Flag (LINE_REPORT_ALL_NODES, i);

			//---- store the control data ----

			line_report_array.push_back (line_report_data);
		}
	}

	//---- link report data ----

	num_files = Highest_Control_Group (LINK_REPORT_LINKS);

	if (num_files > 0) {

		//---- read the link report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (LINK_REPORT_LINKS, i)) continue;
			Print (1);

			//---- report number and title ----

			link_report_data.number = i;
			link_report_data.title = Get_Control_Text (LINK_REPORT_TITLE, i);

			//---- anode-bnode pairs ----
			
			key = Get_Control_Text (LINK_REPORT_LINKS, i);
			if (key.empty ()) continue;

			link_report_data.links = key;

			key.Parse (node_pairs);
			link_report_data.nodes.clear ();

			for (str_itr = node_pairs.begin (); str_itr != node_pairs.end (); str_itr++) {
				str_itr->Parse (ab_strings, "-");

				for (anode=0, ab_itr = ab_strings.begin (); ab_itr != ab_strings.end (); ab_itr++, anode = bnode) {
					bnode = ab_itr->Integer ();
					if (anode > 0) {
						link_report_data.nodes.push_back (anode);
						link_report_data.nodes.push_back (bnode);
					}
				}
			}

			//---- selected modes ----

			key = Get_Control_Text (LINK_REPORT_MODES, i);
			link_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				link_report_data.all_modes = false;
				if (!link_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				link_report_data.all_modes = true;
			}

			//---- selected lines ----

			key = Get_Control_Text (LINK_REPORT_LINES, i);
			link_report_data.lines.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				link_report_data.all_lines = false;
				key.Parse (link_report_data.lines);
			} else {
				link_report_data.all_lines = true;
			}

			//---- oneway/twoway flag ----

			link_report_data.dir_flag = Get_Control_Flag (LINK_REPORT_ONEWAY, i);

			//---- store the control data ----

			link_report_array.push_back (link_report_data);
		}
	}

	//---- on-off report data ----

	num_files = Highest_Control_Group (ON_OFF_REPORT_STOPS);

	if (num_files > 0) {
		on_off_flag = true;

		//---- read the boarding report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (ON_OFF_REPORT_STOPS, i)) continue;
			Print (1);

			//---- report number and title ----

			on_off_report_data.number = i;
			on_off_report_data.title = Get_Control_Text (ON_OFF_REPORT_TITLE, i);

			//---- stop range ----

			key = Get_Control_Text (ON_OFF_REPORT_STOPS, i);
			if (key.empty ()) continue;

			on_off_report_data.stops.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				on_off_report_data.all_stops = false;
				if (!on_off_report_data.stops.Add_Ranges (key)) {
					exe->Error ("Adding Stop Ranges");
				}
			} else {
				on_off_report_data.all_stops = true;
			}

			//---- select modes ----

			key = Get_Control_Text (ON_OFF_REPORT_MODES, i);

			on_off_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				on_off_report_data.all_modes = false;
				if (!on_off_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				on_off_report_data.all_modes = true;
			}

			//---- level of detail ----

			key = Get_Control_Text (ON_OFF_REPORT_DETAILS, i);

			if (!key.empty ()) {
				char ch = key [0];
				if (ch >= 'a' && ch <= 'z') ch = ch - 'a' + 'A';

				if (ch == 'T' || ch == 'Y' || ch == '1') {
					on_off_report_data.details = 1;
				} else if (ch == 'M' || ch == '2') {
					on_off_report_data.details = 2;
				} else {
					on_off_report_data.details = 0;
				}
			} else {
				on_off_report_data.details = 0;
			}

			//---- output data file ----

			key = Get_Control_String (NEW_ON_OFF_REPORT_FILE, i);

			if (!key.empty ()) {
				if (Check_Control_Key (NEW_ON_OFF_REPORT_FORMAT, i)) {
					format = Get_Control_String (NEW_ON_OFF_REPORT_FORMAT, i);

					on_off_report_data.arcview_flag = format.Equals ("ARCVIEW");
				} else {
					on_off_report_data.arcview_flag = false;
				}
				Print (1);
				if (on_off_report_data.arcview_flag) {
					on_off_report_data.file = on_off_report_data.arc_file = new Arcview_File ();

					on_off_report_data.arc_file->File_Type (String ("New On-Off Report File #%d") % i);
					on_off_report_data.arc_file->Shape_Type (DOT);
					on_off_report_data.arc_file->Z_Flag (z_flag);
					on_off_report_data.arc_file->M_Flag (m_flag);

					on_off_report_data.arc_file->Create (Project_Filename (key));

					on_off_report_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ());
					xy_flag = true;
				} else {
					on_off_report_data.file = new Db_Header ();

					if (Check_Control_Key (NEW_ON_OFF_REPORT_FORMAT, i)) {
						on_off_report_data.file->Dbase_Format (format);
					}
					on_off_report_data.file->File_Type (String ("New On-Off Report File #%d") % i);
					on_off_report_data.file->Create (Project_Filename (key));
				}
			} else {
				on_off_report_data.file = 0;
			}

			//---- store the control data ----

			on_off_report_array.push_back (on_off_report_data);
		}
	}

	//---- access report data ----

	num_files = Highest_Control_Group (ACCESS_REPORT_STOPS);

	if (num_files > 0) {
		access_flag = true;

		//---- read the access report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (ACCESS_REPORT_STOPS, i)) continue;
			Print (1);

			//---- report number and title ----

			access_report_data.number = i;
			access_report_data.title = Get_Control_Text (ACCESS_REPORT_TITLE, i);

			//---- stop range ----

			key = Get_Control_Text (ACCESS_REPORT_STOPS, i);
			if (key.empty ()) continue;

			access_report_data.stops.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				access_report_data.all_stops = false;
				if (!access_report_data.stops.Add_Ranges (key)) {
					exe->Error ("Adding Stop Ranges");
				}
			} else {
				access_report_data.all_stops = true;
			}

			//---- select modes ----

			key = Get_Control_Text (ACCESS_REPORT_MODES, i);

			access_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				access_report_data.all_modes = false;
				if (!access_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				access_report_data.all_modes = true;
			}

			//---- level of detail ----

			key = Get_Control_Text (ACCESS_REPORT_DETAILS, i);

			if (!key.empty ()) {
				char ch = key [0];
				if (ch >= 'a' && ch <= 'z') ch = ch - 'a' + 'A';

				if (ch == 'T' || ch == 'Y' || ch == '1') {
					access_report_data.details = 1;
				} else if (ch == 'M' || ch == '2') {
					access_report_data.details = 2;
				} else {
					access_report_data.details = 0;
				}
			} else {
				access_report_data.details = 0;
			}

			//---- output data file ----

			key = Get_Control_String (NEW_ACCESS_REPORT_FILE, i);

			if (!key.empty ()) {
				access_report_data.file = new Db_Header ();
				access_report_data.file->File_Type (String ("New Access Report File #%d") % i);

				if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) {
					access_report_data.file->Dbase_Format (Get_Control_String (NEW_ACCESS_REPORT_FORMAT, i));
				}
				access_report_data.file->Create (Project_Filename (key));

				if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) {
					format = Get_Control_String (NEW_ACCESS_REPORT_FORMAT, i);

					access_report_data.arcview_flag = format.Equals ("ARCVIEW");
				} else {
					access_report_data.arcview_flag = false;
				}
				Print (1);
				if (access_report_data.arcview_flag) {
					access_report_data.file = access_report_data.arc_file = new Arcview_File ();

					access_report_data.arc_file->File_Type (String ("New Access Report File #%d") % i);
					access_report_data.arc_file->Shape_Type (DOT);
					access_report_data.arc_file->Z_Flag (z_flag);
					access_report_data.arc_file->M_Flag (m_flag);

					access_report_data.arc_file->Create (Project_Filename (key));

					access_report_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ());
					xy_flag = true;
				} else {
					access_report_data.file = new Db_Header ();

					if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) {
						access_report_data.file->Dbase_Format (format);
					}
					access_report_data.file->File_Type (String ("New Access Report File #%d") % i);
					access_report_data.file->Create (Project_Filename (key));
				}
			} else {
				access_report_data.file = 0;
			}

			//---- store the control data ----

			access_report_array.push_back (access_report_data);
		}
	}

	//---- stop report data ----

	num_files = Highest_Control_Group (STOP_REPORT_STOPS);

	if (num_files > 0) {
		access_flag = true;

		//---- read the stop report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (STOP_REPORT_STOPS, i)) continue;
			Print (1);

			//---- report number and title ----

			stop_report_data.number = i;
			stop_report_data.title = Get_Control_Text (STOP_REPORT_TITLE, i);

			//---- stop range ----
			
			key = Get_Control_Text (STOP_REPORT_STOPS, i);
			if (key.empty ()) continue;

			stop_report_data.stops.clear ();

			if (!stop_report_data.stops.Add_Ranges (key)) {
				exe->Error ("Adding Stop Ranges");
			}

			//---- select modes ----

			key = Get_Control_Text (STOP_REPORT_MODES, i);
			stop_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				stop_report_data.all_modes = false;
				if (!stop_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				stop_report_data.all_modes = true;
			}

			//---- line range ----

			key = Get_Control_Text (STOP_REPORT_LINES, i);
			stop_report_data.lines.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				stop_report_data.all_lines = false;
				key.Parse (stop_report_data.lines);
			} else {
				stop_report_data.all_lines = true;
			}

			//---- transfer modes ----

			key = Get_Control_Text (STOP_REPORT_TRANSFERS, i);
			stop_report_data.transfers.clear ();

			if (!key.empty () && !key.Equals ("NONE")) {
				if (!stop_report_data.transfers.Add_Ranges (key)) {
					exe->Error ("Adding Transfer Mode Ranges");
				}
			}

			//---- store the control data ----

			stop_report_array.push_back (stop_report_data);
		}
	}

	//---- total report data ----

	num_files = Highest_Control_Group (TOTAL_REPORT_LINES);

	if (num_files > 0) {

		//---- read the total report keys ----

		for (i=1; i <= num_files; i++) {
			if (!Check_Control_Key (TOTAL_REPORT_LINES, i)) continue;
			Print (1);

			//---- report number and title ----

			total_report_data.number = i;
			total_report_data.title = Get_Control_Text (TOTAL_REPORT_TITLE, i);

			//---- line range ----

			key = Get_Control_Text (TOTAL_REPORT_LINES, i);
			if (key.empty ()) continue;

			key.Parse (total_report_data.lines);

			//---- selected modes ----

			key = Get_Control_Text (TOTAL_REPORT_MODES, i);
			
			total_report_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				total_report_data.all_modes = false;
				if (!total_report_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				total_report_data.all_modes = true;
			}

			//---- output data file ----

			key = Get_Control_String (NEW_TOTAL_REPORT_FILE, i);
			if (!key.empty ()) {
				total_report_data.file = new Db_Header ();
				total_report_data.file->File_Type (String ("New Total Report File #%d") % i);

				if (Check_Control_Key (NEW_TOTAL_REPORT_FORMAT, i)) {
					total_report_data.file->Dbase_Format (Get_Control_String (NEW_TOTAL_REPORT_FORMAT, i));
				}
				total_report_data.file->Create (Project_Filename (key));

				//---- peak hours ----

				total_report_data.peak_hours = (double) Get_Control_Time (TOTAL_REPORT_PEAK_HOURS, i) / hour;
			
				//---- offpeak hours ----

				total_report_data.offpeak_hours = (double) Get_Control_Time (TOTAL_REPORT_OFFPEAK_HOURS, i) / hour;
			} else {
				total_report_data.file = 0;
			}

			//---- store the control data ----

			total_report_array.push_back (total_report_data);
		}
	}

	//---- open the node XY file ----

	if (xy_flag) {
		key = Get_Control_String (NODE_XY_FILE);

		if (key.empty ()) {
			Error ("Node XY File is Required for Stop Shapefiles");
		}
		if (Check_Control_Key (NODE_XY_FORMAT)) {
			node_xy_file.Dbase_Format (Get_Control_String (NODE_XY_FORMAT));
		}
		node_xy_file.File_Type ("Node XY File");

		Print (1);
		node_xy_file.Open (Project_Filename (key));
	}

	//---- link rider file data ----

	num_files = Highest_Control_Group (NEW_LINK_RIDER_FILE);

	if (num_files > 0) {
		arcview_flag = false;

		//---- read the link rider keys ----

		for (i=1; i <= num_files; i++) {

			//---- output data file ---

			key = Get_Control_String (NEW_LINK_RIDER_FILE, i);
			if (key.empty ()) continue;
			
			link_rider_data.number = i;

			if (Check_Control_Key (NEW_LINK_RIDER_FORMAT, i)) {
				format = Get_Control_String (NEW_LINK_RIDER_FORMAT, i);

				link_rider_data.arcview_flag = format.Equals ("ARCVIEW");
			} else {
				link_rider_data.arcview_flag = false;
			}
			Print (1);
			if (link_rider_data.arcview_flag) {
				link_rider_data.file = link_rider_data.arc_file = new Arcview_File ();

				link_rider_data.arc_file->File_Type (String ("New Link Rider File #%d") % i);
				link_rider_data.arc_file->Shape_Type (VECTOR);
				link_rider_data.arc_file->Z_Flag (z_flag);
				link_rider_data.arc_file->M_Flag (m_flag);

				link_rider_data.arc_file->Create (Project_Filename (key));

				link_rider_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ());
				arcview_flag = true;
			} else {
				link_rider_data.file = new Db_Header ();

				if (Check_Control_Key (NEW_LINK_RIDER_FORMAT, i)) {
					link_rider_data.file->Dbase_Format (format);
				}
				link_rider_data.file->File_Type (String ("New Link Rider File #%d") % i);
				link_rider_data.file->Create (Project_Filename (key));
			}

			//---- selected modes ----

			key = Get_Control_Text (LINK_RIDER_MODES, i);
			link_rider_data.modes.clear ();

			if (!key.empty () && !key.Equals ("ALL")) {
				link_rider_data.all_modes = false;
				if (!link_rider_data.modes.Add_Ranges (key)) {
					exe->Error ("Adding Modes Ranges");
				}
			} else {
				link_rider_data.all_modes = true;
			}

			//---- selected lines ----

			key = Get_Control_Text (LINK_RIDER_LINES, i);
			link_rider_data.lines.clear ();
			link_rider_data.all_lines = false;
			link_rider_data.each_line = false;

			if (key.empty ()) {
				link_rider_data.all_lines = true;
			} else if (key.Equals ("ALL")) {
				link_rider_data.all_lines = true;
			} else if (key.Equals ("EACH")) {
				link_rider_data.each_line = true;
			} else {
				key.Parse (link_rider_data.lines);
			}
			
			//---- peak hours ----

			link_rider_data.peak_hours = (double) Get_Control_Time (LINK_RIDER_PEAK_HOURS, i) / hour;

			//---- peak factor ----

			link_rider_data.peak_fac = Get_Control_Double (LINK_RIDER_PEAK_FACTOR, i);

			//---- peak capacity ----

			link_rider_data.peak_cap = Get_Control_Double (LINK_RIDER_PEAK_CAPACITY, i);
			
			//---- offpeak hours ----

			link_rider_data.offpeak = (double) Get_Control_Time (LINK_RIDER_OFFPEAK_HOURS, i) / hour;

			//---- open node file for arcview output ----

			if (link_rider_data.arcview_flag) {
				key = Get_Control_String (LINK_RIDER_XY_FILE, i);

				if (key.empty ()) {
					Error ("A Link Rider XY File is required for Arcview Output");
				}
				link_rider_data.xy_file = new Db_Header ();
				link_rider_data.xy_file->File_Type (String ("Link Rider XY File #%d") % i);

				if (Check_Control_Key (LINK_RIDER_XY_FORMAT, i)) {
					link_rider_data.xy_file->Dbase_Format (Get_Control_String (LINK_RIDER_XY_FORMAT, i));
				}
				link_rider_data.xy_file->Open (Project_Filename (key));

				link_rider_data.node_fld = link_rider_data.xy_file->Required_Field (NODE_FIELD_NAMES);
				link_rider_data.xcoord_fld = link_rider_data.xy_file->Required_Field (X_FIELD_NAMES);
				link_rider_data.ycoord_fld = link_rider_data.xy_file->Required_Field (Y_FIELD_NAMES);

				link_rider_data.offset = Get_Control_Double (LINK_RIDER_SIDE_OFFSET, i);
			} else {
				link_rider_data.offset = 0.0;
			}

			//---- store the control data ----

			link_rider_array.push_back (link_rider_data);
		}

		//---- open the link shape file ----

		if (arcview_flag) {
			key = Get_Control_String (LINK_SHAPE_FILE);

			if (!key.empty ()) {
				Print (1);
				shape_flag = true;

				link_shape.File_Type ("Link Shape File");
				link_shape.Set_Projection (projection.Input_Projection (), projection.Output_Projection ());

				link_shape.Open (Project_Filename (key));

				//---- get the field numbers ----

				key = Get_Control_Text (LINK_SHAPE_ANODE);

				anode_field = link_shape.Required_Field (key);
				Print (0, ", Number=") << anode_field;
				
				key = Get_Control_Text (LINK_SHAPE_BNODE);

				bnode_field = link_shape.Required_Field (key);
				Print (0, ", Number=") << bnode_field;
			}
		}

		//---- process service level files ----

		key = Get_Control_String (SERVICE_FILE);

		if (!key.empty ()) {
			Print (1);
			service_file.File_Type ("Service File");
			service_flag = true;

			//---- get the file format ----

			if (Check_Control_Key (SERVICE_FORMAT)) {
				service_file.Dbase_Format (Get_Control_String (SERVICE_FORMAT));
			}
			service_file.Open (Project_Filename (key));

			//---- get the field numbers ----

			key = Get_Control_Text (SERVICE_LINE_FIELD);

			line_fld = service_file.Required_Field (key);
			Print (0, ", Number=") << line_fld;

			if (Check_Control_Key (SERVICE_PEAK_FIELD)) {
				key = Get_Control_Text (SERVICE_PEAK_FIELD);

				peak_fld = service_file.Required_Field (key);
				Print (0, ", Number=") << peak_fld;
			}
			if (Check_Control_Key (SERVICE_OFFPEAK_FIELD)) {
				key = Get_Control_Text (SERVICE_OFFPEAK_FIELD);

				offpeak_fld = service_file.Required_Field (key);
				Print (0, ", Number=") << offpeak_fld;
			}
		}
	}

	//---- initialize the base routes ----

	num_files = Highest_Control_Group (BASE_ROUTE_FILE, 0);

	if (num_files > 0) {
		base_routes.Initialize (num_files);
		Print (1);

		//---- open each file ----

		for (i=1; i <= num_files; i++) {

			//---- open the base ridership file ----

			key = Get_Control_String (BASE_ROUTE_FILE, i);
			if (key.empty ()) continue;
	
			fh = base_routes [i-1];

			fh->File_Type (String ("Base Route File #%d") % i);
			fh->File_ID (String ("Base%d") % i);

			//---- get the file format ----

			if (Check_Control_Key (BASE_ROUTE_FORMAT, i)) {
				fh->Dbase_Format (Get_Control_String (BASE_ROUTE_FORMAT, i));
			}
			fh->Open (Project_Filename (key));
		}
	}

	//---- initialize the alternative routes ----

	num_files = Highest_Control_Group (ALTERNATIVE_ROUTE_FILE, 0);

	if (num_files > 0) {
		alt_routes.Initialize (num_files);
		Print (1);

		//---- open each file ----

		for (i=1; i <= num_files; i++) {

			//---- open the alternative ridership file ----

			key = Get_Control_String (ALTERNATIVE_ROUTE_FILE, i);
			if (key.empty ()) continue;
	
			fh = alt_routes [i-1];

			fh->File_Type (String ("Alternative Route File #%d") % i);
			fh->File_ID (String ("Alte%d") % i);

			//---- get the file format ----

			if (Check_Control_Key (ALTERNATIVE_ROUTE_FORMAT, i)) {
				fh->Dbase_Format (Get_Control_String (ALTERNATIVE_ROUTE_FORMAT, i));
			}
			fh->Open (Project_Filename (key));
		}
	}
}