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); }
bool LineFollower::intersection(byte& L_bits, byte& R_bits) { Get_Line_Data(); L_bits = this->L_bits; R_bits = this->R_bits; return ( Line_Data == 0xFF ) ; }
bool LineFollower::isCentered(byte& L_bits, byte& R_bits) // Has to be changed as the code doesn't explicitly checks whether it(rover) is centered or not. { Get_Line_Data(); L_bits = this->L_bits; R_bits = this->R_bits; return (L_bits == R_bits) && (L_bits == 1); //L_bits == R_bits is ambiguous as it also happens when rover is over black part of the course (L_bits==R_bits == 0) }