Пример #1
0
void VehGen::Program_Control (void)
{
	Db_Header *file;

	Demand_Service::Program_Control ();

	file = (Db_Header *) Demand_Db_Base (HOUSEHOLD);

	vehicle_flag = (file->Optional_Field ("VEHICLES", "AUTOS") != 0);
} 
Пример #2
0
void ZoneData::Read_Data (void)
{
	int id, field, count;

	Db_Sort_Array *data;
	Db_Header *file;
	Data_Itr data_itr;

	for (data_itr = data_group.begin (); data_itr != data_group.end (); data_itr++) {
		file = data_itr->file;
		data = data_itr->data_db;
		field = data_itr->join_field;

		//---- read the data file ----

		Show_Message (String ("Reading %s -- Record") % file->File_Type ());
		Set_Progress ();

		count = 0;

		while (file->Read ()) {
			Show_Progress ();

			//---- get the join field id ----

			id = file->Get_Integer (field);
			if (id == 0) continue;

			//---- copy the data fields ----

			data->Copy_Fields (*file);

			//---- set the record index and zone count ----

			data->Put_Field (0, id);
			data->Put_Field (1, 0);

			//---- save the database record ----

			if (!data->Write_Record (id)) {
				Error ("Writing Data File Database");
			}
			count++;
		}
		End_Progress ();

		Print (2, String ("Number of Data #%d Records = %d") % data_itr->group % count);
		
		file->Close ();
	}
}
Пример #3
0
void ZoneData::Read_Data (int num)
{
	int id, field, count;

	Db_Index_Array *data;
	Db_Header *file;

	//---- set the file pointers ----

	file = data_files [num];
	if (file == NULL) return;

	data = data_db [num];
	field = data_field [num];

	if (!data->Max_Records (file->Num_Records ())) {
		Error ("Insufficient Memory for Data File Database");
	}

	//---- read the data file ----

	Show_Message ("Reading %s -- Record", file->File_Type ());
	Set_Progress (1000);

	count = 0;

	while (file->Read ()) {
		Show_Progress ();

		//---- get the join field id ----

		file->Get_Field (field, &id);
		if (id == 0) continue;

		//---- copy the data fields ----

		data->Copy_Fields (file);

		//---- set the record index and location count ----

		data->Put_Field (1, id);
		data->Put_Field (2, 0);

		//---- save the database record ----

		if (!data->Add_Record ()) {
			Error ("Writing Data File Database");
		}
		count++;
	}
	End_Progress ();

	Print (2, "Number of %s Records = %d", file->File_Type (), count);
	
	file->Close ();
}
Пример #4
0
void ZoneData::Program_Control (void)
{
	int i, size, num, decimal, existing;
	char *str_ptr, *format_ptr, name [FIELD_BUFFER], buffer [FIELD_BUFFER];
	Db_Code::Field_Type type;

	Db_Header *file;

	//---- open network files ----

	Network_Service::Program_Control ();

	input_file = (Zone_File *) Network_Db_File (ZONE);
	input_file->File_ID ("In");

	output_file = (Zone_File *) Network_Db_File (NEW_ZONE);
	output_file->File_ID ("Out");

	//---- copy existing fields ----

	str_ptr = Get_Control_String (COPY_EXISTING_FIELDS);

	if (str_ptr != NULL) {
		Print (2, "Copy Existing Fields = %s", str_ptr);

		copy_flag = Get_Control_Flag (COPY_EXISTING_FIELDS);

		if (copy_flag) {
			output_file->Clear_Fields ();
			output_file->Replicate_Fields (input_file, false);
		}
	}

	//---- get the new zone fields ----

	num = Highest_Control_Group (NEW_ZONE_FIELD_x, 0);

	if (num == 0) {
		if (Get_Control_String (NEW_ZONE_FIELD) != NULL) {
			num = 1;
		}
	} else {
		num++;
	}

	if (num == 0) {
		if (!copy_flag) {
			Warning ("No New Zone Fields");
		}
	} else {
		Print (1);

		for (i=0; i < num; i++) {
			if (i == 0) {
				str_ptr = Get_Control_String (NEW_ZONE_FIELD);
			} else {
				str_ptr = Get_Control_String (NEW_ZONE_FIELD_x, i);
			}
			if (str_ptr == NULL) continue;

			if (i == 0) {
				Print (1, "New Zone Field = %s", str_ptr);
			} else {
				Print (1, "New Zone Field #%d = %s", i, str_ptr);
			}
			str_ptr = Get_Token (str_ptr, name, sizeof (name));
			if (name [0] == '\0') goto data_error;

			existing = output_file->Field_Number (name);
			if (existing != 0) goto field_error;

			str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer));
			if (buffer [0] == '\0' || buffer [0] == 'I') {
				type = INTEGER;
			} else if (buffer [0] == 'R' || buffer [0] == 'D') {
				type = DOUBLE;
			} else if (buffer [0] == 'S' || buffer [0] == 'C') {
				type = STRING;
			} else {
				goto data_error;
			}
			str_ptr = Get_Token (str_ptr, buffer);
			if (buffer [0] == '\0') {
				size = 10;
				if (type == DOUBLE) {
					decimal = 2;
				} else {
					decimal = 0;
				}
			} else {
				size = atoi (buffer);

				if (type == DOUBLE) {
					str_ptr = strchr (buffer, '.');
					if (str_ptr != NULL) {
						decimal = atoi (str_ptr+1);
					} else {
						decimal = 2;
					}
				} else {
					decimal = 0;
				}
			}
			output_file->Add_Field (name, type, size, decimal);
		}
	}
	if (copy_flag && output_file->Notes_Flag ()) {
		if (output_file->Field_Number ("NOTES") == 0) {
			output_file->Add_Field ("NOTES", STRING, FIELD_BUFFER);
		}
	}
	output_file->Write_Header ();
	
	//---- check for data files ----

	num_data_files = Highest_Control_Group (DATA_FILE_x, 0);

	if (num_data_files == 0) {
		if (Get_Control_String (DATA_FILE) != NULL) {
			num_data_files = 1;
		}
	} else {
		num_data_files++;
	}
	if (num_data_files > 0) {
		data_flag = true;
	}

	//---- check for polygon files ----

	num_polygons = Highest_Control_Group (BOUNDARY_POLYGON_x, 0);

	if (num_polygons == 0) {
		if (Get_Control_String (BOUNDARY_POLYGON) != NULL) {
			num_polygons = 1;
		}
	} else {
		num_polygons++;
	}
	if (num_polygons > 0) {
		polygon_flag = true;
	}

	//---- read conversion script ----

	str_ptr = Get_Control_String (CONVERSION_SCRIPT);

	if (str_ptr == NULL) {
		if (data_flag || polygon_flag) {
			Error ("A Convertion Script is needed for Data Processing");
		}
	} else {
		script_flag = true;
		Print (1);
		program_file.File_Type ("Conversion Script");
		program_file.Open (Project_Filename (str_ptr));
		Print (1);
	}

	//---- read data files ----

	if (data_flag) {

		//---- allocate data files ----

		data_files = new Db_Header * [num_data_files];
		data_field = new int [num_data_files];
		zone_field = new int [num_data_files];

		if (data_files == NULL || data_field == NULL || zone_field == NULL) {
			Error ("Insufficient Memory for %d Data Files", num_data_files);
		}
		memset (data_files, '\0', num_data_files * sizeof (Db_Header *));
		memset (data_field, '\0', num_data_files * sizeof (int));
		memset (zone_field, '\0', num_data_files * sizeof (int));

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

		for (i=0; i < num_data_files; i++) {
			if (i == 0) {
				str_ptr = Get_Control_String (DATA_FILE);
			} else {
				str_ptr = Get_Control_String (DATA_FILE_x, i);
			}
			if (str_ptr == NULL) continue;

			//---- create a header file and file labels ----

			Print (1);
			data_files [i] = file = new Db_Header ();

			if (i == 0) {
				file->File_Type ("Data File");
				file->File_ID ("Data");
				format_ptr = Get_Control_String (DATA_FORMAT);
			} else {
				str_fmt (buffer, sizeof (buffer), "Data File #%d", i);
				file->File_Type (buffer);

				str_fmt (buffer, sizeof (buffer), "Data%d", i);
				file->File_ID (buffer);

				format_ptr = Get_Control_String (DATA_FORMAT_x, i);
			}

			//---- open the file ----

			if (format_ptr != NULL) {
				file->Dbase_Format (format_ptr);
			}
			file->Open (Project_Filename (str_ptr));

			//---- find the data join field ----

			if (i == 0) {
				str_ptr = Get_Control_String (DATA_JOIN_FIELD);
			} else {
				str_ptr = Get_Control_String (DATA_JOIN_FIELD_x, i);
			}
			if (str_ptr == NULL) goto control_error;

			data_field [i] = file->Field_Number (str_ptr);

			if (data_field [i] == 0) {
				Error ("Data Join Field %s was Not Found", str_ptr);
			}
			if (i == 0) {
				Print (1, "Data Join Field = %s, Number = %d", str_ptr, data_field [i]);
			} else {
				Print (1, "Data Join Field #%d = %s, Number = %d", i, str_ptr, data_field [i]);
			}

			//---- find the zone join field ----

			if (i == 0) {
				str_ptr = Get_Control_String (ZONE_JOIN_FIELD);
			} else {
				str_ptr = Get_Control_String (ZONE_JOIN_FIELD_x, i);
			}
			if (str_ptr == NULL) goto control_error;

			zone_field [i] = input_file->Field_Number (str_ptr);

			if (zone_field [i] == 0) {
				Error ("Zone Join Field %s was Not Found", str_ptr);
			}
			if (i == 0) {
				Print (1, "Zone Join Field = %s, Number = %d", str_ptr, zone_field [i]);
			} else {
				Print (1, "Zone Join Field #%d = %s, Number = %d", i, str_ptr, zone_field [i]);
			}
		}
	}

	//---- read the boundary polygons ----

	if (polygon_flag) {
		Arcview_File *poly_file;

		projection.Read_Control ();

		//---- allocate data files ----

		polygon_files = new Arcview_File * [num_polygons];
		polygons = new Index_Array * [num_polygons];
		polygon_db = new Db_Index_Array * [num_polygons];

		if (polygon_files == NULL || polygons == NULL || polygon_db == NULL) {
			Error ("Insufficient Memory for %d Polygon Files", num_polygons);
		}
		memset (polygon_files, '\0', num_polygons * sizeof (Arcview_File *));
		memset (polygons, '\0', num_polygons * sizeof (Index_Array *));
		memset (polygon_db, '\0', num_polygons * sizeof (Db_Index_Array *));

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

		for (i=0; i < num_polygons; i++) {
			if (i == 0) {
				str_ptr = Get_Control_String (BOUNDARY_POLYGON);
			} else {
				str_ptr = Get_Control_String (BOUNDARY_POLYGON_x, i);
			}
			if (str_ptr == NULL) continue;

			//---- open the file ----

			polygon_files [i] = poly_file = new Arcview_File ();
			polygons [i] = new Index_Array (sizeof (Boundary));

			poly_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ());

			Print (1);
			if (i == 0) {
				poly_file->File_Type ("Boundary Polygon File");
				poly_file->File_ID ("Polygon");
			} else {
				str_fmt (buffer, sizeof (buffer), "Boundary Polygon File #%d", i);
				poly_file->File_Type (buffer);

				str_fmt (buffer, sizeof (buffer), "Polygon%d", i);
				poly_file->File_ID (buffer);
			}
			poly_file->Open (Project_Filename (str_ptr));
		}
	}
	Show_Message (1);
	return;

control_error:
	Error ("Missing Control Key = %s", Current_Key ());

data_error:
	Error ("New Zone Field %d is Improperly Specified", i);

field_error:
	Error ("New Zone Field %s already exists as Field %d", name, existing);
}
Пример #5
0
void LineSum::Compare (void)
{
	int mode;
	Dtime time;
	Db_Header *fh;
	File_Itr file_itr;
	Sort_Key sort_key;

	Route_Data route_rec, *base_ptr, *alt_ptr;
	Route_Map_Itr route_itr, base_itr;
	Route_Map_Stat route_stat;
	Route_Map base_map, alt_map;

	//---- compare files ----

	Show_Message ("Reading Base Route Files -- Record");
	Set_Progress ();

	for (mode=1, file_itr = base_routes.begin (); file_itr != base_routes.end (); file_itr++, mode++) {
		fh = *file_itr;

		while (fh->Read ()) {
			Show_Progress ();

			sort_key.mode = (short) mode;	//(short) fh->Get_Integer ("MODE");
			sort_key.leg = (short) 1;
			sort_key.name = fh->Get_String ("NAME");

			time = fh->Get_Time ("HEADWAY1");
			route_rec.headway1 = (int) time.Minutes ();

			time = fh->Get_Time ("HEADWAY2");
			route_rec.headway2 = (int) time.Minutes ();

			time = fh->Get_Time ("TTIME1");
			route_rec.ttime1 = (int) time.Minutes ();

			time = fh->Get_Time ("TTIME2");
			route_rec.ttime2 = (int) time.Minutes ();

			route_rec.nodes = fh->Get_Integer ("NODES");
			route_rec.notes = fh->Get_String ("NOTES");
			route_rec.match = 0;

			route_stat = base_map.insert (Route_Map_Data (sort_key, route_rec));
			if (!route_stat.second) {
				sort_key.leg = (short) 2;
				route_stat = base_map.insert (Route_Map_Data (sort_key, route_rec));
			}
		}
	}
	End_Progress ();

	//---- compare files ----

	Show_Message ("Reading Alternative Route Files -- Record");
	Set_Progress ();
	
	New_Page ();
	Header_Number (DIFFERENCE_REPORT);
	Compare_Header ();

	for (mode=1, file_itr = alt_routes.begin (); file_itr != alt_routes.end (); file_itr++, mode++) {
		fh = *file_itr;

		while (fh->Read ()) {
			Show_Progress ();

			sort_key.mode = (short) mode;	//(short) fh->Get_Integer ("MODE");
			sort_key.leg = (short) 1;
			sort_key.name = fh->Get_String ("NAME");

			time = fh->Get_Time ("HEADWAY1");
			route_rec.headway1 = (int) time.Minutes ();

			time = fh->Get_Time ("HEADWAY2");
			route_rec.headway2 = (int) time.Minutes ();

			time = fh->Get_Time ("TTIME1");
			route_rec.ttime1 = (int) time.Minutes ();

			time = fh->Get_Time ("TTIME2");
			route_rec.ttime2 = (int) time.Minutes ();

			route_rec.nodes = fh->Get_Integer ("NODES");
			route_rec.notes = fh->Get_String ("NOTES");

			route_rec.match = 0;

			route_stat = alt_map.insert (Route_Map_Data (sort_key, route_rec));
			if (!route_stat.second) {
				sort_key.leg = (short) 2;
				route_stat = alt_map.insert (Route_Map_Data (sort_key, route_rec));
			}
		}
	}
	End_Progress ();

	for (route_itr = alt_map.begin (); route_itr != alt_map.end (); route_itr++) {
		sort_key = route_itr->first;
		alt_ptr = &route_itr->second;

		base_itr = base_map.find (route_itr->first);

		if (base_itr == base_map.end ()) {
			Print (1, String ("%3d   %-12.12s") % sort_key.mode % sort_key.name);
			Print (0, String ("  %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d    %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d  ") %
				0 % 0 % 0 % 0 % 0 %
				alt_ptr->headway1 % alt_ptr->ttime1 % alt_ptr->headway2 % alt_ptr->ttime2 % alt_ptr->nodes);
			Print (0, alt_ptr->notes);
		} else {
			base_ptr = &base_itr->second;
			base_ptr->match = 1;

			if (base_ptr->headway1 != alt_ptr->headway1 || base_ptr->headway2 != alt_ptr->headway2 ||
				base_ptr->ttime1 != alt_ptr->ttime1 || base_ptr->ttime2 != alt_ptr->ttime2 ||
				base_ptr->nodes != alt_ptr->nodes) {

				Print (1, String ("%3d   %-12.12s") % sort_key.mode % sort_key.name);
				Print (0, String ("  %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d    %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d  ") %
					base_ptr->headway1 % base_ptr->ttime1 % base_ptr->headway2 % base_ptr->ttime2 % base_ptr->nodes %
					alt_ptr->headway1 % alt_ptr->ttime1 % alt_ptr->headway2 % alt_ptr->ttime2 % alt_ptr->nodes);
				Print (0, base_ptr->notes);
			}
		}
	}

	for (base_itr = base_map.begin (); base_itr != base_map.end (); base_itr++) {
		if (base_itr->second.match == 0) {
			sort_key = base_itr->first;
			base_ptr = &base_itr->second;

			Print (1, String ("%3d   %-12.12s") % sort_key.mode % sort_key.name);
			Print (0, String ("  %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d    %6.1lf   %6.1lf   %6.1lf   %6.1lf  %5d  ") %
				base_ptr->headway1 % base_ptr->ttime1 % base_ptr->headway2 % base_ptr->ttime2 % base_ptr->nodes %
				0 % 0 % 0 % 0 % 0);
			Print (0, base_ptr->notes);
		}
	}
	Header_Number (0);
}
Пример #6
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));
		}
	}
}
Пример #7
0
void LineSum::Combine (int period, File_List &list, Db_Header &output)
{
	int i, j, num_out, node, vol;
	String name, name_key;
	double freq;
	bool stat;
	Db_Header *fh;
	File_Itr file_itr;
	Sort_Key sort_key;
	Leg_Data leg_data;
	Line_Map_Stat map_stat;
	On_Off_Data on_off_data;
	Access_Key access_key;
	Access_Map_Stat access_stat;
	On_Off_Key on_off_key;
	On_Off_Map_Stat on_off_stat;
	Line_Map *map;
	Str_ID_Itr service_itr;

	if (list.size () == 0) return;

	if (period == 0) {
		name = "Peak";
		map = &peak_map;
	} else if (period == 1) {
		name = "Offpeak";
		map = &offpeak_map;
	} else {
		name = "Total";
		map = 0;
	}
	Show_Message (String ("Reading %s Ridership Files -- Record") % name);
	Set_Progress ();
	num_out = 0;

	memset (&on_off_data, '\0', sizeof (on_off_data));

	if (list.size () == 1) {
		fh = *list.begin ();

		while (fh->Read ()) {
			Show_Progress ();

			//---- copy fields to the output file ----

			if (output.Is_Open ()) {
				output.Copy_Fields (*fh);
				output.Write ();
			}

			//---- save the data to the line map ----

			if (map == 0) continue;

			name = fh->Get_String ("NAME");
			name.Trim ();
			if (name.Ends_With ("-")) continue;

			if (name [0] == '*') {
				if (access_flag) {
					vol = fh->Get_Integer ("AB_VOL");
					if (vol == 0) continue;

					access_key.stop = fh->Get_Integer ("A");
					access_key.mode = fh->Get_Integer ("MODE");
					access_key.node = fh->Get_Integer ("B");

					access_stat = access_map.insert (Access_Map_Data (access_key, on_off_data));

					if (period == 0) {
						access_stat.first->second.pk_off += vol;
					} else {
						access_stat.first->second.op_off += vol;
					}
					node = access_key.node;
					access_key.node = access_key.stop;
					access_key.stop = node;

					access_stat = access_map.insert (Access_Map_Data (access_key, on_off_data));

					if (period == 0) {
						access_stat.first->second.pk_on += vol;
					} else {
						access_stat.first->second.op_on += vol;
					}
				}
				continue;
			}
			sort_key.mode = (short) fh->Get_Integer ("MODE");
			sort_key.name = name;
			sort_key.leg = (short) fh->Get_Integer ("SEQ");

			if (fh->Get_Integer ("STOP_A") == 0) {
				leg_data.a = -fh->Get_Integer ("A");;
			} else {
				leg_data.a = fh->Get_Integer ("A");;
			}
			if (fh->Get_Integer ("STOP_B") == 0) {
				leg_data.b = -fh->Get_Integer ("B");;
			} else {
				leg_data.b = fh->Get_Integer ("B");;
			}
			leg_data.time = (short) fh->Get_Integer ("TIME");
			leg_data.dist = (short) fh->Get_Integer ("DIST");
			freq = fh->Get_Double ("FREQ");
			if (freq > 0.0) {
				leg_data.runs = 60.0 / freq;
			} else {
				leg_data.runs = 0.0;
			}
			leg_data.ab.ride = fh->Get_Integer ("AB_VOL");
			leg_data.ab.on = fh->Get_Integer ("AB_BRDA");
			leg_data.ab.off = fh->Get_Integer ("AB_XITB");
			leg_data.ba.ride = fh->Get_Integer ("BA_VOL");
			leg_data.ba.on = fh->Get_Integer ("BA_BRDB");
			leg_data.ba.off = fh->Get_Integer ("BA_XITA");

			if (service_flag && period < 2) {
				name_key = name;
				name_key.To_Upper ();

				service_itr = service_map.find (name_key);
				if (service_itr != service_map.end ()) {
					if (period == 0) {
						leg_data.service = service_itr->second >> 16;
					} else {
						leg_data.service = service_itr->second & 0xFFFF;
					}
				}