bool Data_Service::Get_Line_Data (Line_File &file, Line_Data &line_rec) { int route; //---- process a header line ---- if (!file.Nested ()) { Int_Map_Itr map_itr; route = file.Route (); if (route == 0) return (false); line_rec.Route (route); if (file.Stops () < 2) return (false); line_rec.Mode (file.Mode ()); line_rec.Type (file.Type ()); line_rec.Name (file.Name ()); line_rec.Notes (file.Notes ()); if (file.Version () > 40 && veh_type_array.size () > 0) { map_itr = veh_type_map.find (line_rec.Type ()); if (map_itr == veh_type_map.end ()) { Warning (String ("Transit Route %d Vehicle Type %d was Not Found") % route % line_rec.Type ()); } else { line_rec.Type (map_itr->second); } } return (true); } //---- process a stop record ---- int zone, stop; Line_Stop line_stop; Int_Map_Itr itr; route = line_rec.Route (); stop = file.Stop (); itr = stop_map.find (stop); if (itr == stop_map.end ()) { Warning (String ("Transit Stop %d on Route %d was Not Found") % stop % route); return (false); } line_stop.Stop (itr->second); zone = file.Zone (); if (Num_Fare_Zones () > 0 && (zone < 0 || zone > Num_Fare_Zones ())) { Warning (String ("Transit Zone %d on Route %d is Out of Range (1..%d)") % zone % route % Num_Fare_Zones ()); } line_stop.Zone (zone); line_stop.Time_Flag ((file.Time_Flag () > 0)); line_rec.push_back (line_stop); return (true); }
bool Network_Service::Line_Processing (Db_File *fh) { static int id, nstops, stop_num; int zone; bool stop_flag; Line_Data *line_ptr = NULL; Line_File *file = (Line_File *) fh; stop_flag = Network_Data_Flag (TRANSIT_STOP); //---- process a header line ---- if (!file->Nest ()) { id = file->Route (); if (id == 0) return (false); if (id < 1) { return (Check_Message ("Transit Route ID %d is Out of Range", id)); } line_ptr = line_data.New_Record (true); if (line_ptr == NULL) goto mem_error; line_ptr->Route (id); stop_num = 1; nstops = file->Stops (); if (nstops < 2) { return (Check_Message ("Number of Stops %d on Route %d is Out of Range", nstops, id)); } if (!line_ptr->Stops (nstops)) { Error ("Insufficient Memory for %d Stops on Router %d", nstops, id); } line_ptr->Mode (Transit_Code (file->Mode ())); line_ptr->Null_Name (); line_ptr->Null_Notes (); if (Notes_Name_Flag ()) { char *str_ptr = file->Name (); if (str_ptr != NULL && *str_ptr != '\0') { line_ptr->Name (str_ptr); } str_ptr = file->Notes (); if (str_ptr != NULL && *str_ptr != '\0') { line_ptr->Notes (str_ptr); } } } else { line_ptr = line_data.New_Record (false); if (line_ptr == NULL) goto mem_error; //---- process a stop record ---- int stop = file->Stop (); if (stop_flag) { int index = stop_data.Get_Index (stop); if (index == 0) { return (Check_Message ("Transit Stop %d on Route %d was Not Found in the Stop File", stop, id)); } if (Renumber ()) stop = index; } line_ptr->Stop (stop_num, stop); zone = file->Zone (); if (Num_Fare_Zones () > 0 && (zone < 1 || zone > Num_Fare_Zones ())) { if (zone != 0 || !Zero_Fare_Zone ()) { Warning ("Transit Zone %d on Route %d is Out of Range (1..%d)", zone, id, Num_Fare_Zones ()); if (zone == 0) Zero_Fare_Zone (true); } } line_ptr->Zone (stop_num, zone); line_ptr->Time_Flag (stop_num, file->Time_Flag ()); if (stop_num == nstops) { return (true); } else { stop_num++; return (false); } } return (false); mem_error: Error ("Insuffienct Memory for Transit Line Data"); return (false); }