Exemple #1
0
void TripSum::Write_Zones (void)
{
	int i, nrec;

	Point_Time_Data *end_ptr;

	Show_Message ("Writing %s -- Record", zone_end_file.File_Type ());
	Set_Progress (1000);

	//---- write each zone ----

	nrec = 0;

	for (end_ptr = zone_end_data.First_Key (); end_ptr; end_ptr = zone_end_data.Next_Key ()) {
		Show_Progress ();

		if (end_ptr->Periods () > 0) {
			zone_end_file.ID (end_ptr->ID ());

			for (i=1; i <= num_inc; i++) {
				zone_end_file.Total_In (i, end_ptr->In (i));
				zone_end_file.Total_Out (i, end_ptr->Out (i));
			}
			if (!zone_end_file.Write ()) {
				Error ("Writing %s", zone_end_file.File_Type ());
			}
			nrec++;
		}
	}
	End_Progress ();

	Print (2, "Number of %s Records = %d", zone_end_file.File_Type (), nrec);

	zone_end_file.Close ();
}
Exemple #2
0
void LocationData::Read_Boundary (void)
{
	int zone;
	Points_Map_Stat map_stat;

	//---- read zone polygons----

	Show_Message (String ("Reading %s -- Record") % boundary_file.File_Type ());
	Set_Progress ();

	while (boundary_file.Read_Record ()) {
		Show_Progress ();

		//---- get the zone number ----

		zone = boundary_file.Get_Integer (zone_field);
		if (zone == 0) continue;

		if (zone_map.find (zone) == zone_map.end ()) continue;
		if (range_flag && !zone_range.In_Range (zone)) continue;

		map_stat = boundary_map.insert (Points_Map_Data (zone, boundary_file));
		if (!map_stat.second) {
			Warning ("Duplicate Zone Number = ") << zone;
		}
	}
	End_Progress ();

	boundary_file.Close ();

	Print (2, "Number of ") << boundary_file.File_Type () << " Records = " << boundary_map.size ();
}
Exemple #3
0
void LineSum::Read_Service (void)
{
	String line;
	int peak, offpeak, service;

	//---- read the line service file ----

	Show_Message (String ("Reading %s -- Record") % service_file.File_Type ());
	Set_Progress ();

	//---- read each record ----

	while (service_file.Read ()) {
		Show_Progress ();

		line = service_file.Get_String (line_fld);
		line.To_Upper ();

		peak = service_file.Get_Integer (peak_fld);
		offpeak = service_file.Get_Integer (offpeak_fld);
		service = (peak << 16) + offpeak;

		service_map.insert (Str_ID_Data (line, service));
	}
	End_Progress ();

	Print (2, String ("Number of %s Records = %d") % service_file.File_Type () % service_map.size ());
	
	service_file.Close ();
}
Exemple #4
0
void Network_Service::Read_Line (void)
{
	Line_File *file = (Line_File *) Network_Db_File (TRANSIT_ROUTE);

	//---- store the transit route data ----

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

	if (Check_Data () || Renumber ()) {
		if (!Network_Data_Flag (TRANSIT_STOP) && 
			(Network_File_Flag (TRANSIT_STOP) || Network_Option_Flag (TRANSIT_STOP))) {
			Error (file_error, "Transit Stop", file->File_ID ());
		}
	}
	First_Record (true);
	int i, num;

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

		if (Line_Processing (file)) {
			if (!line_data.Add ()) goto add_error;

		}
		First_Record (false);

		num = file->Stops ();

		for (i=1; i <= num; i++) {
			if (!file->Read (true)) {
				Error ("Number of Nested Records for Route %d", file->Route ());
			}
			Show_Progress ();

			if (Line_Processing (file)) {
				if (!line_data.Add ()) goto add_error;
			}			
		}	
	}
	End_Progress ();
	file->Close ();

	line_data.Route_Records (Progress_Count ());

	Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ());

	num = line_data.Num_Records ();

	if (num && num != Progress_Count ()) {
		Print (1, "Number of Transit Route Data Records = %d", num);
	}
	line_data.Optimize ();

	if (num > 0) Network_Data_True (TRANSIT_ROUTE);
	return;

add_error:
	Error ("Adding Record to the Transit Route Data List");
}
Exemple #5
0
void ArcNet::Write_Subzone (void)
{
	XYZ_Point point;

	int z_field = subzone_file.Optional_Field ("Z_COORD", "ELEVATION", "Z");

	arcview_subzone.Num_Points (1);

	Show_Message ("Reading %s -- Record", subzone_file.File_Type ());
	Set_Progress (1000);

	while (subzone_file.Read ()) {
		Show_Progress ();

		arcview_subzone.Copy_Fields (&subzone_file);

		point.x = subzone_file.X ();
		point.y = subzone_file.Y ();
		subzone_file.Get_Field (z_field, &(point.z));

		arcview_subzone.points.Set (1, &point);

		if (!arcview_subzone.Write_Record ()) {
			Error ("Writing ArcView Subzone File");
		}
	}
	End_Progress ();
	
	subzone_file.Close ();
	arcview_subzone.Close ();

	Print (2, "Number of %s Records = %d", subzone_file.File_Type (), Progress_Count ());
}
Exemple #6
0
void IntControl::Read_Deletes (void)
{
    int node;

    //---- store the delete data ----

    Show_Message ("Reading %s -- Record", delete_file.File_Type ());
    Set_Progress ();

    while (delete_file.Read ()) {
        Show_Progress ();

        Get_Integer (delete_file.Record (), &node);
        if (node == 0) continue;

        if (!delete_node.Add (node)) {
            Error ("Adding Delete Node Record");
        }
    }
    End_Progress ();

    delete_file.Close ();

    Print (2, "Number of %s Records = %d", delete_file.File_Type (), Progress_Count ());
}
Exemple #7
0
void LineSum::Read_Shapes (void)
{
	int anode, bnode;

	//---- read the arcview shape file ----

	Show_Message (String ("Reading %s -- Record") % link_shape.File_Type ());
	Set_Progress ();

	//---- read each record ----

	while (link_shape.Read_Record ()) {
		Show_Progress ();

		anode = link_shape.Get_Integer (anode_field);
		bnode = link_shape.Get_Integer (bnode_field);

		points_map.insert (I2_Points_Map_Data (Int2_Key (anode, bnode), link_shape));
	}
	End_Progress ();

	Print (2, String ("Number of %s Records = %d") % link_shape.File_Type () % points_map.size ());
	
	link_shape.Close ();
}
Exemple #8
0
void LocationData::Read_Polygons (void)
{
	int i, index, num_pts;

	Arcview_File *poly_file;
	Boundary poly_rec;
	Index_Array *polygon;
	Db_Index_Array *data;

	//---- read the arcview boundary file ----

	for (i=0; i < num_polygons; i++) {
		poly_file = polygon_files [i];
		if (poly_file == NULL) continue;

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

		//---- read each record ----

		index = 0;
		polygon = polygons [i];
		data = polygon_db [i];

		while (poly_file->Read_Record ()) {
			Show_Progress ();

			poly_rec.zone = ++index;
			num_pts = poly_file->Num_Points ();

			poly_rec.points = new Point_Data ();

			if (poly_rec.points == NULL || !poly_rec.points->Num_Points (num_pts)) {
				Error ("Insufficient Memory for Boundary Polygons");
			}
			num_pts *= sizeof (XY_Point);

			memcpy (poly_rec.points->Get_XY_Data (1), poly_file->Get_XY_Data (1), num_pts);

			if (!polygon->Add (&poly_rec)) {
				Error ("Adding Boundary Polygon");
			}

			//----- add to the database ----

			data->Copy_Fields (poly_file);
			data->Put_Field (1, index);

			if (!data->Add_Record ()) {
				Error ("Writing Boundary Polygon Database");
			}
		}
		End_Progress ();

		Print (2, "Number of %s Records = %d", poly_file->File_Type (), Progress_Count ());
		
		poly_file->Close ();
	}
}
Exemple #9
0
void RoutePrep::Read_Node_Map (void)
{
	String record;
	Strings fields;

	int node, index;
	Int_Map_Itr map_itr;
	Int_Map_Stat map_stat;
	Node_Data *node_ptr;

	Show_Message (String ("Reading %s -- Record") % node_map_file.File_Type ());
	Set_Progress ();

	while (node_map_file.Read ()) {
		Show_Progress ();

		record = node_map_file.Record_String ();

		record.Parse (fields);

		node = fields [0].Integer ();
		if (node <= 0) continue;

		index = fields [1].Integer ();

		if (index > 0) {
			map_itr = node_map.find (index);

			if (map_itr == node_map.end ()) {
				Warning (String ("Node Map %d to %d was Not Found in the Node File") % node % index);
				continue;
			}
			index = map_itr->second;
		}

		//---- insert the node;

		map_stat = input_map.insert (Int_Map_Data (node, index));

		if (!map_stat.second) {
			Warning (String ("Duplicate Node Map %d to %d and %d") % node % index % map_stat.first->second);
			continue;
		}
		if (index >= 0) {
			node_ptr = &node_array [index];

			node_ptr->Control (node);
		}

	}
	End_Progress ();

	node_map_file.Close ();

	Print (2, String ("Number of %s Records = %d") % node_map_file.File_Type () % Progress_Count ());
}
Exemple #10
0
void Emissions::Write_HPMS_VMT (void)
{
	int vt, vt_field, yr_field, fac_field, vmt_field, off_field, max_vt, num_vt, year;

	//---- create the data fields ----

	hpms_file.Add_Field ("HPMSVtypeID", Db_Code::INTEGER, 3);
	vt_field = 1;

	hpms_file.Add_Field ("yearID", Db_Code::INTEGER, 5);
	yr_field = 2;
	
	hpms_file.Add_Field ("VMTGrowthFactor", Db_Code::DOUBLE, 9, 6);
	fac_field = 3;
	
	hpms_file.Add_Field ("HPMSBaseYearVMT", Db_Code::DOUBLE, 20, 2);
	vmt_field = 4;
	
	hpms_file.Add_Field ("baseYearOffNetVMT", Db_Code::DOUBLE, 20, 2);
	off_field = 5;

	hpms_file.Write_Header ();

	//---- save the data to the file ----

	Show_Message ("Writing %s -- Record", hpms_file.File_Type ());
	Set_Progress ();

	year = years.First ();
	if (year == 0) year = 2007;

	max_vt = category_data.Get (HPMS)->Max_Value ();
	num_vt = 0;

	for (vt=1; vt <= max_vt; vt++) {
		Show_Progress ();

		if (hpms_vmt [vt] == 0.0) continue;

		hpms_file.Put_Field (vt_field, vt);
		hpms_file.Put_Field (yr_field, year);
		hpms_file.Put_Field (fac_field, 0);
		hpms_file.Put_Field (vmt_field, hpms_vmt [vt] / MILETOMETER);
		hpms_file.Put_Field (off_field, 0);

		if (!hpms_file.Write ()) {
			Error ("Writing %s", hpms_file.File_Type ());
		}
		num_vt++;
	}
	End_Progress ();

	hpms_file.Close ();

	Print (2, "Number of %s Records = %d", hpms_file.File_Type (), num_vt);
}
Exemple #11
0
void Data_Service::Read_Lines (Line_File &file)
{
	int i, num;
	bool keep_flag;
	Int_Map_Stat map_stat;
	Line_Data line_rec;

	//---- store the route data ----

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

	while (file.Read (false)) {
		Show_Progress ();

		line_rec.Clear ();

		keep_flag = Get_Line_Data (file, line_rec);

		num = file.Num_Nest ();
		if (num > 0) line_rec.reserve (num);

		for (i=1; i <= num; i++) {
			if (!file.Read (true)) {
				Error (String ("Number of Stop Records for Route %d") % file.Route ());
			}
			Show_Progress ();

			Get_Line_Data (file, line_rec);
		}
		if (keep_flag) {
			map_stat = line_map.insert (Int_Map_Data (line_rec.Route (), (int) line_array.size ()));

			if (!map_stat.second) {
				Warning ("Duplicate Route Number = ") << line_rec.Route ();
			} else {
				line_array.push_back (line_rec);

				line_array.Add_Route_Stops ((int) line_rec.size ());
			}
		}
	}
	End_Progress ();
	file.Close ();

	Print (2, String ("Number of %s Records = %d") % file.File_Type () % Progress_Count ());

	num = (int) line_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of %s Data Records = %d") % file.File_ID () % num);
	}
	if (num > 0) System_Data_True (TRANSIT_ROUTE);
}
Exemple #12
0
void ArcRider::Write_Stops (void)
{
	int index, board, alight, stop_field, board_field, alight_field, total_field;
	bool stop_flag;

	Offset_Data *stop_ptr;
	XYZ_Point point;

	stop_field = arcview_stop.Field_Number ("STOP");
	board_field = arcview_stop.Field_Number ("BOARD");
	alight_field = arcview_stop.Field_Number ("ALIGHT");
	total_field = arcview_stop.Field_Number ("TOTAL");
	
	stop_flag = (transit_stops.Num_Ranges () > 0);

	arcview_stop.Num_Points (1);

	Show_Message ("Writing %s -- Record", arcview_stop.File_Type ());
	Set_Progress (1000);

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

	for (stop_ptr = stop_offset.First (); stop_ptr; stop_ptr = stop_offset.Next ()) {
		Show_Progress ();

		if (stop_flag && !transit_stops.In_Range (stop_ptr->ID ())) continue;

		index = stop_offset.Record_Index ();

		board = board_data [index];
		alight = alight_data [index];

		if (board <= 0 && alight <= 0) continue;

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

		point.x = stop_ptr->X ();
		point.y = stop_ptr->Y ();
		point.z = stop_ptr->Z ();

		arcview_stop.Put_Field (stop_field, stop_ptr->ID ());
		arcview_stop.Put_Field (board_field, board);
		arcview_stop.Put_Field (alight_field, alight);
		arcview_stop.Put_Field (total_field, (board + alight));

		arcview_stop.points.Set (1, &point);

		if (!arcview_stop.Write_Record ()) {
			Error ("Writing ArcView Stop Demand File");
		}
		num_stop++;
	}
	End_Progress ();

	arcview_stop.Close ();
}
Exemple #13
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 ();
}
Exemple #14
0
void Data_Service::Read_Shapes (Shape_File &file)
{
	int i, num;	
	bool keep_flag;
	Shape_Data shape_rec;
	Int_Map_Stat map_stat;

	//---- store the shape point data ----

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

	Initialize_Shapes (file);

	while (file.Read (false)) {
		Show_Progress ();

		shape_rec.Clear ();

		keep_flag = Get_Shape_Data (file, shape_rec);

		num = file.Num_Nest ();
		if (num > 0) shape_rec.reserve (num);

		for (i=1; i <= num; i++) {
			if (!file.Read (true)) {
				Error (String ("Number of Nested Records for Link %d") % file.Link ());
			}
			Show_Progress ();

			Get_Shape_Data (file, shape_rec);
		}
		if (keep_flag) {
			map_stat = shape_map.insert (Int_Map_Data (shape_rec.Link (), (int) shape_array.size ()));

			if (!map_stat.second) {
				Warning ("Duplicate Link Number = ") << shape_rec.Link ();
			} else {
				shape_array.push_back (shape_rec);
			}
		}
	}
	End_Progress ();
	file.Close ();

	Print (2, String ("Number of %s Records = %d") % file.File_Type () % Progress_Count ());

	num = (int) shape_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of Link %s Records = %d") % file.File_ID () % num);
	}
	if (num > 0) System_Data_True (SHAPE);
}
Exemple #15
0
void TransitAccess::Read_Link (void)
{
	int anode, bnode, dist, zone, type;
	double len;
	String text;
	Zone_Map_Itr zone_itr;
	Node_Map_Itr node_itr;

	//---- walk link data ----

	Show_Message (String ("Reading %s -- Record") % link_data_file.File_Type ());
	Set_Progress ();

	while (link_data_file.Read ()) {
		Show_Progress ();

		anode = link_data_file.Get_Integer (link_anode_fld);
		bnode = link_data_file.Get_Integer (link_bnode_fld);

		if (skip_links.find (Int2_Key (anode, bnode)) != skip_links.end ()) continue;
		if (skip_links.find (Int2_Key (bnode, anode)) != skip_links.end ()) continue;

		len = link_data_file.Get_Double (link_len_fld);
		zone = link_data_file.Get_Integer (link_zone_fld);
		type = link_data_file.Get_Integer (link_type_fld);

		if (!type_range.In_Range (type)) continue;

		zone_itr = zone_map.find (zone);
		if (zone_itr == zone_map.end ()) continue;
		if (zone_itr->second.walk == 0) continue;

		dist = DTOI (len * 100.0 * zone_itr->second.weight);

		node_itr = node_map.find (anode);
		if (node_itr != node_map.end ()) {
			node_itr->second.use = 1;
		}
		node_itr = node_map.find (bnode);
		if (node_itr != node_map.end ()) {
			node_itr->second.use = 1;
		}
	
		text (" N=%d-%d MODE=13 SPEED=3 ONEWAY=T DIST=%d") % anode % bnode % dist;

		sidewalk_file.File () << "SUPPORT" << text << endl;

		walk_link_file.File () << "SUPPLINK" << text << endl;
	}
	End_Progress ();
	link_data_file.Close ();

	Print (2, "Number of Link Data Records = ") << Progress_Count ();
}
void ActivityPattern::Survey_Population (void)
{
	int hhold;

	Survey_HHold *household_ptr;
	Survey_Person *population_ptr;

	if (!survey_pop_data.Max_Records (survey_pop_file.Num_Records ())) goto mem_error;

	//---- read the survey population file ----

	Show_Message ("Reading %s -- Record", survey_pop_file.File_Type ());
	Set_Progress (50000);
	
	while (survey_pop_file.Read ()) {
		Show_Progress ();

		//---- check the household id ----

		hhold = survey_pop_file.Household ();
		if (hhold <= 0) continue;

		household_ptr = survey_hh_data.Get (hhold);
		if (household_ptr == NULL) {
			Error ("Survey Person Household %d was Not Found", hhold);
		}

		population_ptr = survey_pop_data.New_Record (true);
		if (population_ptr == NULL) goto mem_error;

		population_ptr->Household (hhold);
		population_ptr->Person (survey_pop_file.Person ());
		population_ptr->Age (survey_pop_file.Age ());
		population_ptr->Gender (survey_pop_file.Gender ());
		population_ptr->Work (survey_pop_file.Work ());
		population_ptr->Drive (survey_pop_file.Drive ());
		population_ptr->Count (0);

		if (!survey_pop_data.Add ()) {
			Error ("Adding Record to the Population Data Array");
		}
	}
	End_Progress ();
	survey_pop_file.Close ();

	Print (2, "Number of %s Records = %d", survey_pop_file.File_Type (), Progress_Count ());

	survey_pop_data.Optimize ();
	return;

mem_error:
	Error ("Insufficient Memory for Survey Population Data");
}
Exemple #17
0
void Data_Service::Read_Locations (void)
{
	Location_File *file = (Location_File *) System_File_Handle (LOCATION);

	int num;
	bool zone_flag = System_Data_Flag (ZONE);

	Int_Map_Stat map_stat;
	Location_Data location_rec;

	//---- store the location data ----

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

	Initialize_Locations (*file);

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

		location_rec.Clear ();

		if (Get_Location_Data (*file, location_rec)) {
			map_stat = location_map.insert (Int_Map_Data (location_rec.Location (), (int) location_array.size ()));

			if (!map_stat.second) {
				Warning ("Duplicate Location Number = ") << location_rec.Location ();
				continue;
			} else {
				if (!file->Setback_Flag () && location_rec.Setback () == 0) {
					location_rec.Setback (Internal_Units (100.0, FEET));
				}
				location_array.push_back (location_rec);

				if (!zone_flag && location_rec.Zone () > Max_Zone_Number ()) {
					Max_Zone_Number (location_rec.Zone ());
				}
			}
		}
	}
	End_Progress ();
	file->Close ();

	Print (2, String ("Number of %s Records = %d") % file->File_Type () % Progress_Count ());

	num = (int) location_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of %s Data Records = %d") % file->File_ID () % num);
	}
	if (num > 0) System_Data_True (LOCATION);
}
Exemple #18
0
void PlanSum::Write_Turns (void)
{
    int i;
    char *time1_ptr, *time2_ptr;

    Movement_Data *move_ptr;
    Movement_Array *array_ptr;
    Dir_Data *dir_ptr;

    Show_Message ("Writing %s -- Record", turn_file.File_Type ());
    Set_Progress (10000);

    //---- write each turn movement ----

    for (i=1; i <= num_inc; i++) {
        array_ptr = movement_data [i];

        time1_ptr = time_periods.Range_Format (i);

        time2_ptr = strstr (time1_ptr, "..");
        *time2_ptr = '\0';
        time2_ptr += 2;

        for (move_ptr = array_ptr->First_Key (); move_ptr; move_ptr = array_ptr->Next_Key ()) {
            Show_Progress ();

            turn_file.Node (move_ptr->node);

            dir_ptr = dir_data [move_ptr->in_link];
            turn_file.In_Link (dir_ptr->Link ());

            dir_ptr = dir_data [move_ptr->out_link];
            turn_file.Out_Link (dir_ptr->Link ());

            turn_file.Start (time1_ptr);
            turn_file.End (time2_ptr);
            turn_file.Volume (move_ptr->volume);

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

            if (!turn_file.Write ()) {
                Error ("Writing Turn Movement File");
            }
        }
    }
    End_Progress ();

    Print (2, "Number of %s Records = %d", turn_file.File_Type (), Progress_Count ());

    turn_file.Close ();
}
Exemple #19
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 ();
	}
}
Exemple #20
0
void ArcPlan::Write_Parking (void)
{
	int index, in, out, park_field, out_field, in_field, tot_field;

	Offset_Data *parking_ptr;
	XYZ_Point point;

	park_field = arcview_parking.Field_Number ("PARKING");
	out_field = arcview_parking.Field_Number ("DEPART");
	in_field = arcview_parking.Field_Number ("ARRIVE");
	tot_field = arcview_parking.Field_Number ("TOTAL");

	arcview_parking.Num_Points (1);

	Show_Message ("Writing %s -- Record", arcview_parking.File_Type ());
	Set_Progress (1000);

	//---- process each parking lot ----

	for (parking_ptr = parking_offset.First (); parking_ptr; parking_ptr = parking_offset.Next ()) {
		Show_Progress ();

		index = parking_offset.Record_Index ();

		out = parking_out [index];
		in = parking_in [index];

		if (in <= 0 && out <= 0) continue;

		//---- write the parking record ----

		point.x = parking_ptr->X ();
		point.y = parking_ptr->Y ();

		arcview_parking.Put_Field (park_field, parking_ptr->ID ());
		arcview_parking.Put_Field (out_field, out);
		arcview_parking.Put_Field (in_field, in);
		arcview_parking.Put_Field (tot_field, (out + in));

		arcview_parking.points.Set (1, &point);

		if (!arcview_parking.Write_Record ()) {
			Error ("Writing ArcView Parking Demand File");
		}
		num_parking++;
	}
	End_Progress ();

	arcview_parking.Close ();
}
Exemple #21
0
void Data_Service::Read_Events (void)
{
	Event_File *file = (Event_File *) System_File_Handle (EVENT);
	
	int num;
	Event_Data event_rec;
	Event_Index event_index;
	Event_Map_Stat map_stat;

	//---- store the event data ----

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

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

		event_rec.Clear ();

		if (Get_Event_Data (*file, event_rec)) {
			event_rec.Get_Event_Index (event_index);

			map_stat = event_map.insert (Event_Map_Data (event_index, (int) event_array.size ()));

			if (!map_stat.second) {
				Warning (String ("Duplicate Event Record = %d-%d-%d-%d-%d") % 
					event_index.Household () % event_index.Person () % event_index.Tour () % 
					event_index.Trip () % event_index.Event ());

				continue;
			} else {
				event_array.push_back (event_rec);
			}
		}
	}
	End_Progress ();
	file->Close ();
	
	Print (2, String ("Number of %s Records = %d") % file->File_Type () % Progress_Count ());

	num = (int) event_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of %d Data Records = %d") % file->File_ID () % num);
	}
	if (num > 0) System_Data_True (EVENT);
}
Exemple #22
0
void TransimsNet::Add_Node_Data (void)
{
	int node, count;
	Db_Sort_Itr db_itr;
	Int_Map_Stat map_stat;
	Node_Data node_rec;

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

	Show_Message (String ("Adding %s -- Record") % node_data_file.File_Type ());
	Set_Progress ();

	count = 0;

	for (db_itr = node_data_array.begin (); db_itr != node_data_array.end (); db_itr++) {
		Show_Progress ();

		node = db_itr->first;
		if (node_map.find (node) != node_map.end ()) continue;

		update_node_range.Add_Range (node, node);

		node_data_array.Read_Record (node);

		count++;
		node_data_file.Copy_Fields (node_data_array);

		node_rec.Clear ();
		node_rec.Node (node_data_file.Node ());
		node_rec.X (node_data_file.X ());
		node_rec.Y (node_data_file.Y ());
		node_rec.Z (node_data_file.Z ());
		node_rec.Subarea (node_data_file.Subarea ());
		node_rec.Notes (node_data_file.Notes ());

		map_stat = node_map.insert (Int_Map_Data (node_rec.Node (), (int) node_array.size ()));

		if (!map_stat.second) {
			Warning ("Duplicate Node Number = ") << node_rec.Node ();
			continue;
		} else {
			node_array.push_back (node_rec);
		}
	}
	End_Progress ();

	Print (2, String ("Number of %s Records Added = %d") % node_data_file.File_Type () % count);
}
Exemple #23
0
void Data_Service::Read_Zones (void)
{
	Zone_File *file = (Zone_File *) System_File_Handle (ZONE);
	
	Zone_Data zone_rec;
	Int_Map_Stat map_stat;

	//---- store the zone data ----

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

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

		zone_rec.Clear ();

		if (Get_Zone_Data (*file, zone_rec)) {
			map_stat = zone_map.insert (Int_Map_Data (zone_rec.Zone (), (int) zone_array.size ()));

			if (!map_stat.second) {
				Warning ("Duplicate Zone Number = ") << zone_rec.Zone ();
				continue;
			} else {
				zone_array.push_back (zone_rec);

				if (zone_rec.Zone () > Max_Zone_Number ()) {
					Max_Zone_Number (zone_rec.Zone ());
				}
			}
		}
	}
	End_Progress ();
	file->Close ();
	
	Print (2, String ("Number of %s Records = %d") % file->File_Type () % Progress_Count ());

	int num = (int) zone_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of %s Data Records = %d") % file->File_ID () % num);
	}
	if (num != Max_Zone_Number ()) Print (1, "Highest Zone Number = ") << Max_Zone_Number ();

	if (num > 0) System_Data_True (ZONE);
}
Exemple #24
0
void Network_Service::Read_Phasing (void)
{
	Db_File *file = Network_Db_File (PHASING_PLAN);

	//---- store the phasing plan data ----

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

	if (Check_Data () || Renumber ()) { 
		if (!Network_File_Flag (NODE) && Network_Option_Flag (NODE)) {
			Error (file_error, "Node", file->File_ID ());
		}
		if (!Network_File_Flag (LINK) && Network_Option_Flag (LINK)) {
			Error (file_error, "Link", file->File_ID ());
		}
		if (!Network_File_Flag (TIMING_PLAN) && Network_Option_Flag (TIMING_PLAN)) {
			Error (file_error, "Timing Plan", file->File_ID ());
		}
	}
	file->Num_Records ();
	First_Record (true);

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

		if (Phasing_Processing (file)) {
			if (!phasing_data.Add ()) {
				Error ("Adding Record to the Phasing Plan List");
			}
		}
		First_Record (false);
	}
	End_Progress ();
	file->Close ();

	phasing_data.Max_Records (phasing_data.Num_Records ());

	Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ());

	int num = phasing_data.Num_Records ();

	if (num && num != Progress_Count ()) {
		Print (1, "Number of Phasing Plan Data Records = %d", num);
	}
	if (num > 0) Network_Data_True (PHASING_PLAN);
}
Exemple #25
0
void PlanTrips::Write_Activity (void)
{
	Activity_Data *act_ptr;

	char buffer [FIELD_BUFFER];
	
	Show_Message ("Writing %s", act_file->File_Type ());
	Set_Progress (10000);

	//---- process each activity ----

	for (act_ptr = activity_data.First_Key (); act_ptr; act_ptr = activity_data.Next_Key ()) {
		Show_Progress ();

		act_file->Household (act_ptr->Household ());
		act_file->Person (act_ptr->Person ());
		act_file->Activity (act_ptr->Activity ());
		act_file->Purpose (act_ptr->Purpose ());
		act_file->Priority (act_ptr->Priority ());

		trip_time.Format_Step (act_ptr->Start_Time (), buffer);
		act_file->Start_Min (buffer);
		act_file->Start_Max (buffer);
		
		trip_time.Format_Step (act_ptr->End_Time (), buffer);
		act_file->End_Min (buffer);
		act_file->End_Max (buffer);
		
		trip_time.Format_Duration (act_ptr->Duration (), buffer);
		act_file->Time_Min (buffer);
		act_file->Time_Max (buffer);

		act_file->Mode (act_ptr->Mode ());
		act_file->Vehicle (act_ptr->Vehicle ());
		act_file->Location (act_ptr->Location ());
		act_file->Passengers (act_ptr->Passengers ());
		act_file->Constraint (act_ptr->Constraint ());

		if (!act_file->Write ()) {
			Error ("Writing %s", act_file->File_Type ());
		}
		num_act++;
	}
	End_Progress ();

	act_file->Close ();
}
Exemple #26
0
void GISNet::Read_Node (void)
{
	int node, node_field, z_field;
	XYZ_Point *pt_ptr;

	Node_Data node_rec;

	//---- initialize the node array ----

	node_field = gis_node.Required_Field ("NODE", "ID", "NODE_ID", "NODEID", "N");
	z_field = gis_node.Optional_Field ("Z_COORD", "ELEVATION", "Z");

	//---- read each node record----

	Show_Message ("Reading %s -- Record", gis_node.File_Type ());
	Set_Progress (1000);

	while (gis_node.Read_Record ()) {
		Show_Progress ();

		//---- read the node data ----

		gis_node.Get_Field (node_field, &node);
		if (node == 0) continue;

		if (node >= first_node) first_node = node + 1;
		
		pt_ptr = gis_node.points.First ();

		//---- save to index class -----

		node_rec.Node (node);
		node_rec.X (Round (pt_ptr->x));
		node_rec.Y (Round (pt_ptr->y));
		node_rec.Z (Round (pt_ptr->z));

		if (!node_data.Add (&node_rec)) {
			Error ("Adding Node Data Record");
		}
	}
	End_Progress ();

	gis_node.Close ();

	Print (2, "Number of %s Records = %d", gis_node.File_Type (), Progress_Count ());
}
Exemple #27
0
void Data_Service::Write_Households (void)
{
	int part, num_part, count;

	Household_File *file = System_Household_File (true);

	Int_Map_Itr itr;
	Household_Data *hhold_ptr;
	Household_Itr hhold_itr;
	Partition_Files <Household_File> new_file_set;

	if (file->Part_Flag ()) {
		for (num_part=0, hhold_itr = hhold_array.begin (); hhold_itr != hhold_array.end (); hhold_itr++) {
			part = Partition_Index (hhold_itr->Partition ());
			if (part > num_part) num_part = part;
		}
		new_file_set.Initialize (file, ++num_part);
		Show_Message (String ("Writing %ss -- Record") % file->File_Type ());
	} else {
		num_part = 1;
		Show_Message (String ("Writing %s -- Record") % file->File_Type ());
	}
	Set_Progress ();

	for (count=0, itr = hhold_map.begin (); itr != hhold_map.end (); itr++) {
		Show_Progress ();

		hhold_ptr = &hhold_array [itr->second];
		if (hhold_ptr->Partition () < 0) continue;

		if (file->Part_Flag ()) {
			part = Partition_Index (hhold_ptr->Partition ());
			if (part < 0) continue;
			file = new_file_set [part];
		}
		count += Put_Household_Data (*file, *hhold_ptr);
	}
	End_Progress ();

	file->Close ();
	
	Print (2, String ("%s Records = %d") % file->File_Type () % count);
	if (num_part > 1) Print (0, String (" (%d files)") % num_part);
}
Exemple #28
0
void Network_Service::Read_Turn (void)
{
	Turn_File *file = (Turn_File *) Network_Db_File (TURN_PROHIBITION);

	//---- store the turn prohibition data ----

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

	if (Check_Data () || Renumber ()) {
		if (!Network_File_Flag (NODE) && Network_Option_Flag (NODE) && file->Node_Based ()) {
			Error (file_error, "Node", file->File_ID ());
		}
		if (!Network_File_Flag (LINK) && Network_Option_Flag (LINK)) {
			Error (file_error, "Link", file->File_ID ());
		}
	}
	file->Num_Records ();
	First_Record (true);

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

		if (Turn_Processing (file)) {
			if (!turn_data.Add ()) {
				Error ("Adding Record to the Turn Data List");
			}
		}
		First_Record (false);
	}
	End_Progress ();
	file->Close ();

	Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ());

	int num = turn_data.Num_Records ();

	if (num && num != Progress_Count ()) {
		Print (1, "Number of Turn Prohibition Data Records = %d", num);
	}
	turn_data.Optimize ();

	if (num > 0) Network_Data_True (TURN_PROHIBITION);
}
Exemple #29
0
void Demand_Service::Read_Vehicle (void)
{
	vehicle_data.Sorted (!sort_flag);

	Db_File *file = Demand_Db_File (VEHICLE);

	//---- store the vehicle data ----

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

	if (Check_Data () || Renumber ()) { 
		if (!Network_File_Flag (PARKING) && Network_Option_Flag (PARKING)) {
			Error (file_error, "Parking", file->File_ID ());
		}
	}
	//file->Num_Records ();
	First_Record (true);

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

		if (Vehicle_Processing (file)) {
			if (!vehicle_data.Add ()) {
				Error ("Adding Record to the Vehicle Data Array");
			}
		}
		First_Record (false);
	}
	End_Progress ();
	file->Close ();

	Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ());

	int num = vehicle_data.Num_Records ();

	if (num && num != Progress_Count ()) {
		Print (1, "Number of Vehicle Data Records = %d", num);
	}
	vehicle_data.Optimize (compress_flag);

	if (num > 0) Demand_Data_True (VEHICLE);
}
Exemple #30
0
void TripSum::Write_Link_Trips (void)
{
	int i, j, p, link, num_periods, total, count;

	Int_Map_Itr map_itr;
	Integers *trips;

	Show_Message ("Writing Link Trip Ends -- Link");
	Set_Progress ();

	count = 0;
	num_periods = sum_periods.Num_Periods ();

	for (map_itr = link_map.begin (); map_itr != link_map.end (); map_itr++) {
		Show_Progress ();

		link = map_itr->second;

		link_trip_file.Put_Field (0, map_itr->first);

		trips = &link_trip_data [link];

		total = 0;
		j = num_periods * 2;

		for (i=0; i < j; i++) {
			total += trips->at (i);
		}
		if (total == 0) continue;

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

		for (i=1, p=j=0; p < num_periods; p++) {
			link_trip_file.Put_Field (i++, trips->at (j++));
			link_trip_file.Put_Field (i++, trips->at (j++));
		}
		link_trip_file.Write ();
		count++;
	}
	End_Progress ();

	Print (2, "Number of New Link Trip End Records = ") << count;
}