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::Initialize_Lines (Line_File &file) { Required_File_Check (file, TRANSIT_STOP); if (file.Version () > 40) { Required_File_Check (file, VEHICLE_TYPE); } int percent = System_Data_Reserve (TRANSIT_ROUTE); if (line_array.capacity () == 0 && percent > 0) { int num = file.Num_Records () / 25; if (percent != 100) { num = (int) ((double) num * percent / 100.0); } if (num > 1) { line_array.reserve (num); if (num > (int) line_array.capacity ()) Mem_Error (file.File_ID ()); } } }