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 Data_Service::Initialize_Locations (Location_File &file) { Required_File_Check (file, LINK); int percent = System_Data_Reserve (LOCATION); if (location_array.capacity () == 0 && percent > 0) { int num = file.Num_Records (); if (percent != 100) { num = (int) ((double) num * percent / 100.0); } if (num > 1) { location_array.reserve (num); if (num > (int) location_array.capacity ()) Mem_Error (file.File_ID ()); } } }