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"); }
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); }
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); }
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 (); }
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 (); }
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 ()); }
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 ()); }
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 (); }
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 (); }
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 (); } }
int Data_Service::Put_Timing_Data (Timing_File &file, Signal_Data &data) { Int_Map_Itr map_itr; Timing_Itr timing_itr; Timing_Phase_Itr phase_itr; int i, num, count; Timing_Phase *phase_sort [20]; file.Signal (data.Signal ()); count = 0; for (timing_itr = data.timing_plan.begin (); timing_itr != data.timing_plan.end (); timing_itr++) { Show_Progress (); file.Timing (timing_itr->Timing ()); file.Type (timing_itr->Type ()); file.Cycle (timing_itr->Cycle ()); file.Offset (timing_itr->Offset ()); file.Phases ((int) timing_itr->size ()); file.Notes (timing_itr->Notes ()); if (!file.Write (false)) { Error (String ("Writing %s") % file.File_Type ()); } count++; num = 0; memset (phase_sort, '\0', sizeof (phase_sort)); for (phase_itr = timing_itr->begin (); phase_itr != timing_itr->end (); phase_itr++) { i = phase_itr->Phase (); if (i >= 20) continue; if (i > num) num = i; phase_sort [i] = &(*phase_itr); } for (i=1; i <= num; i++) { if (phase_sort [i] == 0) continue; file.Phase (phase_sort [i]->Phase ()); file.Barrier (phase_sort [i]->Barrier ()); file.Ring (phase_sort [i]->Ring ()); file.Position (phase_sort [i]->Position ()); file.Min_Green (phase_sort [i]->Min_Green ()); file.Max_Green (phase_sort [i]->Max_Green ()); file.Extension (phase_sort [i]->Extension ()); file.Yellow (phase_sort [i]->Yellow ()); file.All_Red (phase_sort [i]->All_Red ()); if (!file.Write (true)) { Error (String ("Writing %s") % file.File_Type ()); } count++; } } return (count); }
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 (); }
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 ()); }
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 (); }
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); }
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 Data_Service::Write_Links (void) { Link_File *file = System_Link_File (true); int count = 0; Int_Map_Itr itr; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { Show_Progress (); count += Put_Link_Data (*file, link_array [itr->second]); } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
void Data_Service::Write_Timing_Plans (void) { Timing_File *file = System_Timing_File (true); int count = 0; Int_Map_Itr map_itr; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (map_itr = signal_map.begin (); map_itr != signal_map.end (); map_itr++) { Show_Progress (); count += Put_Timing_Data (*file, signal_array [map_itr->second]); } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
void Data_Service::Write_Nodes (void) { Node_File *file = (Node_File *) System_File_Handle (NEW_NODE); int count = 0; Int_Map_Itr itr; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = node_map.begin (); itr != node_map.end (); itr++) { Show_Progress (); count += Put_Node_Data (*file, node_array [itr->second]); } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % 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"); }
void Data_Service::Write_Parking_Lots (void) { Parking_File *file = (Parking_File *) System_File_Handle (NEW_PARKING); int count = 0; Int_Map_Itr itr; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = parking_map.begin (); itr != parking_map.end (); itr++) { Show_Progress (); count += Put_Parking_Data (*file, parking_array [itr->second]); } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
void Data_Service::Write_Connections (void) { Connect_File *file = (Connect_File *) System_File_Handle (NEW_CONNECTION); int dir, index, count; Connect_Data *connect_ptr; Dir_Data *dir_ptr; Link_Data *link_ptr; Int_Map_Itr itr; count = 0; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { link_ptr = &link_array [itr->second]; for (dir=0; dir < 2; dir++) { index = (dir) ? link_ptr->BA_Dir () : link_ptr->AB_Dir (); if (index < 0) continue; Show_Progress (); dir_ptr = &dir_array [index]; for (index = dir_ptr->First_Connect (); index >= 0; index = connect_ptr->Next_Index ()) { connect_ptr = &connect_array [index]; count += Put_Connect_Data (*file, *connect_ptr); } } } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
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); }
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 (); }
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 (); } }
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 (); }
void NetPrep::Write_Link_Nodes (void) { int count = 0; Int_Map_Itr itr; Int_List_Itr list_itr; Link_Nodes *ptr; Link_Data *link_ptr; Show_Message (String ("Writing %s -- Record") % link_node_file.File_Type ()); Set_Progress (); fstream &file = link_node_file.File (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { Show_Progress (); link_ptr = &link_array [itr->second]; if (!drop_flag || link_ptr->Length () > 0) { count++; ptr = &link_node_array [itr->second]; file << ptr->link << " ="; for (list_itr = ptr->nodes.begin (); list_itr != ptr->nodes.end (); list_itr++) { file << " " << *list_itr; } file << endl; } } Show_Progress (count); End_Progress (); link_node_file.Close (); Print (2, String ("%s Records = %d") % link_node_file.File_Type () % count); }
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); }
void Data_Service::Write_Signs (void) { Sign_File *file = (Sign_File *) System_File_Handle (NEW_SIGN); int dir, index, count; Dir_Data *dir_ptr; Link_Data *link_ptr; Int_Map_Itr itr; count = 0; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { link_ptr = &link_array [itr->second]; for (dir=0; dir < 2; dir++) { index = (dir) ? link_ptr->BA_Dir () : link_ptr->AB_Dir (); if (index < 0) continue; Show_Progress (); dir_ptr = &dir_array [index]; if (dir_ptr->Sign () == NO_CONTROL) continue; count += Put_Sign_Data (*file, *dir_ptr); } } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
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); }