bool Skim_File::Create_Fields (void) { Clear_Fields (); Matrix_File::Create_Fields (); if (time_flag) { Add_Field ("TIME", DB_TIME, 4, Time_Format (), true); } else { if (mode == WAIT_MODE) { Add_Field ("WAIT", DB_TIME, 2, Time_Format (), true); } else if (mode == BIKE_MODE || mode == OTHER_MODE) { Add_Field ("OTHER", DB_TIME, 2, Time_Format (), true); } else { Add_Field ("WALK", DB_TIME, 2, Time_Format (), true); if (mode != WALK_MODE) { if (mode != RIDE_MODE && mode != TRANSIT_MODE && mode != TAXI_MODE) { Add_Field ("DRIVE", DB_TIME, 4, Time_Format (), true); } if (mode != DRIVE_MODE) { if (mode != RIDE_MODE && mode != TAXI_MODE) { Add_Field ("TRANSIT", DB_TIME, 4, Time_Format (), true); } Add_Field ("WAIT", DB_TIME, 2, Time_Format (), true); } Add_Field ("OTHER", DB_TIME, 2, Time_Format (), true); } } } if (Length_Format () == MILES || Length_Format () == KILOMETERS) { Add_Field ("LENGTH", DB_DOUBLE, 4.2, Length_Format (), true); } else { Add_Field ("LENGTH", DB_INTEGER, 4, Length_Format (), true); } if (len_flag) { Db_Field *fld = Field ("LENGTH"); if (fld->Units () != Length_Format ()) { fld->Units (Length_Format ()); } } Add_Field ("COST", DB_INTEGER, 2, CENTS, true); Add_Field ("IMPEDANCE", DB_INTEGER, 4, IMPEDANCE, true); return (Set_Field_Numbers ()); }
void LocationData::Set_Files (void) { int i, nfld, key; bool binary; Db_Field *fld; Db_Base *file; Db_Sort_Array *data; Data_Itr data_itr; Polygon_Itr poly_itr; //---- create the program data structure ---- data_rec.push_back (input_file); data_rec.push_back (output_file); //---- convert each data file to binary ---- for (data_itr = data_group.begin (); data_itr != data_group.end (); data_itr++) { file = data_itr->file; data = data_itr->data_db; data_rec.push_back ((Db_Base *) data); data->File_ID (file->File_ID ()); data->File_Type (file->File_Type ()); nfld = file->Num_Fields (); key = data_itr->join_field; binary = (file->Record_Format () == BINARY); fld = file->Field (key); data->Add_Field (fld->Name (), DB_INTEGER, 10); data->Add_Field ("AL_COUNT", DB_INTEGER, 10); for (i=0; i < nfld; i++) { if (i == key) continue; fld = file->Field (i); if (fld != 0) { data->Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); } } } //---- read the arcview boundary file ---- for (poly_itr = polygons.begin (); poly_itr != polygons.end (); poly_itr++) { file = poly_itr->file; data = poly_itr->data_db; data_rec.push_back ((Db_Base *) data); data->File_ID (file->File_ID ()); data->File_Type (file->File_Type ()); nfld = file->Num_Fields (); binary = (file->Record_Format () == BINARY); data->Add_Field ("INDEX", DB_INTEGER, 10); for (i=0; i < nfld; i++) { fld = file->Field (i); if (fld != 0) { data->Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); } } } Write (1, "Compiling Conversion Script"); if (Report_Flag (PRINT_SCRIPT)) { Header_Number (PRINT_SCRIPT); if (!Break_Check (10)) { Print (1); Page_Header (); } } program.Initialize (data_rec, random.Seed () + 1); if (!program.Compile (program_file, Report_Flag (PRINT_SCRIPT))) { Error ("Compiling Conversion Script"); } if (Report_Flag (PRINT_STACK)) { Header_Number (PRINT_STACK); program.Print_Commands (false); } Header_Number (0); }
void LinkSum::Program_Control (void) { int i, field, ngroup, num; bool binary; String key, token; Location_File *location_file; Db_Field *fld; Doubles dbl; Doubles_Itr itr; //---- set the equivalence flags ---- Zone_Equiv_Flag (Check_Control_Key (NEW_GROUP_TRAVEL_FILE)); group_select = Set_Control_Flag (SELECT_BY_LINK_GROUP); Link_Equiv_Flag (group_select || Report_Flag (LINK_GROUP) || Report_Flag (TRAVEL_TIME) || Report_Flag (GROUP_REPORT) || Report_Flag (GROUP_SUMMARY) || Check_Control_Key (NEW_GROUP_SUMMARY_FILE)); //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); turn_flag = System_File_Flag (TURN_DELAY); Print (2, String ("%s Control Keys:") % Program ()); //---- open the compare performance file ---- key = Get_Control_String (COMPARE_PERFORMANCE_FILE); if (!key.empty ()) { compare_file.File_Type ("Compare Performance File"); Print (1); if (Check_Control_Key (COMPARE_PERFORMANCE_FORMAT)) { compare_file.Dbase_Format (Get_Control_String (COMPARE_PERFORMANCE_FORMAT)); } compare_file.Open (Project_Filename (key)); compare_flag = true; } num_inc = sum_periods.Num_Periods (); if (num_inc < 1) num_inc = 1; cap_factor = (double) sum_periods.Range_Length () / (Dtime (1, HOURS) * num_inc); if (cap_factor <= 0.0) cap_factor = 1.0; //---- open the compare link map file ---- key = Get_Control_String (COMPARE_LINK_MAP_FILE); if (!key.empty ()) { link_map_file.File_Type ("Compare Link Map File"); Print (1); if (Check_Control_Key (COMPARE_LINK_MAP_FORMAT)) { link_map_file.Dbase_Format (Get_Control_String (COMPARE_LINK_MAP_FORMAT)); } link_map_file.Open (Project_Filename (key)); link_map_flag = true; } //---- get minimum volume ---- minimum_volume = Get_Control_Double (MINIMUM_LINK_VOLUME); //---- person-based statistics ---- person_flag = Get_Control_Flag (PERSON_BASED_STATISTICS); //---- get the select by link group flag ---- group_select = Get_Control_Flag (SELECT_BY_LINK_GROUP); if (group_select || select_subareas || select_polygon || select_facilities) select_flag = true; //---- turning movement data ---- if (turn_flag) { //---- open the compare turn delays file ---- key = Get_Control_String (COMPARE_TURN_DELAY_FILE); if (!key.empty ()) { turn_compare_file.File_Type ("Compare Turn Delay File"); Print (1); if (Check_Control_Key (COMPARE_TURN_DELAY_FORMAT)) { turn_compare_file.Dbase_Format (Get_Control_String (COMPARE_TURN_DELAY_FORMAT)); } turn_compare_file.Open (Project_Filename (key)); turn_compare_flag = true; } //---- select turn nodes---- key = exe->Get_Control_Text (TURN_NODE_RANGE); if (!key.empty () && !key.Equals ("ALL")) { if (!turn_range.Add_Ranges (key)) { exe->Error ("Adding Turn Node Ranges"); } } } //---- create link activity file ---- key = Get_Control_String (NEW_LINK_ACTIVITY_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Link Activity File"); } location_file = System_Location_File (); binary = (location_file->Record_Format () == BINARY); Print (1); activity_file.File_Type ("New Link Activity File"); if (Check_Control_Key (NEW_LINK_ACTIVITY_FORMAT)) { activity_file.Dbase_Format (Get_Control_String (NEW_LINK_ACTIVITY_FORMAT)); } activity_file.Create (Project_Filename (key)); //---- copy location field name ---- key = Get_Control_Text (COPY_LOCATION_FIELDS); if (key.empty ()) { Error ("Location Field Names are Required for Link Activity File"); } link_db.File_Type ("Link Location Database"); //---- set required fields ---- link_db.Add_Field ("LINK", DB_INTEGER, 10); activity_file.Add_Field ("LINK", DB_INTEGER, 10); //---- copy selected fields ---- while (!key.Split (token)) { field = location_file->Field_Number (token); if (field < 0) { Error (String ("Field %s was Not Found in the Location File") % token); } field_list.push_back (field); fld = location_file->Field (field); link_db.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); activity_file.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); } activity_file.Write_Header (); activity_flag = true; } //---- create zone travel file ---- key = Get_Control_String (NEW_ZONE_TRAVEL_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Zone Travel File"); } Print (1); zone_file.File_Type ("New Zone Travel File"); if (Check_Control_Key (NEW_ZONE_TRAVEL_FORMAT)) { zone_file.Dbase_Format (Get_Control_String (NEW_ZONE_TRAVEL_FORMAT)); } zone_file.Create (Project_Filename (key)); zone_flag = true; } //---- create zone group travel file ---- key = Get_Control_String (NEW_GROUP_TRAVEL_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Group Travel File"); } Print (1); group_file.File_Type ("New Group Travel File"); if (Check_Control_Key (NEW_GROUP_TRAVEL_FORMAT)) { group_file.Dbase_Format (Get_Control_String (NEW_GROUP_TRAVEL_FORMAT)); } group_file.Create (Project_Filename (key)); group_flag = true; } if (!activity_flag && !zone_flag && !group_flag) { System_File_False (LOCATION); } //---- get the number of direction groups ---- ngroup = Highest_Control_Group (NEW_LINK_DIRECTION_FILE, 0); if (ngroup > 0) { Dir_Group group, *group_ptr; //---- process each group ---- for (i=1; i <= ngroup; i++) { key = Get_Control_String (NEW_LINK_DIRECTION_FILE, i); if (key.empty ()) continue; Print (1); dir_group.push_back (group); group_ptr = &dir_group.back (); group_ptr->group = i; group_ptr->file = new Link_Direction_File (); group_ptr->file->File_Type (String ("New Link Direction File #%d") % i); if (Check_Control_Key (NEW_LINK_DIRECTION_FORMAT, i)) { group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DIRECTION_FORMAT, i)); } group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ()); group_ptr->file->Create (Project_Filename (key)); //---- get the field name ---- key = Get_Control_Text (NEW_LINK_DIRECTION_FIELD, i); if (key.empty ()) { Error (String ("New Link Direction Field #%d is Missing") % i); } group_ptr->field = Performance_Code (key); group_ptr->index = Get_Control_Flag (NEW_LINK_DIRECTION_INDEX, i); group_ptr->flip = Get_Control_Flag (NEW_LINK_DIRECTION_FLIP, i); if (group_ptr->flip && !compare_flag) { Warning ("Link Direction Flipping requires Comparison Data"); group_ptr->flip = false; } Set_Link_Dir (group_ptr); } } //---- get the number of groups ---- ngroup = Highest_Control_Group (NEW_LINK_DATA_FILE, 0); if (ngroup > 0) { Data_Group group, *group_ptr; //---- process each group ---- for (i=1; i <= ngroup; i++) { key = Get_Control_String (NEW_LINK_DATA_FILE, i); if (key.empty ()) continue; Print (1); data_group.push_back (group); group_ptr = &data_group.back (); group_ptr->group = i; group_ptr->file = new Link_Data_File (); group_ptr->file->File_Type (String ("New Link Data File #%d") % i); if (Check_Control_Key (NEW_LINK_DATA_FORMAT, i)) { group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DATA_FORMAT, i)); } group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ()); group_ptr->file->Create (Project_Filename (key)); //---- get the field name ---- key = Get_Control_Text (NEW_LINK_DATA_FIELD, i); if (key.empty ()) { Error (String ("New Link Data Field #%d is Missing") % i); } group_ptr->field = Performance_Code (key); Set_Link_Data (group_ptr); } } //---- data summary file ---- key = Get_Control_String (NEW_DATA_SUMMARY_FILE); if (!key.empty ()) { Print (1); summary_file.File_Type ("New Data Summary File"); if (Check_Control_Key (NEW_DATA_SUMMARY_FORMAT)) { summary_file.Dbase_Format (Get_Control_String (NEW_DATA_SUMMARY_FORMAT)); } summary_file.Add_Field ("MEASURE", DB_STRING, 40); summary_file.Add_Field ("VALUE", DB_DOUBLE, 12.2); if (compare_flag) summary_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2); summary_file.Create (Project_Filename (key)); summary_flag = true; //---- data summary periods ---- if (!Control_Key_Empty (NEW_DATA_SUMMARY_PERIODS)) { periods_flag = data_periods.Add_Ranges (Get_Control_Text (NEW_DATA_SUMMARY_PERIODS)); } //---- data summary ratios ---- if (Check_Control_Key (NEW_DATA_SUMMARY_RATIOS)) { Double_List list; Dbl_Itr itr; Get_Control_List (NEW_DATA_SUMMARY_RATIOS, list); for (i=0, itr = list.begin (); itr != list.end (); itr++, i++) { if (i > 0 && *itr >= 1.0) { data_ratios.push_back (Round (*itr * 100.0)); ratios_flag = true; } } } } //---- group summary file ---- key = Get_Control_String (NEW_GROUP_SUMMARY_FILE); if (!key.empty ()) { Print (1); group_sum_file.File_Type ("New Group Summary File"); if (Check_Control_Key (NEW_GROUP_SUMMARY_FORMAT)) { group_sum_file.Dbase_Format (Get_Control_String (NEW_GROUP_SUMMARY_FORMAT)); } group_sum_file.Add_Field ("MEASURE", DB_STRING, 40); group_sum_file.Add_Field ("VALUE", DB_DOUBLE, 12.2); if (compare_flag) group_sum_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2); group_sum_file.Create (Project_Filename (key)); group_sum_flag = true; } //---- read report types ---- List_Reports (); if (!compare_flag && (Report_Flag (TIME_CHANGE) || Report_Flag (VOLUME_CHANGE) || Report_Flag (TOP_TIME_CHANGE) || Report_Flag (TOP_VOL_CHANGE) || Report_Flag (RELATIVE_GAP))) { Error ("A Compare Performance File is Required for Change Reports"); } //---- process support data ---- if (Link_Equiv_Flag ()) { link_equiv.Read (Report_Flag (LINK_EQUIV)); } if (group_flag) { zone_equiv.Read (Report_Flag (ZONE_EQUIV)); } //---- allocate work space ---- if (periods_flag || ratios_flag) { num = (periods_flag) ? (int) data_periods.size () : 1; num += (ratios_flag) ? (int) data_ratios.size () : 1; if (num_inc + 1 > num) { num = num_inc + 1; } } else { num = num_inc + 1; } sum_bin.assign (num, dbl); for (itr = sum_bin.begin (); itr != sum_bin.end (); itr++) { itr->assign (NUM_SUM_BINS, 0.0); } }