Exemplo n.º 1
0
void RiderSum::Group_Rider_Report (void)
{
	int n, run, runs, num, length, tot_len, period, num_periods, routes, index, stop, to, link;
	int max_riders, max_board, max_alight, max_runs, total;
	double factor, max_fac, sum_time, tot_time, time;
	double vmt, vht, pmt, pht;
	Dtime low, high;
	String label;
	bool flag;

	Int_Set *group;
	Int_Set_Itr itr;
	Int_Map_Itr map_itr, to_itr;
	Line_Data *line_ptr;
	Stop_Data *stop_ptr;
	Line_Stop_Itr stop_itr, next_itr;
	Line_Run_Itr run_itr;
	Int_Map stop_index;
	Int2_Map link_index;
	Int2_Map_Itr map2_itr;
	Int2_Key int2_key;
	Int2_Map_Stat map2_stat;
	Int_Map_Stat map_stat;
	Stop_Group_Data data, *data_ptr, *link_ptr;
	Stop_Group_Itr data_itr;

	Show_Message ("Line Group Profile -- Record");
	Set_Progress ();

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

	Header_Number (GROUP_RIDERS);

	num_periods = sum_periods.Num_Periods ();
	if (num_periods == 0) num_periods = 1;

	num = (int) (line_map.size () * stop_map.size ());

	if (!Break_Check (num + 5)) {
		Print (1);
		Group_Rider_Header ();
	}

	routes = 0;
	memset (&data, '\0', sizeof (data));
	
	for (n = line_equiv.First_Group (); n > 0; n = line_equiv.Next_Group ()) {

		group = line_equiv.Group_List (n);
		if (group == 0) continue;

		label = line_equiv.Group_Label (n);

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

		for (period = 0; period < num_periods; period++) {

			//---- initialize stop data ----

			stop_index.clear ();
			link_index.clear ();
			stop_group_array.clear ();
			routes = 0;
			vmt = vht = pmt = pht = 0.0;

			//---- process each line in the line group ----

			for (itr = group->begin (); itr != group->end (); itr++) {

				map_itr = line_map.find (*itr);
				if (map_itr == line_map.end ()) continue;

				Show_Progress ();

				line_ptr = &line_array [map_itr->second];

				//---- set the run flags ----

				if (!Run_Selection (line_ptr)) continue;

				if (period_flag [period] == 0) continue;

				time = 0.0;
				total = length = 0;
				flag = false;

				sum_periods.Period_Range (period, low, high);

				for (stop_itr = line_ptr->begin (); stop_itr != line_ptr->end (); stop_itr++) {

					stop_ptr = &stop_array [stop_itr->Stop ()];
					stop = stop_ptr->Stop ();

					map_itr = stop_index.find (stop);

					next_itr = stop_itr + 1;

					if (next_itr != line_ptr->end ()) {
						stop_ptr = &stop_array [next_itr->Stop ()];

						to = stop_ptr->Stop ();
					} else {
						to = 0;
					}

					//---- create the link ----

					int2_key = Int2_Key (stop, to);

					map2_itr = link_index.find (int2_key);

					if (map2_itr == link_index.end ()) {
						if (to == 0 && map_itr != stop_index.end ()) {
							link = map_itr->second;
						} else {
							link = (int) stop_group_array.size ();

							link_index.insert (Int2_Map_Data (int2_key, link));

							data.stop = stop;
							data.to = to;
							stop_group_array.push_back (data);

							//---- check for a merge ----

							if (to != 0) {
								to_itr = stop_index.find (to);

								if (to_itr != stop_index.end ()) {
									index = (int) stop_group_array.size ();

									int2_key = Int2_Key (to, 0);

									map2_stat = link_index.insert (Int2_Map_Data (int2_key, index));

									if (map2_stat.second) {
										data.stop = to;
										data.to = 0;
										stop_group_array.push_back (data);
									}
								}
							}
						}
					} else {
						link = map2_itr->second;
					}
					link_ptr = &stop_group_array [link];

					//---- crete the stop index ----

					if (map_itr == stop_index.end ()) {
						map_stat = stop_index.insert (Int_Map_Data (stop, link));
						index = link;
					} else {
						index = map_itr->second;
					}
					data_ptr = &stop_group_array [index];

					if (next_itr != line_ptr->end ()) {
						length = next_itr->Length () - stop_itr->Length ();
					} else {
						length = 0;
					}
					sum_time = 0.0;
					num = runs = 0;

					for (run=0, run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++, run++) {
						if (run_flag [run] == 0) continue;
						if (run_period [run] != period) continue;

						data_ptr->board += run_itr->Board ();
						data_ptr->alight += run_itr->Alight ();
						link_ptr->riders += run_itr->Load ();
						runs++;
						flag = true;

						if (next_itr != line_ptr->end ()) {
							link_ptr->runs++;
							time = next_itr->at (run).Schedule ().Seconds () - run_itr->Schedule ().Seconds ();
							sum_time += time;
							num++;

							vmt += length;
							vht += time;
							pmt += length * run_itr->Load ();
							pht += time * run_itr->Load ();
						}
					}
					if (runs == 0) continue;

					if (link_ptr->length == 0.0) {
						link_ptr->length = length;
					}
					if (num > 0) {
						time = sum_time / num;
					} else {
						time = 0;
					}
					if (link_ptr->time > 0) {
						link_ptr->time = (link_ptr->time + time) / 2.0;
					} else {
						link_ptr->time = time;
					}
				}
				if (flag) routes++;
			}

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

			if (!Break_Check ((int) stop_index.size () + 15)) {
				Print (1);
				Group_Rider_Header ();
			}
			Print (1, "Group   Time Period  Routes  Description");

			Print (2, String ("%5d  %12.12s  %6d  %s") % n %	sum_periods.Range_Format (period) %
				routes % label);

			Print (2, "    Stop  Length   TTime   Alight    Board   Riders  Runs  LoadFac");
			Print (1);

			tot_time = 0.0;
			max_alight = max_board = max_riders = max_runs = total = tot_len = 0;
			max_fac = 0.0;

			for (data_itr = stop_group_array.begin (); data_itr != stop_group_array.end (); data_itr++) {

				map_itr = stop_map.find (data_itr->stop);
					
				stop_ptr = &stop_array [map_itr->second];
				
				if (data_itr->runs > 0) {
					factor = DTOI (data_itr->riders * 10.0 / data_itr->runs) / 10.0;
				} else {
					factor = 0.0;
				}
				Print (1, String ("%8d %7.0lf %7.0lf %8d %8d %8d %5d %8.1lf") % data_itr->stop  % 
					UnRound (data_itr->length) % data_itr->time % data_itr->alight % data_itr->board % 
					data_itr->riders % data_itr->runs % factor);

				if (Notes_Name_Flag ()) {
					if (!stop_ptr->Name ().empty ()) {
						Print (0, String ("  %s") % stop_ptr->Name ());
					}
					if (!stop_ptr->Notes ().empty ()) {
						Print (0, " -- ") << stop_ptr->Notes ();
					}
				}
				if (data_itr->alight > max_alight) max_alight = data_itr->alight;
				if (data_itr->board > max_board) max_board = data_itr->board;
				if (data_itr->riders > max_riders) max_riders = data_itr->riders;
				if (data_itr->runs > max_runs) max_runs = data_itr->runs;
				if (factor > max_fac) max_fac = factor;

				tot_len += data_itr->length;
				tot_time += data_itr->time;
				total += data_itr->board;
			}
			if (max_runs == 0) continue;

			Print (2, String (" Maximum                 %8ld %8ld %8ld %5ld %8.1lf") %
				max_alight % max_board % max_riders % max_runs % max_fac);

			Print (2, "Total Boardings = ") << total;

			if (total == 0 || tot_time == 0) continue;

			factor = UnRound (tot_len);
			vmt = UnRound (vmt) / 5280.0;
			vht = vht / 3600.0;
			pmt = UnRound (pmt) / 5280.0;
			pht = pht / 3600.0;


			Print (1, String ("Route Length = %.1lf miles, %.1lf minutes  Average Speed = %.1lf mph") %
				External_Units (factor, MILES) % (tot_time / 60.0) % External_Units ((factor / tot_time), MPH));
			Print (1, String ("Vehicle Miles = %.1lf  Vehicle Hours = %.1lf") % vmt % vht);
			Print (1, String ("Passenger Miles = %.1lf  Passenger Hours = %.1lf") %	pmt % pht);
			Print (1, String ("Passengers per Vehicle Mile = %.1lf  Passengers per Vehicle Hour = %.1lf") %	
				(pmt / vht) % (pht / vht));

			vmt = pmt / total;
			vht = pht * 60.0 / total;

			Print (1, String ("Average Trip Length = %.1lf miles, %.1lf minutes") % vmt % vht);
		}
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 2
0
void PlanSum::Rider_Group (void)
{
	int i, j, num, dir, length, link, previous_period, period, dir_index, periods;
	String label;
	bool flag;

	Int_Set *group;
	Int_Set_Itr link_itr;
	Line_Itr line_itr;
	Line_Stop_Itr stop_itr;
	Line_Run_Itr run_itr;
	Driver_Array *driver_ptr;
	Driver_Itr driver_itr;
	Link_Data *link_ptr;
	Dir_Data *dir_ptr;

	Group_Data group_data, *group_ptr;
	Group_Array group_array;
	Group_Itr group_itr;

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

	periods = sum_periods.Num_Periods ();
	if (periods < 1) periods= 1;

	Show_Message ("Writing Transit Link Groups -- Record");
	Set_Progress ();

	//---- find each link group ----

	num = link_equiv.Num_Groups ();

	Header_Number (RIDER_GROUP);

	if (!Break_Check (num + 7)) {
		Print (1);
		Rider_Header ();
	}
	num = link_equiv.Max_Group ();

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

		group = link_equiv.Group_List (i);
		if (group == 0) continue;

		group_array.assign (periods, group_data);

		label = link_equiv.Group_Label (i);

		flag = false;
		memset (&group_data, '\0', sizeof (group_data));

		//---- write data for each line ----

		for (line_itr = line_array.begin (); line_itr != line_array.end (); line_itr++) {
			Show_Progress ();

			driver_ptr = &line_itr->driver_array;

			//---- process each link in the link group ----

			for (link_itr = group->begin (); link_itr != group->end (); link_itr++) {
				link = *link_itr;
				if (link < 0) {
					link = -link;
					dir = 1;
				} else {
					dir = 0;
				}
				link_ptr = &link_array [link];
				dir_index = (dir == 0) ? link_ptr->AB_Dir () : link_ptr->BA_Dir ();

				//---- search for the link on the route ----

				length = 0;

				for (driver_itr = driver_ptr->begin (); driver_itr != driver_ptr->end (); driver_itr++) {
					dir_ptr = &dir_array [*driver_itr];
					link_ptr = &link_array [dir_ptr->Link ()];

					if (*driver_itr == dir_index) {
						length += link_ptr->Length () / 2;
						break;
					}
					length += link_ptr->Length ();
				}

				for (stop_itr = line_itr->begin (); stop_itr != line_itr->end (); stop_itr++) {
					if (stop_itr->Length () > length) {
						if (stop_itr > line_itr->begin ()) {
							stop_itr--;
							previous_period = -1;

							for (run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++) {
								period = sum_periods.Period (run_itr->Schedule ());
								if (period < 0) continue;

								group_ptr = &group_array [period];

								if (period != previous_period) {
									previous_period = period;
									group_ptr->lines++;
								}
								group_ptr->runs++;
								group_ptr->riders += run_itr->Load ();
							}
						}
						flag = true;
						break;
					}
				}
			}
		}
		if (!flag) continue;

		//---- print the link group data ----

		flag = true;

		for (j=0, group_itr = group_array.begin (); group_itr != group_array.end (); group_itr++, j++) {
			if (group_itr->lines == 0) continue;

			if (flag) {
				Print (1, String ("%3d %-40.40s") % i % label);
				flag = false;
			} else {
				Print (1, String ("%44c") % BLANK);
			}
			Print (0, String ("%5d %6d  %12.12s  %7d") %
				group_itr->lines % group_itr->runs %  
				sum_periods.Range_Format (j) % group_itr->riders);
		}
		if (j > 1) Print (1);
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 3
0
void PlanSum::Link_Group (double min_vc)
{
	int i, num, dir, link, cap, tod_cap, tod_cap2, lns, lanes, period, periods, index, flow_index;
	Dtime low, high;
	double flow, vc;
    string label;
	bool flag;

	Flow_Time_Period_Itr array_itr;
	Dir_Data *dir_ptr;
	Link_Data *link_ptr;
	Lane_Use_Period *period_ptr;
	Int_Set *list;
	Int_Set_Itr list_itr;
	Int_Map_Itr int_itr;

	Group_Array group_array;
	Group_Data zero, *data_ptr;

	memset (&zero, '\0', sizeof (zero));
	periods = sum_periods.Num_Periods ();

	Show_Message ("Writing the Link Group Report -- Record");
	Set_Progress ();

	minimum_vc = min_vc;

	//---- find V/C ratios for each link group ----

	num = link_equiv.Num_Groups ();

	Header_Number (LINK_GROUP);

	if (!Break_Check (num + 7)) {
		Print (1);
		Link_Group_Header ();
	}
	num = link_equiv.Max_Group ();

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

		list = link_equiv.Group_List (i);
		if (list == 0) continue;

		label = link_equiv.Group_Label (i);

		flag = false;
		group_array.assign (periods, zero);

		//---- process each link in the link group ----

		for (list_itr = list->begin (); list_itr != list->end (); list_itr++) {

			link = abs (*list_itr);
			
			int_itr = link_map.find (link);
			if (int_itr == link_map.end ()) continue;

			link_ptr = &link_array [int_itr->second];

			if (*list_itr < 0) {
				dir = link_ptr->BA_Dir ();
			} else {
				dir = link_ptr->AB_Dir ();
			}
			if (dir < 0) continue;
			
			//---- get the directional data ----

			dir_ptr = &dir_array [dir];

			cap = (int) (dir_ptr->Capacity () * cap_factor + 0.5);
			if (cap <= 0) continue;

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

			flow_index = dir_ptr->Flow_Index ();

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

			for (period=0, array_itr = link_delay_array.begin (); array_itr != link_delay_array.end (); array_itr++, period++) {
				flow = array_itr->Flow (dir);

				//---- time-of-day capacity ----

				tod_cap = tod_cap2 = cap;
				index = dir_ptr->First_Lane_Use ();

				if (index >= 0) {
					sum_periods.Period_Range (period, low, high);
					low = (low + high) / 2;

					for (period_ptr = &use_period_array [index]; ; period_ptr = &use_period_array [++index]) {
						if (period_ptr->Start () <= low && low < period_ptr->End ()) {
							lns = period_ptr->Lanes (0);
							tod_cap = (tod_cap * lns + lanes / 2) / lanes;
							if (tod_cap == 0) tod_cap = cap / 2;

							lns = period_ptr->Lanes (1);
							tod_cap2 = (tod_cap2 * lns + lanes / 2) / lanes;
							if (tod_cap2 == 0) tod_cap2 = cap / 2;
							break;
						}
						if (period_ptr->Periods () == 0) break;
					}
				}
				if (tod_cap > 0) {
					data_ptr = &group_array [period];

					flag = true;
					data_ptr->links++;
					data_ptr->volume += DTOI (flow);
					data_ptr->capacity += tod_cap;

					if (flow_index >= 0 && tod_cap2 > 0) {
						flow = array_itr->Flow (flow_index);

						data_ptr->volume += DTOI (flow);
						data_ptr->capacity += tod_cap2;
					}
				}
			}
		}
		if (!flag) continue;

		//---- print the link group data ----

		flag = true;

		for (period=0; period < periods; period++) {
			data_ptr = &group_array [period];

			if (data_ptr->capacity <= 0) continue;

			vc = (double) data_ptr->volume / data_ptr->capacity;

			if (vc > min_vc) {
				Show_Progress ();

				//---- print the data record ----

				if (flag) {
					flag = false;
					Print (1, label);
				}
				Print (1, String ("%20c%5d   %7d  %12.12s  %7d   %6.2lf") %
					BLANK % data_ptr->links % data_ptr->capacity % 
					sum_periods.Range_Format (period) % data_ptr->volume % vc);
			}
		}
	}
	End_Progress ();

	if (Progress_Count () > 0) {
		Print (2, "Number of Records in the Report = ") << Progress_Count ();
	}
	Header_Number (0);
}
Exemplo n.º 4
0
void RiderSum::Write_Group_Rider (void)
{
	int n, run, runs, num, length, period, num_periods, routes, index, stop, to, link, capacity;
	double factor, sum_time, time, capfac;
	Dtime low, high;
	String label;
	bool flag;
	
	Int_Set *group;
	Int_Set_Itr itr;
	Int_Map_Itr map_itr, to_itr;
	Line_Data *line_ptr;
	Stop_Data *stop_ptr;
	Line_Stop_Itr stop_itr, next_itr;
	Line_Run_Itr run_itr;
	Int_Map stop_index;
	Int2_Map link_index;
	Int2_Map_Itr map2_itr;
	Int2_Key int2_key;
	Int2_Map_Stat map2_stat;
	Int_Map_Stat map_stat;
	Stop_Group_Data data, *data_ptr, *link_ptr;
	Stop_Group_Itr data_itr;
	Veh_Type_Data *veh_type_ptr, *run_type_ptr;

	fstream &file = line_group_file.File ();
	
	num_periods = sum_periods.Num_Periods ();
	if (num_periods == 0) num_periods = 1;

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

	file << "Group\tPeriod\tRoutes\tStops\tDescription\n";
	file << "Stop\tLength\tTTime\tAlight\tBoard\tRiders\tRuns\tLoadFac\tCapacity\tCapFac\tStopName\n";

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

	routes = 0;
	memset (&data, '\0', sizeof (data));
	
	for (n = line_equiv.First_Group (); n > 0; n = line_equiv.Next_Group ()) {

		group = line_equiv.Group_List (n);
		if (group == 0) continue;

		label = line_equiv.Group_Label (n);

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

		for (period = 0; period < num_periods; period++) {

			//---- initialize stop data ----

			stop_index.clear ();
			link_index.clear ();
			stop_group_array.clear ();
			routes = 0;

			//---- process each line in the line group ----

			for (itr = group->begin (); itr != group->end (); itr++) {

				map_itr = line_map.find (*itr);
				if (map_itr == line_map.end ()) continue;

				Show_Progress ();

				line_ptr = &line_array [map_itr->second];

				//---- set the run flags ----

				if (!Run_Selection (line_ptr)) continue;

				//---- check the period flag ----

				if (period_flag [period] == 0) continue;

				time = 0.0;
				length = 0;
				flag = false;
				veh_type_ptr = &veh_type_array [line_ptr->Type ()];

				sum_periods.Period_Range (period, low, high);

				for (stop_itr = line_ptr->begin (); stop_itr != line_ptr->end (); stop_itr++) {
					
					stop_ptr = &stop_array [stop_itr->Stop ()];
					stop = stop_ptr->Stop ();

					map_itr = stop_index.find (stop);

					next_itr = stop_itr + 1;

					if (next_itr != line_ptr->end ()) {
						stop_ptr = &stop_array [next_itr->Stop ()];

						to = stop_ptr->Stop ();
					} else {
						to = 0;
					}

					//---- create the link ----

					int2_key = Int2_Key (stop, to);

					map2_itr = link_index.find (int2_key);

					if (map2_itr == link_index.end ()) {
						if (to == 0 && map_itr != stop_index.end ()) {
							link = map_itr->second;
						} else {
							link = (int) stop_group_array.size ();

							link_index.insert (Int2_Map_Data (int2_key, link));

							data.stop = stop;
							data.to = to;
							stop_group_array.push_back (data);

							//---- check for a merge ----

							if (to != 0) {
								to_itr = stop_index.find (to);

								if (to_itr != stop_index.end ()) {
									index = (int) stop_group_array.size ();

									int2_key = Int2_Key (to, 0);

									map2_stat = link_index.insert (Int2_Map_Data (int2_key, index));

									if (map2_stat.second) {
										data.stop = to;
										data.to = 0;
										stop_group_array.push_back (data);
									}
								}
							}
						}
					} else {
						link = map2_itr->second;
					}
					link_ptr = &stop_group_array [link];

					//---- crete the stop index ----

					if (map_itr == stop_index.end ()) {
						map_stat = stop_index.insert (Int_Map_Data (stop, link));
						index = link;
					} else {
						index = map_itr->second;
					}
					data_ptr = &stop_group_array [index];

					if (next_itr != line_ptr->end ()) {
						length = next_itr->Length () - stop_itr->Length ();
					} else {
						length = 0;
					}
					sum_time = 0.0;
					num = runs = 0;

					for (run=0, run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++, run++) {
						if (run_flag [run] == 0) continue;
						if (run_period [run] != period) continue;

						data_ptr->board += run_itr->Board ();
						data_ptr->alight += run_itr->Alight ();
						link_ptr->riders += run_itr->Load ();
						runs++;
						flag = true;

						if (next_itr != line_ptr->end ()) {
							if (line_ptr->run_types.size () > 0) {
								run_type_ptr = &veh_type_array [line_ptr->Run_Type (run)];
								capacity = run_type_ptr->Capacity ();
							} else {
								capacity = veh_type_ptr->Capacity ();
							}
							link_ptr->runs++;
							link_ptr->capacity += capacity;
							time = next_itr->at (run).Schedule ().Seconds () - run_itr->Schedule ().Seconds ();
							sum_time += time;
							num++;
						}
					}
					if (runs == 0) continue;
						
					if (link_ptr->length == 0.0) {
						link_ptr->length = length;
					}
					if (num > 0) {
						time = sum_time / num;
					} else {
						time = 0;
					}
					if (link_ptr->time > 0) {
						link_ptr->time = (link_ptr->time + time) / 2.0;
					} else {
						link_ptr->time = time;
					}
				}
				if (flag) routes++;
			}
			file << n << "\t" << sum_periods.Range_Format (period) << "\t" << routes << "\t" << stop_index.size () << "\t" << label << "\n";

			for (data_itr = stop_group_array.begin (); data_itr != stop_group_array.end (); data_itr++) {

				map_itr = stop_map.find (data_itr->stop);
					
				stop_ptr = &stop_array [map_itr->second];
				
				if (data_itr->runs > 0) {
					factor = DTOI (data_itr->riders * 10.0 / data_itr->runs) / 10.0;
				} else {
					factor = 0;
				}
				if (data_itr->capacity > 0) {
					capfac = DTOI (data_itr->riders * 10.0 / data_itr->capacity) / 10.0;
				} else {
					capfac = 0;
				}
				file << data_itr->stop << "\t" << UnRound (data_itr->length) << "\t" << data_itr->time << "\t" <<
					data_itr->alight << "\t" << data_itr->board << "\t" << data_itr->riders << "\t" << 
					data_itr->runs << "\t" << factor << "\t" << data_itr->capacity << "\t" << capfac << "\t";

				if (Notes_Name_Flag ()) {
					file << stop_ptr->Name ();

					if (!stop_ptr->Notes ().empty ()) {
						file << " -- " << stop_ptr->Notes ();
					}
				}
				file << "\n";
			}
		}
	}
	End_Progress ();
	line_group_file.Close ();
}
Exemplo n.º 5
0
void ArcPlan::Write_Group (void)
{
	int i, num, board, alight, max_group;
	int group_field, board_field, alight_field, total_field, name_field;

	XYZ_Point pt;

	Int_Map_Itr map_itr;
	Point_Map_Itr pt_itr;
	Int_Set *group;
	Int_Set_Itr itr;

	group_field = arcview_group.Field_Number ("GROUP");
	name_field = arcview_group.Field_Number ("NAME");
	board_field = arcview_group.Field_Number ("BOARD");
	alight_field = arcview_group.Field_Number ("ALIGHT");
	total_field = arcview_group.Field_Number ("TOTAL");

	arcview_group.clear ();

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

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

	max_group = stop_equiv.Max_Group ();

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

		group = stop_equiv.Group_List (i);
		if (group == 0) continue;

		Show_Progress ();

		board = alight = num = 0;
		pt.x = pt.y = pt.z = 0.0;

		//---- sum the stops in the group ----

		for (itr = group->begin (); itr != group->end (); itr++) {

			pt_itr = stop_pt.find (*itr);
			if (pt_itr == stop_pt.end ()) continue;
			
			map_itr = stop_map.find (pt_itr->first);
			if (map_itr == stop_map.end ()) continue;

			pt.x += pt_itr->second.x;
			pt.y += pt_itr->second.y;
			pt.z += pt_itr->second.z;

			board += board_data [map_itr->second];
			alight += alight_data [map_itr->second];
			num++;
		}
		if (board <= 0 && alight <= 0) continue;

		//---- write the stop record ----

		pt.x = pt.x / num;
		pt.y = pt.y / num;
		pt.z = pt.z / num;

		arcview_group.Put_Field (group_field, i);
		arcview_group.Put_Field (name_field, stop_equiv.Group_Label (i));
		arcview_group.Put_Field (board_field, board);
		arcview_group.Put_Field (alight_field, alight);
		arcview_group.Put_Field (total_field, (board + alight));

		arcview_group.assign (1, pt);

		if (!arcview_group.Write_Record ()) {
			Error (String ("Writing %s") % arcview_group.File_Type ());
		}
		num_group++;
	}
	End_Progress ();

	arcview_group.Close ();
}
Exemplo n.º 6
0
void Validate::Link_Group_Stats (void)
{
	int i, n, lnk;
	String label;

	Group_Data *data;
	Group_Map_Itr map_itr;
	Statistics stats;
	Link_Data *link_ptr;
	Int_Set *list;
	Int_Set_Itr itr;
	Int_Map_Itr int_itr;

	for (i = 1; i <= link_equiv.Max_Group (); i++) {
		list = link_equiv.Group_List (i);

		if (list == 0) continue;

		for (itr = list->begin (); itr != list->end (); itr++) {
			lnk = *itr;
			int_itr = link_map.find (abs (lnk));
			if (int_itr == link_map.end ()) continue;

			link_ptr = &link_array [int_itr->second];

			if (lnk > 0 && link_ptr->AB_Dir () >= 0) {
				Sum_Group (i, link_ptr, link_ptr->AB_Dir ());
			} else if (lnk < 0 && link_ptr->BA_Dir () >= 0) {
				Sum_Group (i, link_ptr, link_ptr->BA_Dir ());
			}
		}
	}

	//---- print the page header ----
	
	Header_Number (LINK_GROUP);

	if (!Break_Check ((int) group_data.size () + 9)) {
		Print (1);
		Link_Group_Header ();
	}

	//---- print each link group ----

	for (map_itr = group_data.begin (); map_itr != group_data.end (); map_itr++) {
		data = &map_itr->second;
		n = data->number;
		if (n == 0) continue;
	
		Calc_Stats (data, stats);
		
		i = data->index;
		
		label = link_equiv.Group_Label (i);
		if (label.empty ()) {
			label = String ("Link Group %d") % i;
		}
		label = String ("%-25.25s") % label;
		Page_Check (1);
		Print (0, String (stats_format) % label % n % data->volume % data->count % 
			(data->volume - data->count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % data->max_vc);
	}
		
	//---- calculate the total statistics ----
	
	n = total.number;
	if (n > 0) {
		Calc_Stats (&total, stats);
		
		Page_Check (3);
		Print (0, "\n");
		label = String ("%-25.25s") % "TOTAL";
		Print (0, String (stats_format) % "TOTAL" % n % total.volume % total.count % 
			(total.volume - total.count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % total.max_vc);
		Print (0, "\n");
	}
	Header_Number (0);
}
Exemplo n.º 7
0
void LinkSum::Link_Group (double min_volume)
{
	int i, j, num, lnk, dir, link, use_index, group_num;
	String label;

	Link_Data *link_ptr;
	Perf_Period_Itr period_itr;
	Perf_Data perf_data;
	Int_Set *group;
	Int_Set_Itr itr;
	Int_Map_Itr map_itr;
	Doubles group_data;

	Show_Message ("Creating the Link Group Report -- Record");
	Set_Progress ();

	header_value = DTOI (min_volume);

	//---- find events for each link group ----

	num = link_equiv.Num_Groups ();

	Header_Number (LINK_GROUP);

	if (!Break_Check (num + 7)) {
		Print (1);
		Link_Group_Header ();
	}

	for (i = link_equiv.First_Group (); i > 0; i = link_equiv.Next_Group ()) {

		group = link_equiv.Group_List (i);
		if (group == 0) continue;

		label = link_equiv.Group_Label (i);

		group_num = 0;
		group_data.assign (num_inc, 0);

		//---- process each link in the link group ----

		for (itr = group->begin (); itr != group->end (); itr++) {

			link = *itr;
			lnk = abs (link);

			map_itr = link_map.find (lnk);
			if (map_itr == link_map.end ()) continue;

			link_ptr = &link_array [map_itr->second];

			if (link < 0) {
				dir = link_ptr->BA_Dir ();
			} else {
				dir = link_ptr->AB_Dir ();
			}
			if (dir < 0) continue;
			use_index = dir_array [dir].Use_Index ();

			group_num++;

			//---- get the directional data ----
		
			for (j=0, period_itr = perf_period_array.begin (); period_itr != perf_period_array.end (); period_itr++, j++) {
				perf_data = period_itr->Total_Performance (dir, use_index);

				group_data [j] += perf_data.Volume ();
			}
		}
		if (group_num == 0) continue;

		//---- print the link group data ----

		for (j=0; j < num_inc; j++) {
			if (group_data [j] < min_volume) continue;

			Show_Progress ();

			//---- print the data record ----

			Print (1, String ("%4d  %-40.40s  %5d  %12.12s%9d") % 
				i % label % group_num % sum_periods.Range_Format (j) % group_data [j]);
		}
	}
	End_Progress ();

	if (Progress_Count ()) {
		Print (2, "Number of Records in the Report = ") << Progress_Count ();
	}
	Header_Number (0);
}