void SimSubareas::Program_Control (void) { String key; //---- create the network files ---- Data_Service::Program_Control (); Node_File *file = System_Node_File (true); file->Subarea_Flag (true); file->Clear_Fields (); file->Create_Fields (); file->Write_Header (); Print (2, String ("%s Control Keys:") % Program ()); //---- get the subarea boundary file ---- key = Get_Control_String (SUBAREA_BOUNDARY_FILE); if (!key.empty ()) { boundary_file.File_Type ("Subarea Boundary File"); if (!boundary_file.Open (Project_Filename (key))) { Error (String ("Opening Boundary File %s") % boundary_file.Filename ()); } if (Check_Control_Key (SUBAREA_DATA_FIELD)) { key = Get_Control_Text (SUBAREA_DATA_FIELD); subarea_field = boundary_file.Required_Field (key); Print (0, String (" (Number = %d)") % (subarea_field + 1)); } else { subarea_field = boundary_file.Required_Field ("SUBAREA", "ID", "NUMBER", "PARTITION", "SUB"); } boundary_flag = true; update_flag = Get_Control_Flag (SUBAREA_UPDATE_FLAG); } else { //---- get the number of subareas ---- num_subareas = Get_Control_Integer (NUMBER_OF_SUBAREAS); subarea_count.assign (num_subareas, 0); //---- get the center node number --- center = Get_Control_Integer (CENTER_NODE_NUMBER); } }
void Demand_Service::Program_Control (void) { int max_errors; char *str_ptr, *format_ptr; Format_Type default_format, file_format, demand_format; Access_Type access; //---- open network files ---- Network_Service::Program_Control (); demand_format = default_format = Demand_Format (); File_Data *file = demand_file; //---- get the default demand file format ---- format_ptr = Get_Control_String (DEMAND_FILE_FORMAT); if (format_ptr != NULL) { demand_format = Format_Code (format_ptr); if (demand_format != default_format) { Print (2, "Demand File Format = %s", format_ptr); } } else { demand_format = default_format; } Demand_Format (demand_format); //---- open the files ---- for (int i=0; i < END_DEMAND; i++, file++) { if (file->flag || file->option) { //---- initialize overlaid data classes ---- if (i == LINK_DELAY || i == NEW_LINK_DELAY) { if (dir_array == NULL) { dir_array = (Dir_Array *) new TTime_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == PERFORMANCE || i == NEW_PERFORMANCE) { if (dir_array == NULL) { dir_array = (Dir_Array *) new Performance_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == RIDERSHIP || i == NEW_RIDERSHIP) { if (line_array == NULL) { line_array = (Line_Array *) new Rider_Array (); } } //---- read the key ---- str_ptr = Get_Control_String (file->key); if (str_ptr == NULL) { if (file->flag) goto control_error; } else { Print (1); file->flag = true; format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { file_format = Format_Code (format_ptr); } else { file_format = demand_format; } access = file->access; switch (i) { case HOUSEHOLD: case NEW_HOUSEHOLD: file->file = new Household_File (Project_Filename (str_ptr), access, file_format); break; case POPULATION: case NEW_POPULATION: file->file = new Population_File (Project_Filename (str_ptr), access, file_format); break; case LINK_DELAY: case PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format); if (((Db_Base *) file->file)->Dbase_Format () == VERSION3) { if (i == LINK_DELAY) { ttime_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (ttime_data.Period_Size ()); } else { performance_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (performance_data.Period_Size ()); } } //---- max link delay errors ---- str_ptr = Get_Control_String (MAX_LINK_DELAY_ERRORS); if (str_ptr != NULL) { Get_Integer (str_ptr, &max_errors); if (max_delay_errors < 0) { Error ("Maximum Link Delay Errors %d is Out of Range", max_errors); } Print (1, "Maximum Number of Link Delay Errors = %d", max_errors); Max_Delay_Errors (max_errors); } break; case NEW_LINK_DELAY: case NEW_PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format, Time_Increment ()); break; case RIDERSHIP: case NEW_RIDERSHIP: file->file = new Ridership_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE_TYPE: case NEW_VEHICLE_TYPE: file->file = new Veh_Type_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE: case NEW_VEHICLE: file->file = new Vehicle_File (Project_Filename (str_ptr), access, file_format); //---- sort vehicles ---- if (i == VEHICLE) { if (Get_Control_String (SORT_VEHICLES) != NULL) { sort_flag = Get_Control_Flag (SORT_VEHICLES); } if (sort_flag) { Print (1, "Vehicle File will be Sorted by Vehicle ID"); } else { Print (1, "Vehicle File is Sorted by Vehicle ID"); } } break; case ACTIVITY: case NEW_ACTIVITY: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Activity_File * act_file = new Activity_File (access, file_format); file->file = act_file; if (Partition ()) { act_file->Filename (str_ptr, Partition_Number ()); } else { act_file->Filename (str_ptr); } Print_Filename (1, act_file->File_Type (), act_file->Groupname ()); if (!act_file->Open (0)) { File_Error (act_file->File_Type (), act_file->Filename ()); } } else { file->file = new Activity_File (str_ptr, access, file_format); } break; case TRIP: case NEW_TRIP: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Trip_File * trip_file = new Trip_File (access, file_format); file->file = trip_file; if (Partition ()) { trip_file->Filename (str_ptr, Partition_Number ()); } else { trip_file->Filename (str_ptr); } Print_Filename (1, trip_file->File_Type (), trip_file->Groupname ()); if (!trip_file->Open (0)) { File_Error (trip_file->File_Type (), trip_file->Filename ()); } } else { file->file = new Trip_File (str_ptr, access, file_format); } break; case BOUNDARY_SPEED: case NEW_BOUNDARY_SPEED: file->file = new Boundary_File (Project_Filename (str_ptr), access, file_format); break; } } } } Demand_Format (default_format); control_flag = true; return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
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); } }
void ConvertTours::Program_Control (void) { int i, j, num_file, lvalue; double dvalue; bool factor_flag; char *str_ptr, buffer [FIELD_BUFFER], *format_ptr; File_Group *group; char *time_control [] = {"ORIGIN", "DESTINATION", "MID-TRIP", NULL}; factor_flag = false; //---- open demand and network files ---- Demand_Service::Program_Control (); //---- set the file points ---- zone_flag = Network_File_Flag (ZONE); trip_file = (Trip_File *) Demand_Db_Base (NEW_TRIP); household_file = (Household_File *) Demand_Db_Base (NEW_HOUSEHOLD); population_file = (Population_File *) Demand_Db_Base (NEW_POPULATION); vehicle_file = (Vehicle_File *) Demand_Db_Base (NEW_VEHICLE); //---- check for copy commands ---- if (Demand_File_Flag (TRIP)) { trip_file->Clear_Fields (); trip_file->Replicate_Fields (Demand_Db_Base (TRIP)); trip_file->Write_Header (); } if (Demand_File_Flag (HOUSEHOLD)) { household_file->Clear_Fields (); household_file->Replicate_Fields (Demand_Db_Base (HOUSEHOLD)); household_file->Write_Header (); } if (Demand_File_Flag (POPULATION)) { population_file->Clear_Fields (); population_file->Replicate_Fields (Demand_Db_Base (POPULATION)); population_file->Write_Header (); } if (Demand_File_Flag (VEHICLE)) { vehicle_file->Clear_Fields (); vehicle_file->Replicate_Fields (Demand_Db_Base (VEHICLE)); vehicle_file->Write_Header (); } //---- get the tour data file ---- str_ptr = Get_Control_String (TOUR_DATA_FILE); if (str_ptr == NULL) goto control_error; Print (1); format_ptr = Get_Control_String (TOUR_DATA_FORMAT); if (format_ptr != NULL) { tour_file.Dbase_Format (format_ptr); } tour_file.Open (Project_Filename (str_ptr)); tour_file_db.Add_Field ("SORTKEY", INTEGER, 10); tour_file_db.Replicate_Fields (&tour_file, true); tour_file_db.File_ID ("Tour"); //---- set tour field numbers ---- Print (1); str_ptr = Get_Control_String (TOUR_HOUSEHOLD_FIELD); if (str_ptr != NULL) { lvalue = tour_file.HHold_Field (str_ptr); } else { lvalue = tour_file.HHold_Field (); } if (lvalue > 0) { Print (1, "Tour Household Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_PERSON_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Person_Field (str_ptr); } else { lvalue = tour_file.Person_Field (); } if (lvalue > 0) { Print (1, "Tour Person Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_NUMBER_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Tour_Field (str_ptr); } else { lvalue = tour_file.Tour_Field (); } if (lvalue > 0) { Print (1, "Tour Number Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_PURPOSE_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Purpose_Field (str_ptr); } else { lvalue = tour_file.Purpose_Field (); } if (lvalue > 0) { Print (1, "Tour Purpose Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_MODE_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Mode_Field (str_ptr); } else { lvalue = tour_file.Mode_Field (); } if (lvalue > 0) { Print (1, "Tour Mode Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_ORIGIN_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Origin_Field (str_ptr); } else { lvalue = tour_file.Origin_Field (); } if (lvalue > 0) { Print (1, "Tour Origin Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_DESTINATION_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Dest_Field (str_ptr); } else { lvalue = tour_file.Dest_Field (); } if (lvalue > 0) { Print (1, "Tour Destination Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_STOP_OUT_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Stop_Out_Field (str_ptr); } else { lvalue = tour_file.Stop_Out_Field (); } if (lvalue > 0) { Print (1, "Tour Stop Out Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_STOP_IN_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Stop_In_Field (str_ptr); } else { lvalue = tour_file.Stop_In_Field (); } if (lvalue > 0) { Print (1, "Tour Stop In Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_START_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Start_Field (str_ptr); } else { lvalue = tour_file.Start_Field (); } if (lvalue > 0) { Print (1, "Tour Start Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_RETURN_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Return_Field (str_ptr); } else { lvalue = tour_file.Return_Field (); } if (lvalue > 0) { Print (1, "Tour Return Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } str_ptr = Get_Control_String (TOUR_GROUP_FIELD); if (str_ptr != NULL) { lvalue = tour_file.Group_Field (str_ptr); } else { lvalue = tour_file.Group_Field (); } if (lvalue > 0) { Print (1, "Tour Group Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue); } //---- get the tour group script ----- str_ptr = Get_Control_String (TOUR_GROUP_SCRIPT); if (str_ptr != NULL) { script_file.File_Type ("Tour Group Script"); script_file.Open (Project_Filename (str_ptr)); script_flag = true; } //---- get the household list file ----- str_ptr = Get_Control_String (HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("Household List File"); hhlist_file.Open (Project_Filename (str_ptr)); hhlist_flag = true; } //---- get the starting hhold id ---- str_ptr = Get_Control_String (STARTING_HOUSEHOLD_ID); if (str_ptr != NULL) { Get_Integer (str_ptr, &hhold_id); if (hhold_id < 1) { Error ("Starting Household ID %d is Out of Range", hhold_id); } } else { hhold_id = 1; } Print (2, "Starting Household ID = %d", hhold_id); //---- get the starting vehicle id ---- str_ptr = Get_Control_String (STARTING_VEHICLE_ID); if (str_ptr != NULL) { Get_Integer (str_ptr, &vehicle_id); if (vehicle_id < 1) { Error ("Starting Vehicle ID %d is Out of Range", vehicle_id); } } else { vehicle_id = 1; } Print (1, "Starting Vehicle ID = %d", vehicle_id); //---- get the time of day format ---- str_ptr = Get_Control_String (TIME_OF_DAY_FORMAT); if (str_ptr == NULL) { str_ptr = "24_HOUR_CLOCK"; } if (!trip_time.Format (str_ptr)) { Error ("Time of Day Format %s was Unrecognized", str_ptr); } Print (2, "Time of Day Format = %s", str_ptr); //---- get the additional travel time ---- str_ptr = Get_Control_String (ADDITIONAL_TRAVEL_TIME); if (str_ptr != NULL) { Get_Integer (str_ptr, &additional_time); if (additional_time < 0) { Error ("Additional Travel Time %d is Out of Range", additional_time); } } Print (2, "Additional Travel Time = %d seconds", additional_time); //---- open the zone location map ---- str_ptr = Get_Control_String (ZONE_LOCATION_MAP_FILE); if (str_ptr != NULL) { zone_loc_flag = true; Print (1); zone_loc_map.Open (Project_Filename (str_ptr)); } //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random_org.Seed (atoi (str_ptr)); } Print (2, "Random Number Seed = %d", random_org.Seed ()); random_des.Seed (random_org.Seed () + 1); random_tod.Seed (random_org.Seed () + 2); random_stop.Seed (random_org.Seed () + 3); //---- open the zone equivalence ---- str_ptr = Get_Control_String (ZONE_EQUIVALENCE_FILE); if (str_ptr != NULL) { equiv_flag = true; Print (1); zone_equiv.Open (Project_Filename (str_ptr)); } //---- open the travel time skim ---- str_ptr = Get_Control_String (TRAVEL_TIME_FILE); if (str_ptr != NULL) { skim_flag = true; Print (1); skim_file.Open (Project_Filename (str_ptr)); } //---- open the diurnal allocation file ---- str_ptr = Get_Control_String (NEW_DIURNAL_FILE); if (str_ptr != NULL) { diurnal_flag = true; diurnal_file.File_Type ("New Diurnal File"); Print (1); diurnal_file.Create (Project_Filename (str_ptr)); } //---- write the report names ---- List_Reports (); //---- get the number of files ---- num_file = Highest_Control_Group (TRIP_TIME_FILE_x, 0); if (num_file == 0) { Error ("No Trip Time Files were Found"); } //---- allocate file space ---- if (!file_group.Max_Records (num_file)) { Error ("Insufficient Memory for %d File Groups", num_file); } //---- process each file ---- for (i=1; i <= num_file; i++) { //---- get the trip time file ---- str_ptr = Get_Control_String (TRIP_TIME_FILE_x, i); if (!Break_Check (15)) { Print (1); } if (str_ptr == NULL) continue; group = file_group.New_Record (true); group->Group (i); group->Time_File (new Diurnal_File ()); str_fmt (buffer, sizeof (buffer), "Trip Time File #%d", i); group->Time_File ()->File_Type (buffer); format_ptr = Get_Control_String (TRIP_TIME_FORMAT_x, i); if (format_ptr != NULL) { group->Time_File ()->Dbase_Format (format_ptr); } group->Time_File ()->Open (Project_Filename (str_ptr)); //---- get the trip time field ---- if (!script_flag) { str_ptr = Get_Control_String (TRIP_TIME_FIELD_x, i); if (str_ptr != NULL) { if (!group->Time_Field (str_ptr)) { Error ("Trip Time Field %s was Not Found", str_ptr); } Print (1, "Trip Time Field Name = %s, Number = %d", str_ptr, group->Time_Field ()); } } //---- get the time period range ---- str_ptr = Get_Control_String (TIME_PERIOD_RANGE_x, i); if (str_ptr != NULL) { Print (1, "Time Period Range = %s", str_ptr); if (!group->Time_Periods (str_ptr)) { Error ("Time Period Range %s is Illogical", str_ptr); } } //---- get the time control point ---- str_ptr = Get_Control_String (TIME_CONTROL_POINT_x, i); if (str_ptr != NULL) { for (j=0; time_control [j] != NULL; j++) { if (str_cmp (str_ptr, time_control [j]) == 0) break; } if (time_control [j] == NULL) { Error ("Time Control Point %s was Unrecognized", str_ptr); } group->Method (j); } else { group->Method (0); } Print (1, "Time Control Point = %s", time_control [group->Method ()]); //---- get the origin weight ---- str_ptr = Get_Control_String (ORIGIN_WEIGHT_FIELD_x, i); if (str_ptr != NULL) { group->Org_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr)); if (group->Org_Wt () == 0) { Error ("Origin Weight Field %s was Not Found in the Activity Location File", str_ptr); } Print (1, "Origin Weight Field Name = %s, Number = %d", str_ptr, group->Org_Wt ()); } else { group->Org_Wt (0); Print (1, "No Origin Weight Field --> Equal Weights"); } //---- get the destination weight ---- str_ptr = Get_Control_String (DESTINATION_WEIGHT_FIELD_x, i); if (str_ptr != NULL) { group->Des_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr)); if (group->Des_Wt () == 0) { Error ("Destination Weight Field %s was Not Found in the Activity Location File", str_ptr); } Print (1, "Destination Weight Field Name = %s, Number = %d", str_ptr, group->Des_Wt ()); } else { group->Des_Wt (0); Print (1, "No Destination Weight Field --> Equal Weights"); } //---- get the distance weight ---- str_ptr = Get_Control_String (DISTANCE_WEIGHT_FLAG_x, i); if (str_ptr != NULL) { group->Dist_Wt (Get_Control_Flag (DISTANCE_WEIGHT_FLAG_x, i)); Print (1, "Distance Weight Flag = %s", str_ptr); } else { group->Dist_Wt (true); } //---- get the stop weight ---- str_ptr = Get_Control_String (STOP_WEIGHT_FIELD_x, i); if (str_ptr != NULL) { group->Stop_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr)); if (group->Stop_Wt () == 0) { Error ("Stop Weight Field %s was Not Found in the Activity Location File", str_ptr); } Print (1, "Stop Weight Field Name = %s, Number = %d", str_ptr, group->Stop_Wt ()); } else { group->Stop_Wt (0); Print (1, "No Stop Weight Field --> Equal Weights"); } //---- get the trip purpose ---- str_ptr = Get_Control_String (TRIP_PURPOSE_CODE_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue > 100) { Error ("Trip Purpose %d is Out of Range (0..100)", lvalue); } group->Purpose (lvalue); } else { group->Purpose (1); } Print (1, "Trip Purpose Code = %d", group->Purpose ()); //---- get the travel mode ---- str_ptr = Get_Control_String (TRAVEL_MODE_CODE_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue >= MAX_MODE) { Error ("Travel Mode %d is Out of Range (0..%d)", lvalue, MAX_MODE); } group->Mode (lvalue); } else { group->Mode (DRIVE_ALONE); } Print (1, "Travel Mode Code = %d", group->Mode ()); //---- stop duration ---- str_ptr = Get_Control_String (TRIP_STOP_DURATION_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > 4 * 60) { Error ("Trip Stop Duration %d is Out of Range (1..240)", lvalue); } } else { lvalue = 5; } group->Duration (lvalue * 60); //---- average speed ---- str_ptr = Get_Control_String (AVERAGE_TRAVEL_SPEED_x, i); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 1.0 || dvalue > 50.0) { Error ("Average Travel Speed %.1lf is Out of Range (1..50)", dvalue); } } else { dvalue = 10.0; } group->Speed (Round (dvalue)); Print (1, "Average Travel Speed = %.1lf (meters/second)", UnRound (group->Speed ())); //---- get the vehicle type ---- str_ptr = Get_Control_String (VEHICLE_TYPE_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > 20) { Error ("Vehicle Type %d is Out of Range (1..20)", lvalue); } group->Type (lvalue); } else { group->Type (1); } //---- get the vehicle subtype ---- str_ptr = Get_Control_String (VEHICLE_SUBTYPE_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue > 20) { Error ("Vehicle Subtype %d is Out of Range (0..20)", lvalue); } group->SubType (lvalue); } else { group->SubType (0); } Print (1, "Vehicle Type = %d, Subtype = %d", group->Type (), group->SubType ()); //---- get the trip scaling factor ---- str_ptr = Get_Control_String (TRIP_SCALING_FACTOR_x, i); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.001 || dvalue > 100.0) { Error ("Trip Scaling Factor %.2lf is Out of Range (0.001..100.0)", dvalue); } group->Scaling_Factor (dvalue); Print (1, "Trip Scaling Factor = %.3lf", dvalue); } else { group->Scaling_Factor (1.0); } //---- get the trip adjustment factors ---- str_ptr = Get_Control_String (TRIP_ADJUSTMENT_FACTORS_x, i); if (str_ptr != NULL) { group->Trip_Factor (new Factor_File ()); str_fmt (buffer, sizeof (buffer), "Trip Adjustment Factors #%d", i); group->Trip_Factor ()->File_Type (buffer); format_ptr = Get_Control_String (TRIP_ADJUSTMENT_FORMAT_x, i); if (format_ptr != NULL) { group->Trip_Factor ()->Dbase_Format (format_ptr); } if (!group->Trip_Factor ()->Open (Project_Filename (str_ptr))) { Error ("Opening Trip Adjustment Factors #%d", i); } factor_flag = true; } //---- time period equivalence ---- //if (factor_flag || group->Trip_File ()->Period_Flag ()) { // str_ptr = Get_Control_String (TIME_PERIOD_EQUIVALENCE_x, i); // if (str_ptr != NULL) { // if (!group->Time_Equiv_File (Project_Filename (str_ptr))) { // Error ("Opening Time Period Equivalence #%d", i); // } // } else if (group->Trip_File ()->Period_Flag ()) { // Warning ("Trip Table Time Periods will be Ignored"); // } //} //---- set the field map ---- if (group->Org_Wt () != 0) { j = field_map.Get_Index (group->Org_Wt ()); if (j == 0) { field_map.Add (group->Org_Wt ()); group->Org_Wt (field_map.Record_Index ()); } else { group->Org_Wt (j); } } if (group->Des_Wt () != 0) { j = field_map.Get_Index (group->Des_Wt ()); if (j == 0) { field_map.Add (group->Des_Wt ()); group->Des_Wt (field_map.Record_Index ()); } else { group->Des_Wt (j); } } //---- add the group record to the list ---- file_group.Add (); } Write (2, "Highest Trip Group Number = %d", num_file); Write (1, "Number of Trip Table Groups = %d", file_group.Num_Records ()); if (field_map.Num_Records () > 0) { Print (2, "Number of Unique Activity Location Weight Fields = %d", field_map.Num_Records ()); Convert_Location *loc_ptr = (Convert_Location *) location_data.New_Record (); loc_ptr->Num_Weight (field_map.Num_Records ()); } Show_Message (1); //---- read the zone equiv ---- if (factor_flag) { if (equiv_flag) { zone_equiv.Read (Report_Flag (ZONE_EQUIV)); } else { Write (2, "Trip Adjustment Factors are Zone-Based"); } } //---- read the zone location map ---- if (zone_loc_flag) { zone_loc_map.Read (false); } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void DynusTPlan::Program_Control (void) { int increment; char *str_ptr, buffer [STRING_BUFFER]; //---- open network files ---- Demand_Service::Program_Control (); if (Demand_File_Flag (VEHICLE) && !Demand_File_Flag (VEHICLE_TYPE)) { Error ("A Vehicle Type File is needed to Convert Vehicle IDs to Type Codes"); } if (!Demand_File_Flag (VEHICLE) && Demand_File_Flag (VEHICLE_TYPE)) { Error ("A Vehicle File is needed to Convert Vehicle IDs to Type Codes"); } //---- open the plan file ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (PLAN_FILE); if (str_ptr == NULL) goto control_error; str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, plan_file.File_Type (), str_ptr); plan_file.Filename (str_ptr); plan_file.Plan_Sort (TIME_SORT); str_ptr = Get_Control_String (PLAN_FORMAT); if (str_ptr != NULL) { plan_file.File_Format (str_ptr); Print (1, "%s Format = %s", plan_file.File_Type (), str_ptr); } plan_file.Node_Based_Flag (type_flag); if (!plan_file.Open (0)) { File_Error ("Opening Plan File", plan_file.Filename ()); } type_flag = plan_file.Node_Based_Flag (); //---- node list paths ---- if (type_flag) { Print (1, "Plan File contains Node List Paths"); } else { Print (1, "Plan File contains Link List Paths"); } //---- get output time increment ---- str_ptr = Get_Control_String (OUTPUT_TIME_INCREMENT); if (str_ptr != NULL) { increment = atol (str_ptr); if (increment < 0 || increment > 240) { Error ("Output Time Increment %d is Out of Range (0-240)", increment); } increment *= 60; } if (!increment == 0) { time_range.Period_Flag (true); } time_range.Increment (increment); //---- get the select time period ---- str_ptr = Get_Control_String (SELECT_TIME_PERIOD); time_range.Format (Time_Step::CLOCK24); if (str_ptr != NULL) { Print (2, "Select Time Period = %s", str_ptr); if (!time_range.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } } else { time_range.Add_Ranges ("0:00..24:00"); } if (increment > 0) { Print (1, "Output Time Increment = %d minutes", (increment / 60)); } start_time = time_range.First ()->Low (); //---- get the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } select_flag = (percent != 100.0); } Print (2, "Selection Percentage = %.1lf%%", percent); percent /= 100.0; //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } if (str_ptr != NULL || percent != 1.0) { Print (1, "Random Number Seed = %d", random.Seed ()); } //---- get the DynusT directory ---- str_ptr = Get_Control_String (DYNUST_PLAN_DIRECTORY); if (str_ptr == NULL) goto control_error; str_cpy (plan_dir, sizeof (plan_dir), Project_Filename (str_ptr)); Print (2, "DynusT Plan Directory = %s", plan_dir); //---- vehicle.dat ---- veh_file.File_Type ("DynusT Vehicle File"); str_fmt (buffer, sizeof (buffer), "%s/vehicle.dat", plan_dir); veh_file.Create (buffer); //---- path.dat ---- path_file.File_Type ("DynusT Path File"); str_fmt (buffer, sizeof (buffer), "%s/path.dat", plan_dir); path_file.Create (buffer); //---- DynusT user class ---- str_ptr = Get_Control_String (DYNUST_USER_CLASS); if (str_ptr != NULL) { user_class = atoi (str_ptr); Print (2, "DynusT User Class = %d", user_class); if (user_class < 1 || user_class > 5) { Error ("DynusT User Class %d is Out of Range (1..5)", user_class); } } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void Network_Service::Program_Control (void) { bool first, new_flag, notes_flag; char *str_ptr, *format_ptr; Format_Type default_format, file_format, network_format; Access_Type access; first = true; new_flag = false; network_format = default_format = Network_Format (); if (Get_Control_String (CREATE_NOTES_AND_NAME_FIELDS) != NULL) { Notes_Name_Flag (Get_Control_Flag (CREATE_NOTES_AND_NAME_FIELDS)); } notes_flag = Notes_Name_Flag (); File_Data *file = network_file; //---- open the files ---- for (int i=0; i < END_NETWORK; i++, file++) { if (file->flag || file->option) { if (i == DIRECTORY) { first = true; //---- get the network format ---- format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { network_format = Format_Code (format_ptr); if (network_format != default_format) { Print (2, "Default Network Format = %s", format_ptr); first = false; } } else { network_format = default_format; } Network_Format (network_format); } else if (i == NEW_DIRECTORY) { first = true; //---- get the new network format ---- format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { network_format = Format_Code (format_ptr); if (network_format != default_format) { Print (2, "Default New Network Format = %s", format_ptr); first = false; } } else { network_format = default_format; } Network_Format (network_format); } //---- get the filename ---- str_ptr = Get_Control_String (file->key); if (str_ptr == NULL) { if (file->flag) goto control_error; } else { if (first) { Print (1); first = false; } file->flag = true; if (i == DIRECTORY) { Print_Filename (1, "Network Directory", str_ptr); Network_Directory (str_ptr); } else if (i == NEW_DIRECTORY) { Print_Filename (1, "New Network Directory", str_ptr); New_Directory (str_ptr); } else { format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { file_format = Format_Code (format_ptr); //if (file_format != network_format) Print (1); } else { file_format = network_format; } access = file->access; if (i > NEW_DIRECTORY) { new_flag = true; str_ptr = New_Filename (str_ptr); } else { str_ptr = Network_Filename (str_ptr); } switch (i) { case NODE: case NEW_NODE: file->file = new Node_File (str_ptr, access, file_format, notes_flag); break; case ZONE: case NEW_ZONE: file->file = new Zone_File (str_ptr, access, file_format, notes_flag); break; case SHAPE: case NEW_SHAPE: file->file = new Shape_File (str_ptr, access, file_format, notes_flag); break; case LINK: case NEW_LINK: file->file = new Link_File (str_ptr, access, file_format, notes_flag); break; case POCKET_LANE: case NEW_POCKET_LANE: file->file = new Pocket_File (str_ptr, access, file_format, notes_flag); break; case LANE_USE: case NEW_LANE_USE: file->file = new Lane_Use_File (str_ptr, access, file_format, notes_flag); break; case TOLL: case NEW_TOLL: file->file = new Toll_File (str_ptr, access, file_format, notes_flag); break; case LANE_CONNECTIVITY: case NEW_LANE_CONNECTIVITY: file->file = new Connect_File (str_ptr, access, file_format, notes_flag); break; case TURN_PROHIBITION: case NEW_TURN_PROHIBITION: file->file = new Turn_File (str_ptr, access, file_format, notes_flag); if (((Turn_File *) (file->file))->Node_Based ()) AB_Key_Flag (true); break; case PARKING: case NEW_PARKING: file->file = new Parking_File (str_ptr, access, file_format, notes_flag); break; case ACTIVITY_LOCATION: case NEW_ACTIVITY_LOCATION: file->file = new Location_File (str_ptr, access, file_format, notes_flag); break; case PROCESS_LINK: case NEW_PROCESS_LINK: file->file = new Access_File (str_ptr, access, file_format, notes_flag); break; case UNSIGNALIZED_NODE: case NEW_UNSIGNALIZED_NODE: file->file = new Sign_File (str_ptr, access, file_format, notes_flag); break; case SIGNALIZED_NODE: case NEW_SIGNALIZED_NODE: file->file = new Signal_File (str_ptr, access, file_format, notes_flag); break; case TIMING_PLAN: case NEW_TIMING_PLAN: file->file = new Timing_File (str_ptr, access, file_format, notes_flag); break; case PHASING_PLAN: case NEW_PHASING_PLAN: file->file = new Phasing_File (str_ptr, access, file_format, notes_flag); break; case DETECTOR: case NEW_DETECTOR: file->file = new Detector_File (str_ptr, access, file_format, notes_flag); break; case SIGNAL_COORDINATOR: case NEW_SIGNAL_COORDINATOR: file->file = new Coordinator_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_STOP: case NEW_TRANSIT_STOP: file->file = new Stop_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_FARE: case NEW_TRANSIT_FARE: file->file = new Fare_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_ROUTE: case NEW_TRANSIT_ROUTE: file->file = new Line_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_SCHEDULE: case NEW_TRANSIT_SCHEDULE: file->file = new Schedule_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_DRIVER: case NEW_TRANSIT_DRIVER: file->file = new Driver_File (str_ptr, access, file_format, notes_flag); break; case ROUTE_HEADER: case NEW_ROUTE_HEADER: file->file = new Route_Header_File (str_ptr, access, file_format, notes_flag); break; case ROUTE_NODES: case NEW_ROUTE_NODES: file->file = new Route_Nodes_File (str_ptr, access, file_format, notes_flag); break; default: file->file = new Db_Header (Project_Filename (str_ptr)); break; } } } } } if (new_flag && notes_flag) { Print (2, "Notes and Name Fields will be Created"); } Network_Format (default_format); control_flag = true; return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void ZoneData::Program_Control (void) { int i, j, num, field; double size; bool flag; String key, name, buf; Field_Type type; Data_Group data_rec; Data_Itr data_itr; Polygon_Group poly_rec; Polygon_Itr poly_itr; Sum_Distance sum_rec; Sum_Itr sum_itr; Field_Ptr fld_ptr; field = 0; //---- open network files ---- Data_Service::Program_Control (); input_file = (Zone_File *) System_File_Handle (ZONE); output_file = (Zone_File *) System_File_Handle (NEW_ZONE); flag = exe->Notes_Name_Flag (); exe->Notes_Name_Flag (false); output_file->Clear_Fields (); Print (2, String ("%s Control Keys:") % Program ()); //---- copy existing fields ---- copy_flag = Get_Control_Flag (COPY_EXISTING_FIELDS); if (copy_flag) { output_file->Replicate_Fields (input_file, false); } else if (Get_Control_Flag (CLEAR_ALL_FIELDS)) { output_file->Clear_Fields (); } else { output_file->Create_Fields (); } exe->Notes_Name_Flag (flag); if (Check_Control_Key (ZONE_FILE_HEADER)) { if (Get_Control_Flag (ZONE_FILE_HEADER)) { output_file->Header_Lines (1); } else { output_file->Header_Lines (0); } } //---- get the new zone fields ---- num = Highest_Control_Group (NEW_ZONE_FIELD, 0); if (num == 0) { if (!copy_flag) { Warning ("No New Zone Fields"); } } else { Print (1); for (i=1; i <= num; i++) { key = Get_Control_Text (NEW_ZONE_FIELD, i); if (key.empty ()) continue; key.Split (name, ","); if (name.empty ()) goto data_error; field = output_file->Field_Number (name); if (field >= 0) goto field_error; key.Split (buf, ","); if (buf.empty () || buf.Starts_With ("I")) { type = DB_INTEGER; } else if (buf.Starts_With ("D") || buf.Starts_With ("R")) { type = DB_DOUBLE; } else if (buf.Starts_With ("S") || buf.Starts_With ("C")) { type = DB_STRING; } else { goto data_error; } key.Split (buf, ","); if (buf.empty ()) { if (type == DB_DOUBLE) { size = 10.2; } else { size = 10.0; } } else { size = buf.Double (); } output_file->Add_Field (name, type, size); } } if (exe->Notes_Name_Flag ()) { if (output_file->Field_Number ("NOTES") < 0) { output_file->Add_Field ("NOTES", DB_STRING, STRING_FIELD_SIZE); } } output_file->Write_Header (); //---- check for data files ---- num_data_files = Highest_Control_Group (DATA_FILE, 0); if (num_data_files > 0) { data_flag = true; } //---- check for polygon files ---- num_polygons = Highest_Control_Group (BOUNDARY_POLYGON_FILE, 0); if (num_polygons > 0) { polygon_flag = true; } //---- check for sum distances ---- num_sum_distance = Highest_Control_Group (SUM_ATTRIBUTE_DISTANCE, 0); if (num_sum_distance > 0) { sum_flag = true; } //---- read conversion script ---- key = Get_Control_String (CONVERSION_SCRIPT); if (key.empty ()) { if (data_flag || sum_flag || polygon_flag) { Error ("A Convertion Script is needed for Data Processing"); } } else { script_flag = true; Print (1); program_file.File_Type ("Conversion Script"); program_file.Open (Project_Filename (key)); Print (1); } //---- read data files ---- if (data_flag) { //---- open each file ---- for (i=1; i <= num_data_files; i++) { key = Get_Control_String (DATA_FILE, i); if (key.empty ()) continue; //---- create a header file and file labels ---- Print (1); data_group.push_back (data_rec); data_itr = --data_group.end (); data_itr->group = i; data_itr->file = new Db_Header (); data_itr->data_db = new Db_Sort_Array (); data_itr->file->File_Type (String ("Data File #%d") % i); data_itr->file->File_ID (String ("Data%d") % i); if (Check_Control_Key (DATA_FORMAT, i)) { data_itr->file->Dbase_Format (Get_Control_String (DATA_FORMAT, i)); } data_itr->file->Open (Project_Filename (key)); //---- find the data join field ---- key = Get_Control_Text (DATA_JOIN_FIELD, i); if (key.empty ()) goto control_error; field = data_itr->file->Field_Number (key); if (field < 0) { Error (String ("Data Join Field %s was Not Found") % key); } data_itr->join_field = field; Print (0, ", Number = ") << (field + 1); //---- find the zone join field ---- key = Get_Control_Text (ZONE_JOIN_FIELD, i); if (key.empty ()) goto control_error; field = input_file->Field_Number (key); if (field < 0) { Error (String ("Zone Join Field %s was Not Found") % key); } data_itr->zone_field = field; Print (0, ", Number = ") << (field + 1); } } //---- read the projection information ---- if (polygon_flag) { projection.Read_Control (); } //---- read the boundary polygons ---- if (polygon_flag) { if (!script_flag) { Error ("Boundary Polygon processing Requires a Conversion Script"); } //---- open each file ---- for (i=1; i <= num_polygons; i++) { key = Get_Control_String (BOUNDARY_POLYGON_FILE, i); if (key.empty ()) continue; polygons.push_back (poly_rec); poly_itr = --polygons.end (); poly_itr->group = i; poly_itr->file = new Arcview_File (); poly_itr->data_db = new Db_Sort_Array (); poly_itr->file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); Print (1); poly_itr->file->File_Type (String ("Boundary Polygon File #%d") % i); poly_itr->file->File_ID (String ("Polygon%d") % i); poly_itr->file->Open (Project_Filename (key)); } } //---- read sum distances ---- if (sum_flag) { //---- open each group ---- num = input_file->Num_Fields (); for (i=1; i <= num_sum_distance; i++) { if (!Check_Control_Key (SUM_ATTRIBUTE_DISTANCE, i)) continue; //---- create a header file and file labels ---- Print (1); sum_group.push_back (sum_rec); sum_itr = --sum_group.end (); sum_itr->group = i; sum_itr->distance = Round (Get_Control_Double (SUM_ATTRIBUTE_DISTANCE, i)); sum_itr->data_db = new Db_Sort_Array (); field = input_file->Zone_Field (); fld_ptr = input_file->Field (field); sum_itr->data_db->File_Type (String ("Sum Attribute Distance #%d") % i); sum_itr->data_db->File_ID (String ("SumZone%d") % i); sum_itr->data_db->Add_Field (fld_ptr->Name (), DB_INTEGER, 10); sum_itr->data_db->Add_Field ("Z_COUNT", DB_INTEGER, 10); sum_itr->field_map.push_back (field); sum_itr->field_map.push_back (-1); for (j=0; j < num; j++) { if (j == field) continue; fld_ptr = input_file->Field (j); if (fld_ptr->Type () == DB_INTEGER || fld_ptr->Type () == DB_DOUBLE) { sum_itr->field_map.push_back (j); sum_itr->data_db->Add_Field (fld_ptr->Name (), DB_DOUBLE, sizeof (double), NO_UNITS, true); } } } } Show_Message (1); return; control_error: Error (String ("Missing Control Key = %s") % Current_Key ()); data_error: Error (String ("New Zone Field %d is Improperly Specified") % i); field_error: Error (String ("New Zone Field %s already exists as Field %d") % name % field); }
void SmoothData::Program_Control (void) { int i, lvalue, nfile, nheader, nfield, increment, max_field; int naverage, default_average, niter, default_iter, max_size, max_iter; char *str_ptr, *format_ptr, buffer [FIELD_BUFFER]; char input_data [FIELD_BUFFER], output_data [FIELD_BUFFER]; char input_format [FIELD_BUFFER], output_format [FIELD_BUFFER]; char initial_file [STRING_BUFFER], initial_format [FIELD_BUFFER]; double dvalue, forward, backward, factor; bool loop_flag, initial_flag, replicate_flag; File_Group *group_ptr; nfile = 0; nheader = 1; nfield = 0; max_field = 100; increment = 0; default_average = 3; max_size = 9; forward = 20.0; backward = 20.0; default_iter = 0; max_iter = 25; loop_flag = true; initial_flag = false; replicate_flag = false; input_data [0] = output_data [0] = '\0'; str_cpy (input_format, sizeof (input_format), "HOURS"); str_cpy (output_format, sizeof (output_format), "HOURS"); //---- number of input files ---- nfile = Highest_Control_Group (INPUT_DATA_FILE_x, 0); if (nfile == 0) { Error ("No Input Data File Keys"); } file_group.Max_Records (nfile); //---- get the default file format ---- str_ptr = Get_Control_String (INPUT_DATA_FORMAT); if (str_ptr != NULL) { str_cpy (input_data, sizeof (input_data), str_ptr); } str_ptr = Get_Control_String (OUTPUT_DATA_FORMAT); if (str_ptr != NULL) { str_cpy (output_data, sizeof (output_data), str_ptr); } //---- get the default distribution filename ---- str_ptr = Get_Control_String (DISTRIBUTION_FILE); if (str_ptr != NULL) { str_cpy (initial_file, sizeof (initial_file), str_ptr); initial_flag = true; str_ptr = Get_Control_String (DISTRIBUTION_FORMAT); if (str_ptr != NULL) { str_cpy (initial_format, sizeof (initial_format), str_ptr); } else { initial_format [0] = '\0'; } } //---- get the time of day format ---- str_ptr = Get_Control_String (INPUT_TIME_FORMAT); if (str_ptr != NULL) { str_cpy (input_format, sizeof (input_format), str_ptr); } str_ptr = Get_Control_String (OUTPUT_TIME_FORMAT); if (str_ptr != NULL) { str_cpy (output_format, sizeof (output_format), str_ptr); } //---- read the field number ---- str_ptr = Get_Control_String (SMOOTH_FIELD_NUMBER); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > max_field) goto field_error; nfield = lvalue; } //---- time increment ---- str_ptr = Get_Control_String (SMOOTH_TIME_INCREMENT); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue > 3600) goto increment_error; increment = lvalue; } if (increment > 0) { max_size = 2 * 3600 / increment + 1; max_iter = (max_size + 1) / 2; if (max_iter > 100) max_iter = 100; max_iter *= max_iter; } else { max_size = 9; max_iter = 25; } //---- read the number smooth records ---- str_ptr = Get_Control_String (SMOOTH_GROUP_SIZE); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 3 || lvalue > max_size) goto size_error; if ((lvalue % 2) != 1) goto odd_error; default_average = lvalue; } //---- read the percent distributed forward ---- factor = 100.0 - 50.0 / default_average; str_ptr = Get_Control_String (PERCENT_MOVED_FORWARD); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > factor) goto forward_error; forward = dvalue; } //---- read the percent distributed backwarde ---- str_ptr = Get_Control_String (PERCENT_MOVED_BACKWARD); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > factor) goto backward_error; backward = dvalue; } factor = forward + backward; dvalue = 100.0 - 100.0 / default_average; if (factor < 5.0 || factor > dvalue) goto combined_error; //---- number of iterations ---- str_ptr = Get_Control_String (NUMBER_OF_ITERATIONS); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > max_iter) goto iteration_error; default_iter = lvalue; } //---- read the circular smoothing flag ---- str_ptr = Get_Control_String (CIRCULAR_GROUP_FLAG); if (str_ptr != NULL) { loop_flag = Get_Control_Flag (CIRCULAR_GROUP_FLAG); } //---- read the replicate fields flag ---- str_ptr = Get_Control_String (REPLICATE_FIELDS_FLAG); if (str_ptr != NULL) { replicate_flag = Get_Control_Flag (REPLICATE_FIELDS_FLAG); } //---- open each file ---- for (i=1; i <= nfile; i++) { //---- get the next filename --- str_ptr = Get_Control_String (INPUT_DATA_FILE_x, i); if (str_ptr == NULL) continue; group_ptr = file_group.New_Record (true); group_ptr->Group (i); //---- create the input file ---- Print (1); group_ptr->Input_File (new Diurnal_File ()); str_fmt (buffer, sizeof (buffer), "Input Data File #%d", i); group_ptr->Input_File ()->File_Type (buffer); format_ptr = Get_Control_String (INPUT_DATA_FORMAT_x, i); if (format_ptr != NULL) { group_ptr->Input_File ()->Dbase_Format (format_ptr); } else if (input_data [0] != '\0') { group_ptr->Input_File ()->Dbase_Format (input_data); } //---- open the file ---- if (!group_ptr->Input_File ()->Open (Project_Filename (str_ptr))) { File_Error (buffer, group_ptr->Input_File ()->Filename ()); } //---- open the output file ---- str_ptr = Get_Control_String (OUTPUT_DATA_FILE_x, i); if (str_ptr == NULL) goto control_error; group_ptr->Output_File (new Diurnal_File (Db_Code::CREATE)); str_fmt (buffer, sizeof (buffer), "Output Data File #%d", i); group_ptr->Output_File ()->File_Type (buffer); format_ptr = Get_Control_String (OUTPUT_DATA_FORMAT_x, i); if (format_ptr != NULL) { group_ptr->Output_File ()->Dbase_Format (format_ptr); } else if (output_data [0] != '\0') { group_ptr->Output_File ()->Dbase_Format (output_data); } if (!group_ptr->Output_File ()->Open (Project_Filename (str_ptr))) { File_Error (buffer, group_ptr->Output_File ()->Filename ()); } //---- get the distribution file ---- str_ptr = Get_Control_String (DISTRIBUTION_FILE_x, i); if (str_ptr == NULL) { if (initial_flag) { str_ptr = initial_file; if (initial_format [0] != '\0') { format_ptr = initial_format; } else { format_ptr = NULL; } } } else { format_ptr = Get_Control_String (DISTRIBUTION_FORMAT_x, i); } if (str_ptr != NULL) { group_ptr->Initial_File (new Diurnal_File ()); str_fmt (buffer, sizeof (buffer), "Distribution File #%d", i); group_ptr->Initial_File ()->File_Type (buffer); if (format_ptr != NULL) { group_ptr->Initial_File ()->Dbase_Format (format_ptr); } if (!group_ptr->Initial_File ()->Open (Project_Filename (str_ptr))) { File_Error (buffer, group_ptr->Initial_File ()->Filename ()); } } else { group_ptr->Initial_File (NULL); } //---- get the time of day format ---- str_ptr = Get_Control_String (INPUT_TIME_FORMAT_x, i); if (str_ptr == NULL) { str_ptr = input_format; } if (!group_ptr->Input_Format (str_ptr)) { Error ("Input Time Format %s was Unrecognized", str_ptr); } Print (1, "Input Time Format = %s", str_ptr); str_ptr = Get_Control_String (OUTPUT_TIME_FORMAT_x, i); if (str_ptr == NULL) { str_ptr = output_format; } if (!group_ptr->Output_Format (str_ptr)) { Error ("Output Time Format %s was Unrecognized", str_ptr); } Print (1, "Output Time Format = %s", str_ptr); //---- read the field number ---- max_field = group_ptr->Input_File ()->Num_Fields (); str_ptr = Get_Control_String (SMOOTH_FIELD_NUMBER_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > max_field) goto field_error; } else { lvalue = nfield; } group_ptr->Field_Number (lvalue); if (lvalue > 0) { Print (1, "Smooth Field Number = %d", lvalue); group_ptr->Input_File ()->Share_Field (lvalue); } //---- time increment ---- str_ptr = Get_Control_String (SMOOTH_TIME_INCREMENT_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue > 3600) goto increment_error; } else { lvalue = increment; } if (lvalue > 0) { Print (1, "Smooth Time Increment = %d seconds", lvalue); max_size = 2 * 3600 / lvalue + 1; max_iter = (max_size + 1) / 2; if (max_iter > 100) max_iter = 100; max_iter *= max_iter; naverage = default_average; niter = default_iter; if (niter == 0) { niter = max_iter / 2; } } else { Print (1, "Smooth Based on Input Time Periods"); max_size = 9; max_iter = 25; naverage = default_average; niter = default_iter; } group_ptr->Increment (lvalue); //---- read the number smooth records ---- str_ptr = Get_Control_String (SMOOTH_GROUP_SIZE_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 3 || lvalue > max_size) goto size_error; if ((lvalue % 2) != 1) goto odd_error; } else { lvalue = naverage; } Print (1, "Smooth Group Size = %d", lvalue); group_ptr->Num_Average (lvalue); //---- read the percent distributed forward ---- factor = 100.0 - 50.0 / lvalue; str_ptr = Get_Control_String (PERCENT_MOVED_FORWARD_x, i); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > factor) goto forward_error; } else { dvalue = forward; } Print (1, "Percent Distributed Forward = %.1lf percent", dvalue); group_ptr->Forward (dvalue); //---- read the percent distributed backwarde ---- str_ptr = Get_Control_String (PERCENT_MOVED_BACKWARD_x, i); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > factor) goto backward_error; } else { dvalue = backward; } Print (1, "Percent Distributed Backward = %.1lf percent", dvalue); group_ptr->Backward (dvalue); factor = group_ptr->Forward () + group_ptr->Backward (); dvalue = 100.0 - 100.0 / group_ptr->Num_Average (); if (factor < 5.0 || factor > dvalue) goto combined_error; //---- number of iterations ---- str_ptr = Get_Control_String (NUMBER_OF_ITERATIONS_x, i); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 1 || lvalue > max_iter) goto iteration_error; } else { lvalue = niter; } Print (1, "Number of Iterations = %d", lvalue); group_ptr->Num_Iteration (lvalue); //---- read the circular smoothing flag ---- str_ptr = Get_Control_String (CIRCULAR_GROUP_FLAG_x, i); if (str_ptr != NULL) { group_ptr->Loop_Flag (Get_Control_Flag (CIRCULAR_GROUP_FLAG_x, i)); } else { group_ptr->Loop_Flag (loop_flag); } Print (1, "Circular Group Flag = %s", (group_ptr->Loop_Flag () ? "TRUE" : "FALSE")); //---- read the replicate fields flag ---- if (Get_Control_String (REPLICATE_FIELDS_FLAG_x, i) != NULL) { group_ptr->Replicate_Flag (Get_Control_Flag (REPLICATE_FIELDS_FLAG_x, i)); } else { group_ptr->Replicate_Flag (replicate_flag); } Print (1, "Replicate Fields Flag = %s", (group_ptr->Replicate_Flag () ? "TRUE" : "FALSE")); if (group_ptr->Replicate_Flag ()) { int field, num; bool binary; Db_Field *fld; Diurnal_File *file; group_ptr->Output_File ()->Share_Field (0); group_ptr->Output_File ()->Clear_Fields (); //---- copy all fields ---- file = group_ptr->Input_File (); binary = (file->Record_Format () == Db_Code::BINARY); num = file->Num_Fields (); for (field=1; field <= num; field++) { fld = file->Field (field); if (fld == NULL) continue; if (field == file->Start_Field () || field == file->End_Field ()) { group_ptr->Output_File ()->Add_Field (fld->Name (), Db_Code::STRING, 20); } else { group_ptr->Output_File ()->Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Decimal (), -1, binary); } } group_ptr->Output_File ()->Write_Header (); group_ptr->Output_File ()->Share_Field (group_ptr->Input_File ()->Share_Field ()); } //---- add the group record ---- if (!file_group.Add ()) { Error ("Adding File Group"); } } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); field_error: Error ("Field Number %d is Out of Range (1..%d)", lvalue, max_field); increment_error: Error ("Smooth Time Increment %d is Out of Range (0..3600)", lvalue); size_error: Error ("Smooth Group Size %d is Out of Range (1..%d)", lvalue, max_size); odd_error: Error ("Smooth Group Size %d must be an Odd Number", lvalue); forward_error: Error ("Forward Percentage %.1lf is Out of Range (0..%.1lf)", dvalue, factor); backward_error: Error ("Backward Percentage %.1lf is Out of Range (0..%.1lf)", dvalue, factor); combined_error: Error ("Combined Distribution Percentage %.1lf is Out of Range (5..%.0lf)", factor, dvalue); iteration_error: Error ("Number of Iterations %d is Out of Range (1-%d)", lvalue, max_iter); }
void PlanSelect::Program_Control (void) { int i, nsel, lvalue; char *str_ptr, buffer [FIELD_BUFFER]; double dvalue; Box box; //---- open network files ---- Demand_Service::Program_Control (); //---- open the plan file ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (PLAN_FILE); if (str_ptr == NULL) goto control_error; str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, plan_file.File_Type (), str_ptr); plan_file.Filename (str_ptr); str_ptr = Get_Control_String (PLAN_FORMAT); if (str_ptr != NULL) { plan_file.File_Format (str_ptr); Print (1, "%s Format = %s", plan_file.File_Type (), str_ptr); } plan_file.Node_Based_Flag (type_flag); if (!plan_file.Open (0)) { File_Error ("Opening Plan File", plan_file.Filename ()); } type_flag = plan_file.Node_Based_Flag (); //---- node list paths ---- if (type_flag) { Print (1, "Plan File contains Node List Paths"); } else { Print (1, "Plan File contains Link List Paths"); } //---- check for a link delay file ---- if (Demand_File_Flag (LINK_DELAY)) { Delay_File *file = (Delay_File *) Demand_Db_File (LINK_DELAY); if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) { Error ("Link and Node files are Required for Link Delay Processing"); } if (file->Dbase_Format () == VERSION3) { turn_flag = false; Network_File_False (LANE_CONNECTIVITY); } else if (!Network_File_Flag (LANE_CONNECTIVITY)) { Warning ("Lane Connectivity is required for Turning Delays"); Show_Message (1); turn_flag = false; } else { turn_flag = true; } delay_flag = true; } else { Network_File_False (LANE_CONNECTIVITY); } //---- open the population file ---- str_ptr = Get_Control_String (POPULATION_FILE); if (str_ptr != NULL) { pop_file.File_Type ("Population File"); Print (1); pop_file.Open (str_ptr); pop_flag = true; } //---- get the household list ---- str_ptr = Get_Control_String (NEW_HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("New Household List"); hhlist_file.File_Access (CREATE); str_ptr = Project_Filename (str_ptr, Extension ()); hhlist_file.Filename (str_ptr); Print_Filename (2, hhlist_file.File_Type (), str_ptr); if (!hhlist_file.Open (0)) { File_Error ("Opening Household List File", hhlist_file.Filename ()); } if (hhlist_file.Extend () == 0 && plan_file.Extend () != 0) { Warning ("Household List File is Not Partitioned"); } } else { str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FILE); if (str_ptr == NULL) { Error ("A New Household List or Household Record File is Required"); } hhrec_flag = true; hhrec_file.File_Access (CREATE); str_ptr = Project_Filename (str_ptr, Extension ()); hhrec_file.Filename (str_ptr); Print_Filename (2, hhrec_file.File_Type (), str_ptr); str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FORMAT); if (str_ptr != NULL) { hhrec_file.Dbase_Format (str_ptr); Print (1, "%s Format = %s", hhrec_file.File_Type (), str_ptr); } if (!hhrec_file.Open (0)) { File_Error ("Opening Household Record file", hhrec_file.Filename ()); } if (hhrec_file.Extend () == 0 && plan_file.Extend () != 0) { Warning ("Household Record File is Not Partitioned"); } } //---- get the select travelers ---- str_ptr = Get_Control_String (SELECT_TRAVELERS); if (str_ptr != NULL) { Print (2, "Select Traveler IDs = %s", str_ptr); if (!travelers.Add_Ranges (str_ptr)) { File_Error ("Traveler ID Range", str_ptr); } } //---- get the select nodes ---- nsel = Highest_Control_Group (SELECT_NODES_x, 0); if (nsel > 0) { nodes.Max_Records (nsel); for (i=1; i <= nsel; i++) { str_ptr = Get_Control_String (SELECT_NODES_x, i); if (str_ptr == NULL) continue; Print (2, "Select Nodes for Group #%d = %s", i, str_ptr); Data_Range *ptr = new Data_Range (); if (!ptr->Add_Ranges (str_ptr)) { File_Error ("Path Node Numbers", str_ptr); } if (!nodes.Add (ptr)) { Error ("Adding Node Ranges to the List"); } } } //---- get the select links ---- nsel = Highest_Control_Group (SELECT_LINKS_x, 0); if (nsel > 0) { links.Max_Records (nsel); for (i=1; i <= nsel; i++) { str_ptr = Get_Control_String (SELECT_LINKS_x, i); if (str_ptr == NULL) continue; Print (2, "Select Links for Group #%d = %s", i, str_ptr); Data_Range *ptr = new Data_Range (1, -MAX_INTEGER, MAX_INTEGER, 0); if (!ptr->Add_Ranges (str_ptr)) { File_Error ("Path Link Numbers", str_ptr); } if (!links.Add (ptr)) { Error ("Adding Link Ranges to the List"); } } } //---- get the select time periods ---- str_ptr = Get_Control_String (SELECT_TIME_PERIODS); if (str_ptr != NULL) { Print (2, "Select Time Periods = %s", str_ptr); times.Format (Time_Step::HOURS); if (!times.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } } //---- get the select travel modes ---- str_ptr = Get_Control_String (SELECT_TRAVEL_MODES); if (str_ptr != NULL) { Print (2, "Select Travel Modes = %s", str_ptr); memset (mode_flag, '\0', sizeof (mode_flag)); nsel = 0; while (str_ptr != NULL) { char *old_ptr = str_ptr; str_ptr = Get_Integer (str_ptr, &i); if (i < 0 || i > DRIVER_MODE || (i == 0 && *old_ptr != '0')) { Error ("Selected Travel Mode %s is Out of Range (0..%d)", old_ptr, DRIVER_MODE); } mode_flag [i] = true; nsel++; } if (nsel == 0) { Error ("No Modes were Selected for Processing"); } } else { for (i=0; i <= DRIVER_MODE; i++) { mode_flag [i] = true; } } //---- get the select facility types ---- str_ptr = Get_Control_String (SELECT_FACILITY_TYPES); if (str_ptr != NULL) { Print (2, "Select Facility Types = %s", str_ptr); factype_flag = true; memset (facility_flag, '\0', sizeof (facility_flag)); nsel = 0; while (str_ptr != NULL) { str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (buffer [0] == '\0') break; i = Facility_Code (buffer); facility_flag [i] = true; nsel++; } if (nsel == 0) { Error ("No Facility Types were Selected for Processing"); } } //---- get the select locations ---- str_ptr = Get_Control_String (SELECT_LOCATIONS); if (str_ptr != NULL) { Print (2, "Select Activity Locations = %s", str_ptr); if (!locations.Add_Ranges (str_ptr)) { File_Error ("Activity Location Range", str_ptr); } } //---- get the select parking lots ---- str_ptr = Get_Control_String (SELECT_PARKING_LOTS); if (str_ptr != NULL) { Print (2, "Select Parking Lots = %s", str_ptr); if (!parking_lots.Add_Ranges (str_ptr)) { File_Error ("Parking Lot Range", str_ptr); } } //---- get the select transit stops ---- str_ptr = Get_Control_String (SELECT_TRANSIT_STOPS); if (str_ptr != NULL) { Print (2, "Select Transit Stops = %s", str_ptr); if (!transit_stops.Add_Ranges (str_ptr)) { File_Error ("Transit Stop Range", str_ptr); } } //---- get the select transit routes ---- str_ptr = Get_Control_String (SELECT_TRANSIT_ROUTES); if (str_ptr != NULL) { Print (2, "Select Transit Routes = %s", str_ptr); if (!transit_routes.Add_Ranges (str_ptr)) { File_Error ("Transit Route Range", str_ptr); } } //---- get the select vc ratio ---- str_ptr = Get_Control_String (SELECT_VC_RATIOS); if (str_ptr != NULL) { if (!delay_flag) { Error ("Select V/C Ratios requires a Link Delay file"); } vc_flag = true; Get_Double (str_ptr, &vc_ratio); if (vc_ratio < 1.0) { Error ("Select V/C Ratios %.2lf is Out of Range (>= 1.0)", vc_ratio); } Print (2, "Select V/C Ratios >= %.2lf", vc_ratio); } //---- get the select time ratio ---- str_ptr = Get_Control_String (SELECT_TIME_RATIOS); if (str_ptr != NULL) { if (!delay_flag) { Error ("Select Travel Time Ratios requires a Link Delay file"); } ratio_flag = true; Get_Double (str_ptr, &time_ratio); if (time_ratio < 1.0) { Error ("Select Time Ratios %.2lf is Out of Range (>= 1.0)", time_ratio); } Print (2, "Select Time Ratios >= %.2lf", time_ratio); } //---- get the select coordinates ---- nsel = Highest_Control_Group (SELECT_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (SELECT_COORDINATES); } else { str_ptr = Get_Control_String (SELECT_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Select Coordinates requires a Node file"); } coord_flag = true; if (i == 0) { Print (2, "Select Coordinates = %s", str_ptr); } else { if (coord_box.Num_Records () == 0) Print (1); Print (1, "Select Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!coord_box.Add (&box)) goto mem_error; } //---- get the select od coordinates ---- nsel = Highest_Control_Group (SELECT_OD_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (SELECT_OD_COORDINATES); } else { str_ptr = Get_Control_String (SELECT_OD_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Select OD Coordinates requires a Node file"); } in_flag = true; if (i == 0) { Print (2, "Select OD Coordinates = %s", str_ptr); } else { if (od_box.Num_Records () == 0) Print (1); Print (1, "Select OD Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!od_box.Add (&box)) goto mem_error; } //---- get the exclude od coordinates ---- nsel = Highest_Control_Group (EXCLUDE_OD_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES); } else { str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Excludet OD Coordinates requires a Node file"); } out_flag = true; if (i == 0) { Print (2, "Exclude OD Coordinates = %s", str_ptr); } else { if (exclude_box.Num_Records () == 0) Print (1); Print (1, "Excludet OD Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!exclude_box.Add (&box)) goto mem_error; } //---- get the select subarea polygon ---- str_ptr = Get_Control_String (SELECT_SUBAREA_POLYGON); if (str_ptr != NULL) { if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) { Error ("Link and Node files are Required for Subarea Polygon Selection"); } Print (1); select_subarea.File_Type ("Select Subarea Polygon"); select_subarea.Open (Project_Filename (str_ptr)); if (!select_subarea.Read_Record ()) { Error ("Reading %s", select_subarea.File_Type ()); } subarea_flag = true; } //---- get the select vehicle types ---- str_ptr = Get_Control_String (SELECT_VEHICLE_TYPES); if (str_ptr != NULL) { Print (2, "Select Vehicle Types = %s", str_ptr); if (!vehicle_types.Add_Ranges (str_ptr)) { File_Error ("Vehicle Type Range", str_ptr); } vehicle_flag = true; if (!Demand_File_Flag (VEHICLE)) { Error ("A Vehicle File is Required for Vehicle Type Selection"); } } else { Demand_File_False (VEHICLE); } //---- get the percent time difference ---- str_ptr = Get_Control_String (PERCENT_TIME_DIFFERENCE); if (str_ptr != NULL) { if (!delay_flag) { Error ("Percent Time Difference requires a Link Delay file"); } diff_flag = true; Get_Double (str_ptr, &percent_diff); if (percent_diff < 0.1 || percent_diff > 100.0) { Error ("Percent Time Difference %.2lf is Out of Range (0.1-100.0)", percent_diff); } Print (2, "Percent Time Difference = %.1lf%%", percent_diff); percent_diff /= 100.0; //---- get the minimum time difference ---- str_ptr = Get_Control_String (MINIMUM_TIME_DIFFERENCE); if (str_ptr != NULL) { Get_Integer (str_ptr, &min_time); if (min_time < 0 || min_time > 120) { Error ("Minimum Time Difference %d is Out of Range (0-120)", min_time); } } Print (1, "Minimum Time Difference = %d minute%s", min_time, ((min_time != 1) ? "s" : " ")); //---- get the maximum time difference ---- str_ptr = Get_Control_String (MAXIMUM_TIME_DIFFERENCE); if (str_ptr != NULL) { Get_Integer (str_ptr, &max_time); if (max_time < min_time || max_time > 1440) { Error ("Maximum Time Difference %d is Out of Range (%d-1440)", max_time, min_time); } } Print (1, "Maximum Time Difference = %d minutes", max_time); min_time *= 60; max_time *= 60; } //---- get the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } select_flag = (percent != 100.0); } Print (2, "Selection Percentage = %.1lf%%", percent); percent /= 100.0; //---- get the max percent selected ---- str_ptr = Get_Control_String (MAXIMUM_PERCENT_SELECTED); if (str_ptr != NULL) { Get_Double (str_ptr, &max_percent); if (max_percent < 1.0 || max_percent > 100.0) { Error ("Maximum Percent Selected %.1lf is Out of Range (1.0-100.0)", max_percent); } } Print (1, "Maximum Percent Selected = %.1lf%%", max_percent); max_percent /= 100.0; //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } if (str_ptr != NULL || percent != 1.0 || max_percent != 1.0) { Print (1, "Random Number Seed = %d", random.Seed ()); } //---- reset the network flags ---- if (!vc_flag && !diff_flag && !ratio_flag) { delay_flag = parking_flag = turn_flag = false; Demand_File_False (LINK_DELAY); Network_File_False (LANE_USE); Network_File_False (PARKING); Network_File_False (LANE_CONNECTIVITY); if (!coord_flag && !out_flag && !in_flag && !subarea_flag && !factype_flag && nodes.Num_Records () == 0 && links.Num_Records () == 0) { Network_File_False (LINK); Network_File_False (NODE); Network_File_False (TRANSIT_STOP); Network_File_False (TRANSIT_DRIVER); } else if (!factype_flag && type_flag && links.Num_Records () == 0) { Network_File_False (LINK); } } else { parking_flag = Network_File_Flag (PARKING); if (!diff_flag) { turn_flag = false; Network_File_False (LANE_CONNECTIVITY); } } transit_flag = (Network_File_Flag (TRANSIT_STOP) && Network_File_Flag (TRANSIT_DRIVER)); return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); coord_error: Error ("Select Coordinates are Incomplete"); od_coord_error: Error ("Exclude OD Coordinates are Incomplete"); mem_error: Error ("Insufficient Memory for Coordinate Groups"); }
void PlanPrep::Program_Control (void) { int i, dump; char *str_ptr; Sort_Type input_sort; //---- open network files ---- Demand_Service::Program_Control (); //---- open the input plans ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (INPUT_PLAN_FILE); if (str_ptr == NULL) goto control_error; input_plans.File_Type ("Input Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, input_plans.File_Type (), str_ptr); input_plans.Filename (str_ptr); str_ptr = Get_Control_String (INPUT_PLAN_FORMAT); if (str_ptr != NULL) { input_plans.File_Format (str_ptr); Print (1, "%s Format = %s", input_plans.File_Type (), str_ptr); } input_plans.Node_Based_Flag (type_flag); if (!input_plans.Open (0)) { File_Error ("Opening Input Plan File", input_plans.Filename ()); } type_flag = input_plans.Node_Based_Flag (); parts_flag = (input_plans.Extend () > 0); //---- input plan sort ---- str_ptr = Get_Control_String (INPUT_PLAN_SORT); if (str_ptr != NULL) { Print (1, "Input Plan Sort = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { input_sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { input_sort = TIME_SORT; } else { Error ("Unrecognized Input Plan Sort = %s", str_ptr); } input_plans.Plan_Sort (input_sort); input_sort_flag = true; } else { input_sort = input_plans.Plan_Sort (); } //---- open the merge plans ---- str_ptr = Get_Control_String (MERGE_PLAN_FILE); if (str_ptr != NULL) { merge_plans.File_Type ("Merge Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, merge_plans.File_Type (), str_ptr); merge_plans.Filename (str_ptr); merge_plans.Extend (input_plans.Extend ()); str_ptr = Get_Control_String (MERGE_PLAN_FORMAT); if (str_ptr != NULL) { merge_plans.File_Format (str_ptr); Print (1, "%s Format = %s", merge_plans.File_Type (), str_ptr); } merge_plans.Node_Based_Flag (type_flag); if (!merge_plans.Open (0)) { File_Error ("Opening Merge Plan File", merge_plans.Filename ()); } merge_flag = true; if (merge_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the subarea plans ---- str_ptr = Get_Control_String (SUBAREA_PLAN_FILE); if (str_ptr != NULL) { if (merge_flag) { Error ("Merge and Subarea Plans are Incompatible"); } subarea_plans.File_Type ("Subarea Plan File"); str_ptr = Project_Filename (str_ptr); subarea_plans.Filename (str_ptr); if (subarea_plans.Extend () > 0) { if (parts_flag) { subpart_flag = true; } else { str_ptr = subarea_plans.Pathname (); str_ptr = Project_Filename (str_ptr, Extension ()); subarea_plans.Filename (str_ptr); subarea_plans.Extend (0); } } Print_Filename (2, subarea_plans.File_Type (), str_ptr); str_ptr = Get_Control_String (SUBAREA_PLAN_FORMAT); if (str_ptr != NULL) { subarea_plans.File_Format (str_ptr); Print (1, "%s Format = %s", subarea_plans.File_Type (), str_ptr); } subarea_plans.Node_Based_Flag (type_flag); if (!subarea_plans.Open (0)) { File_Error ("Opening Subarea Plan File", subarea_plans.Filename ()); } subarea_flag = true; if (subarea_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the output plans ---- str_ptr = Get_Control_String (OUTPUT_PLAN_FILE); if (str_ptr != NULL) { output_plans.File_Type ("Output Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, output_plans.File_Type (), str_ptr); output_plans.Filename (str_ptr); output_plans.File_Access (CREATE); str_cpy (output_name, sizeof (output_name), output_plans.Pathname ()); extend = output_plans.Extend (); output_flag = true; str_ptr = Get_Control_String (OUTPUT_PLAN_FORMAT); if (str_ptr != NULL) { output_plans.File_Format (str_ptr); Print (1, "%s Format = %s", output_plans.File_Type (), str_ptr); binary_flag = (output_plans.File_Format () == BINARY); } output_plans.Node_Based_Flag (type_flag); } else if (merge_flag) { Error ("Plan Merging Requires an Output File"); } else if (subarea_flag) { Error ("Subarea Merging Requires an Output File"); } //---- plan sort option ---- str_ptr = Get_Control_String (PLAN_SORT_OPTION); if (str_ptr != NULL && output_flag) { Print (2, "Plan Sort Option = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { if (merge_flag) { Error ("Plan Merging must be performed in TRAVELER Sort"); } sort = TIME_SORT; } else { Error ("Unrecognized Plan Sort Option = %s", str_ptr); } if (!input_sort_flag || input_sort != sort) { input_plans.Plan_Memory (ALLOCATE_MEMORY); input_plans.Plan_Sort (sort); sort_flag = true; } if (sort_flag && subarea_flag) { Error ("Sorting and Subarea Merging are Incompatible"); } } //---- plan combine option ---- str_ptr = Get_Control_String (PLAN_COMBINE_OPTION); if (str_ptr != NULL && parts_flag && output_flag) { Print (2, "Plan Combine Option = %s", str_ptr); if (!input_sort_flag && !sort_flag) { Error ("The Input Sort or Sort Option are needed for Plan Combining"); } if (str_cmp (str_ptr, "FILE") == 0) { combine = FILE_COMBINE; } else if (str_cmp (str_ptr, "MEMORY") == 0) { if (merge_flag) { Error ("Plan Merging and Memory Combining are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Memory Combining are Incompatible"); } if (sort_flag) { combine = MEMORY_COMBINE; } else { combine = FILE_COMBINE; } } else { Error ("Unrecognized Plan Combine Option = %s", str_ptr); } combine_flag = true; } //---- max plan size ---- str_ptr = Get_Control_String (MAX_OUTPUT_PLAN_SIZE); if (str_ptr != NULL && (combine_flag || (!parts_flag && output_flag))) { Print (2, "Maximum Output Plan Size = %s megabytes", str_ptr); max_size = atol (str_ptr); if (max_size < 1 || max_size > 2048) { Error ("Maximum Output Plan Size %d is Out of Range (1-2048)", max_size); } max_size *= 1024 * 1024; max_size_flag = true; } //---- get the select traveler range ---- str_ptr = Get_Control_String (SELECT_TRAVELER_RANGE); if (str_ptr != NULL) { Print (2, "Select Traveler Range = %s", str_ptr); if (!hhold_range.Add_Ranges (str_ptr)) { Error ("Select Traveler Range", str_ptr); } hhold_flag = true; } //---- get the select time periods ---- str_ptr = Get_Control_String (SELECT_TIME_PERIODS); if (str_ptr != NULL) { Print (2, "Select Time Periods = %s", str_ptr); time_period.Format (Time_Step::HOURS); if (!time_period.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } time_flag = true; } //---- read the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { if (input_sort != TRAVELER_SORT) { Error ("The Input Plans must be in Traveler order for Plan Selection"); } Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } Print (2, "Selection Percentage = %.2lf", percent); percent /= 100.0; select_flag = (percent != 1.0); } if ((time_flag || select_flag || hhold_flag) && subarea_flag) { Error ("Subarea Merging and Plan Selections are Incompatible"); } //---- check plan partitions ---- str_ptr = Get_Control_String (CHECK_PLAN_PARTITIONS); if (str_ptr != NULL) { check_flag = Get_Control_Flag (CHECK_PLAN_PARTITIONS); Print (2, "Check Plan Partitions = %s", str_ptr); if (check_flag) { partition.Initialize (sizeof (Partition)); } } //---- update plan partitions ---- str_ptr = Get_Control_String (UPDATE_PLAN_PARTITIONS); if (str_ptr != NULL) { partition_flag = Get_Control_Flag (UPDATE_PLAN_PARTITIONS); Print (2, "Update Plan Partitions = %s", str_ptr); } //---- get the household list file ---- str_ptr = Get_Control_String (HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("Household List"); hhlist_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, hhlist_file.File_Type (), str_ptr); if (!hhlist_file.Open (0)) { File_Error ("Opening Household List File", hhlist_file.Filename ()); } hhlist_flag = true; } else if (partition_flag) { Error ("Household Lists are required for Partition Updates"); } if (hhlist_flag) { combine_flag = false; if (sort_flag) { Error ("Plan Sorting and Household Lists are Incompatible"); } if (merge_flag) { Error ("Plan Merging and Household Lists are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Household Lists are Incompatible"); } if (check_flag) { Error ("Checking and Updating Plan Partitions are Incompatible"); } if (!output_flag) { Error ("Output Plans are Required for Household Lists"); } partition.Initialize (sizeof (Partition)); } //---- get the delete household list file ---- str_ptr = Get_Control_String (DELETE_HOUSEHOLD_LIST); if (str_ptr != NULL) { delete_file.File_Type ("Delete Household List"); delete_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, delete_file.File_Type (), str_ptr); if (!delete_file.Open (0)) { File_Error ("Opening Delete Household List File", delete_file.Filename ()); } delete_flag = true; } //---- get the delete one leg plans flag ---- str_ptr = Get_Control_String (DELETE_ONE_LEG_PLANS); if (str_ptr != NULL) { one_leg_flag = Get_Control_Flag (DELETE_ONE_LEG_PLANS); Print (1, "Delete One Leg Plans = %s", str_ptr); } //---- get the fix plan file ---- str_ptr = Get_Control_String (FIX_PLAN_FILE); if (str_ptr != NULL) { fix_file.File_Type ("Fix Plan File"); if (!fix_file.Open (Project_Filename (str_ptr))) { File_Error ("Opening Fix Plan File", fix_file.Filename ()); } fix_flag = true; } //---- merge by trip ---- str_ptr = Get_Control_String (MERGE_BY_TRIP); if (str_ptr != NULL) { trip_flag = Get_Control_Flag (MERGE_BY_TRIP); Print (2, "Merge by Trip = %s", str_ptr); } //---- random number seed ---- if (select_flag || fix_flag) { str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } Print (2, "Random Number Seed = %d", random.Seed ()); } //---- check output file name ---- if (output_flag) { output_plans.Plan_Sort (input_plans.Plan_Sort ()); if (max_size_flag || !combine_flag) { extend = output_plans.Extend (input_plans.Extend ()); if (extend == 0 && max_size_flag) { extend = output_plans.Extend (1); } } if (!hhlist_flag || !delete_flag) { if (!output_plans.Open (0)) { File_Error ("Creating Output Plan File", output_plans.Filename ()); } } if (combine_flag && combine == FILE_COMBINE && (sort_flag || merge_flag || subarea_flag)) { //---- set the temporary output filename ---- output_plans.Filename (Filename (output_name, TEMP_LABEL)); output_plans.Extend (input_plans.Extend ()); output_plans.File_Format (BINARY); } } //---- read report types ---- compare_flag = path_flag = false; dump_path = dump_time = MAX_INTEGER; for (i=First_Report (); i != 0; i=Next_Report ()) { if (i != FIX_PLAN) compare_flag = true; if (i == PATH_CHANGE || i == DUMP_PATH_CHANGES) { path_flag = true; if (i == DUMP_PATH_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_path) { dump_path = dump; } } } else if (i == DUMP_TIME_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_time) { dump_time = dump; } } } if (compare_flag) { if (!merge_flag) { Write (1); Warning ("Change Reports require a Merge Plan File"); compare_flag = false; } memset (time_changes, '\0', sizeof (time_changes)); memset (path_changes, '\0', sizeof (path_changes)); increment = MIDNIGHT / TOTAL_TIME_PERIOD; } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void LineSum::Program_Control (void) { int i, num_files, anode, bnode; bool arcview_flag, z_flag, m_flag; String key, format; Strings ab_strings, node_pairs; Str_Itr str_itr, ab_itr; Db_Header *fh = 0; File_Itr file_itr; Line_Report_Data line_report_data; Link_Report_Data link_report_data; On_Off_Report_Data on_off_report_data; Access_Report_Data access_report_data; Stop_Report_Data stop_report_data; Total_Report_Data total_report_data; Link_Rider_Data link_rider_data; Dtime hour; //---- process the global control keys ---- Execution_Service::Program_Control (); Metric_Flag (false); hour.Hours (1.0); //---- get the projection data ---- projection.Read_Control (); //---- get the z coordinate flag ---- m_flag = projection.M_Flag (); z_flag = projection.Z_Flag (); Print (2, String ("%s Control Keys:") % Program ()); //---- initialize the peak file list ---- num_files = Highest_Control_Group (PEAK_RIDERSHIP_FILE, 0); if (num_files > 0) { peak_list.Initialize (num_files); Print (1); //---- open each file ---- for (i=1; i <= num_files; i++) { //---- open the peak ridership file ---- key = Get_Control_String (PEAK_RIDERSHIP_FILE, i); if (key.empty ()) continue; fh = peak_list [i-1]; fh->File_Type (String ("Peak Ridership File #%d") % i); fh->File_ID (String ("Peak%d") % i); //---- get the file format ---- if (Check_Control_Key (PEAK_RIDERSHIP_FORMAT, i)) { fh->Dbase_Format (Get_Control_String (PEAK_RIDERSHIP_FORMAT, i)); } fh->Open (Project_Filename (key)); } } //---- initialize the offpeak file list ---- num_files = Highest_Control_Group (OFFPEAK_RIDERSHIP_FILE, 0); if (num_files > 0) { offpeak_list.Initialize (num_files); Print (1); //---- open each file ---- for (i=1; i <= num_files; i++) { //---- open the offpeak ridership file ---- key = Get_Control_String (OFFPEAK_RIDERSHIP_FILE, i); if (key.empty ()) continue; fh = offpeak_list [i-1]; fh->File_Type (String ("Offpeak Ridership File #%d") % i); fh->File_ID (String ("Offpeak%d") % i); //---- get the file format ---- if (Check_Control_Key (OFFPEAK_RIDERSHIP_FORMAT, i)) { fh->Dbase_Format (Get_Control_String (OFFPEAK_RIDERSHIP_FORMAT, i)); } fh->Open (Project_Filename (key)); } } if (peak_list.size () == 0 && offpeak_list.size () == 0) { // Error ("No Peak or Offpeak Ridership File Keys were Found"); } //---- open the new peak ridership file ---- key = Get_Control_String (NEW_PEAK_RIDERSHIP_FILE); if (!key.empty ()) { Print (1); if (peak_list.size () == 0) { Error ("Input Peak Ridership Files are Required"); } fh = 0; for (file_itr = peak_list.begin (); file_itr != peak_list.end (); file_itr++) { if ((*file_itr)->Is_Open ()) { fh = *file_itr; break; } } if (fh == 0) Error ("Peak Input files are Not Open"); new_peak_file.File_Type ("New Peak Ridership File"); new_peak_file.File_ID ("NewPeak"); //---- get the file format ---- if (Check_Control_Key (NEW_PEAK_RIDERSHIP_FORMAT)) { new_peak_file.Dbase_Format (Get_Control_String (NEW_PEAK_RIDERSHIP_FORMAT)); } new_peak_file.Header_Lines (fh->Header_Lines ()); new_peak_file.Replicate_Fields (fh); new_peak_file.Create (Project_Filename (key)); } //---- open the new offpeak ridership file ---- key = Get_Control_String (NEW_OFFPEAK_RIDERSHIP_FILE); if (!key.empty ()) { Print (1); if (offpeak_list.size () == 0) { Error ("Input Offpeak Ridership Files are Required"); } fh = 0; for (file_itr = offpeak_list.begin (); file_itr != offpeak_list.end (); file_itr++) { if ((*file_itr)->Is_Open ()) { fh = *file_itr; break; } } if (fh == 0) Error ("Offpeak Input files are Not Open"); new_offpeak_file.File_Type ("New Offpeak Ridership File"); new_offpeak_file.File_ID ("NewOffpeak"); //---- get the file format ---- if (Check_Control_Key (NEW_OFFPEAK_RIDERSHIP_FORMAT)) { new_offpeak_file.Dbase_Format (Get_Control_String (NEW_OFFPEAK_RIDERSHIP_FORMAT)); } new_offpeak_file.Header_Lines (fh->Header_Lines ()); new_offpeak_file.Replicate_Fields (fh); new_offpeak_file.Create (Project_Filename (key)); } //---- open the new total ridership file ---- key = Get_Control_String (NEW_TOTAL_RIDERSHIP_FILE); if (!key.empty ()) { Print (1); if (peak_list.size () == 0 || offpeak_list.size () == 0) { Error ("Input Peak and Offpeak Ridership Files are Required"); } fh = 0; for (file_itr = peak_list.begin (); file_itr != peak_list.end (); file_itr++) { if ((*file_itr)->Is_Open ()) { fh = *file_itr; break; } } if (fh == 0) Error ("Peak Input files are Not Open"); new_total_file.File_Type ("New Total Ridership File"); new_total_file.File_ID ("NewTotal"); //---- get the file format ---- if (Check_Control_Key (NEW_TOTAL_RIDERSHIP_FORMAT)) { new_total_file.Dbase_Format (Get_Control_String (NEW_TOTAL_RIDERSHIP_FORMAT)); } new_total_file.Header_Lines (fh->Header_Lines ()); new_total_file.Replicate_Fields (fh); new_total_file.Create (Project_Filename (key)); } //---- open the stop name file ---- key = Get_Control_String (STOP_NAME_FILE); if (!key.empty ()) { Print (1); stop_name_file.File_Type ("Stop Name File"); stop_name_file.File_ID ("StopName"); station_flag = true; //---- get the file format ---- if (Check_Control_Key (STOP_NAME_FORMAT)) { stop_name_file.Dbase_Format (Get_Control_String (STOP_NAME_FORMAT)); } stop_name_file.Open (Project_Filename (key)); } //---- line report data ---- num_files = Highest_Control_Group (LINE_REPORT_LINES); if (num_files > 0) { //---- read the line report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (LINE_REPORT_LINES, i)) continue; Print (1); //---- report number and title ---- line_report_data.number = i; line_report_data.title = Get_Control_Text (LINE_REPORT_TITLE, i); //---- line range ---- key = Get_Control_Text (LINE_REPORT_LINES, i); if (key.empty ()) continue; key.Parse (line_report_data.lines); //---- selected modes ---- key = Get_Control_Text (LINE_REPORT_MODES, i); line_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { line_report_data.all_modes = false; if (!line_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { line_report_data.all_modes = true; } //---- report all nodes ---- line_report_data.node_flag = Get_Control_Flag (LINE_REPORT_ALL_NODES, i); //---- store the control data ---- line_report_array.push_back (line_report_data); } } //---- link report data ---- num_files = Highest_Control_Group (LINK_REPORT_LINKS); if (num_files > 0) { //---- read the link report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (LINK_REPORT_LINKS, i)) continue; Print (1); //---- report number and title ---- link_report_data.number = i; link_report_data.title = Get_Control_Text (LINK_REPORT_TITLE, i); //---- anode-bnode pairs ---- key = Get_Control_Text (LINK_REPORT_LINKS, i); if (key.empty ()) continue; link_report_data.links = key; key.Parse (node_pairs); link_report_data.nodes.clear (); for (str_itr = node_pairs.begin (); str_itr != node_pairs.end (); str_itr++) { str_itr->Parse (ab_strings, "-"); for (anode=0, ab_itr = ab_strings.begin (); ab_itr != ab_strings.end (); ab_itr++, anode = bnode) { bnode = ab_itr->Integer (); if (anode > 0) { link_report_data.nodes.push_back (anode); link_report_data.nodes.push_back (bnode); } } } //---- selected modes ---- key = Get_Control_Text (LINK_REPORT_MODES, i); link_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { link_report_data.all_modes = false; if (!link_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { link_report_data.all_modes = true; } //---- selected lines ---- key = Get_Control_Text (LINK_REPORT_LINES, i); link_report_data.lines.clear (); if (!key.empty () && !key.Equals ("ALL")) { link_report_data.all_lines = false; key.Parse (link_report_data.lines); } else { link_report_data.all_lines = true; } //---- oneway/twoway flag ---- link_report_data.dir_flag = Get_Control_Flag (LINK_REPORT_ONEWAY, i); //---- store the control data ---- link_report_array.push_back (link_report_data); } } //---- on-off report data ---- num_files = Highest_Control_Group (ON_OFF_REPORT_STOPS); if (num_files > 0) { on_off_flag = true; //---- read the boarding report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (ON_OFF_REPORT_STOPS, i)) continue; Print (1); //---- report number and title ---- on_off_report_data.number = i; on_off_report_data.title = Get_Control_Text (ON_OFF_REPORT_TITLE, i); //---- stop range ---- key = Get_Control_Text (ON_OFF_REPORT_STOPS, i); if (key.empty ()) continue; on_off_report_data.stops.clear (); if (!key.empty () && !key.Equals ("ALL")) { on_off_report_data.all_stops = false; if (!on_off_report_data.stops.Add_Ranges (key)) { exe->Error ("Adding Stop Ranges"); } } else { on_off_report_data.all_stops = true; } //---- select modes ---- key = Get_Control_Text (ON_OFF_REPORT_MODES, i); on_off_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { on_off_report_data.all_modes = false; if (!on_off_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { on_off_report_data.all_modes = true; } //---- level of detail ---- key = Get_Control_Text (ON_OFF_REPORT_DETAILS, i); if (!key.empty ()) { char ch = key [0]; if (ch >= 'a' && ch <= 'z') ch = ch - 'a' + 'A'; if (ch == 'T' || ch == 'Y' || ch == '1') { on_off_report_data.details = 1; } else if (ch == 'M' || ch == '2') { on_off_report_data.details = 2; } else { on_off_report_data.details = 0; } } else { on_off_report_data.details = 0; } //---- output data file ---- key = Get_Control_String (NEW_ON_OFF_REPORT_FILE, i); if (!key.empty ()) { if (Check_Control_Key (NEW_ON_OFF_REPORT_FORMAT, i)) { format = Get_Control_String (NEW_ON_OFF_REPORT_FORMAT, i); on_off_report_data.arcview_flag = format.Equals ("ARCVIEW"); } else { on_off_report_data.arcview_flag = false; } Print (1); if (on_off_report_data.arcview_flag) { on_off_report_data.file = on_off_report_data.arc_file = new Arcview_File (); on_off_report_data.arc_file->File_Type (String ("New On-Off Report File #%d") % i); on_off_report_data.arc_file->Shape_Type (DOT); on_off_report_data.arc_file->Z_Flag (z_flag); on_off_report_data.arc_file->M_Flag (m_flag); on_off_report_data.arc_file->Create (Project_Filename (key)); on_off_report_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); xy_flag = true; } else { on_off_report_data.file = new Db_Header (); if (Check_Control_Key (NEW_ON_OFF_REPORT_FORMAT, i)) { on_off_report_data.file->Dbase_Format (format); } on_off_report_data.file->File_Type (String ("New On-Off Report File #%d") % i); on_off_report_data.file->Create (Project_Filename (key)); } } else { on_off_report_data.file = 0; } //---- store the control data ---- on_off_report_array.push_back (on_off_report_data); } } //---- access report data ---- num_files = Highest_Control_Group (ACCESS_REPORT_STOPS); if (num_files > 0) { access_flag = true; //---- read the access report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (ACCESS_REPORT_STOPS, i)) continue; Print (1); //---- report number and title ---- access_report_data.number = i; access_report_data.title = Get_Control_Text (ACCESS_REPORT_TITLE, i); //---- stop range ---- key = Get_Control_Text (ACCESS_REPORT_STOPS, i); if (key.empty ()) continue; access_report_data.stops.clear (); if (!key.empty () && !key.Equals ("ALL")) { access_report_data.all_stops = false; if (!access_report_data.stops.Add_Ranges (key)) { exe->Error ("Adding Stop Ranges"); } } else { access_report_data.all_stops = true; } //---- select modes ---- key = Get_Control_Text (ACCESS_REPORT_MODES, i); access_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { access_report_data.all_modes = false; if (!access_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { access_report_data.all_modes = true; } //---- level of detail ---- key = Get_Control_Text (ACCESS_REPORT_DETAILS, i); if (!key.empty ()) { char ch = key [0]; if (ch >= 'a' && ch <= 'z') ch = ch - 'a' + 'A'; if (ch == 'T' || ch == 'Y' || ch == '1') { access_report_data.details = 1; } else if (ch == 'M' || ch == '2') { access_report_data.details = 2; } else { access_report_data.details = 0; } } else { access_report_data.details = 0; } //---- output data file ---- key = Get_Control_String (NEW_ACCESS_REPORT_FILE, i); if (!key.empty ()) { access_report_data.file = new Db_Header (); access_report_data.file->File_Type (String ("New Access Report File #%d") % i); if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) { access_report_data.file->Dbase_Format (Get_Control_String (NEW_ACCESS_REPORT_FORMAT, i)); } access_report_data.file->Create (Project_Filename (key)); if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) { format = Get_Control_String (NEW_ACCESS_REPORT_FORMAT, i); access_report_data.arcview_flag = format.Equals ("ARCVIEW"); } else { access_report_data.arcview_flag = false; } Print (1); if (access_report_data.arcview_flag) { access_report_data.file = access_report_data.arc_file = new Arcview_File (); access_report_data.arc_file->File_Type (String ("New Access Report File #%d") % i); access_report_data.arc_file->Shape_Type (DOT); access_report_data.arc_file->Z_Flag (z_flag); access_report_data.arc_file->M_Flag (m_flag); access_report_data.arc_file->Create (Project_Filename (key)); access_report_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); xy_flag = true; } else { access_report_data.file = new Db_Header (); if (Check_Control_Key (NEW_ACCESS_REPORT_FORMAT, i)) { access_report_data.file->Dbase_Format (format); } access_report_data.file->File_Type (String ("New Access Report File #%d") % i); access_report_data.file->Create (Project_Filename (key)); } } else { access_report_data.file = 0; } //---- store the control data ---- access_report_array.push_back (access_report_data); } } //---- stop report data ---- num_files = Highest_Control_Group (STOP_REPORT_STOPS); if (num_files > 0) { access_flag = true; //---- read the stop report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (STOP_REPORT_STOPS, i)) continue; Print (1); //---- report number and title ---- stop_report_data.number = i; stop_report_data.title = Get_Control_Text (STOP_REPORT_TITLE, i); //---- stop range ---- key = Get_Control_Text (STOP_REPORT_STOPS, i); if (key.empty ()) continue; stop_report_data.stops.clear (); if (!stop_report_data.stops.Add_Ranges (key)) { exe->Error ("Adding Stop Ranges"); } //---- select modes ---- key = Get_Control_Text (STOP_REPORT_MODES, i); stop_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { stop_report_data.all_modes = false; if (!stop_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { stop_report_data.all_modes = true; } //---- line range ---- key = Get_Control_Text (STOP_REPORT_LINES, i); stop_report_data.lines.clear (); if (!key.empty () && !key.Equals ("ALL")) { stop_report_data.all_lines = false; key.Parse (stop_report_data.lines); } else { stop_report_data.all_lines = true; } //---- transfer modes ---- key = Get_Control_Text (STOP_REPORT_TRANSFERS, i); stop_report_data.transfers.clear (); if (!key.empty () && !key.Equals ("NONE")) { if (!stop_report_data.transfers.Add_Ranges (key)) { exe->Error ("Adding Transfer Mode Ranges"); } } //---- store the control data ---- stop_report_array.push_back (stop_report_data); } } //---- total report data ---- num_files = Highest_Control_Group (TOTAL_REPORT_LINES); if (num_files > 0) { //---- read the total report keys ---- for (i=1; i <= num_files; i++) { if (!Check_Control_Key (TOTAL_REPORT_LINES, i)) continue; Print (1); //---- report number and title ---- total_report_data.number = i; total_report_data.title = Get_Control_Text (TOTAL_REPORT_TITLE, i); //---- line range ---- key = Get_Control_Text (TOTAL_REPORT_LINES, i); if (key.empty ()) continue; key.Parse (total_report_data.lines); //---- selected modes ---- key = Get_Control_Text (TOTAL_REPORT_MODES, i); total_report_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { total_report_data.all_modes = false; if (!total_report_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { total_report_data.all_modes = true; } //---- output data file ---- key = Get_Control_String (NEW_TOTAL_REPORT_FILE, i); if (!key.empty ()) { total_report_data.file = new Db_Header (); total_report_data.file->File_Type (String ("New Total Report File #%d") % i); if (Check_Control_Key (NEW_TOTAL_REPORT_FORMAT, i)) { total_report_data.file->Dbase_Format (Get_Control_String (NEW_TOTAL_REPORT_FORMAT, i)); } total_report_data.file->Create (Project_Filename (key)); //---- peak hours ---- total_report_data.peak_hours = (double) Get_Control_Time (TOTAL_REPORT_PEAK_HOURS, i) / hour; //---- offpeak hours ---- total_report_data.offpeak_hours = (double) Get_Control_Time (TOTAL_REPORT_OFFPEAK_HOURS, i) / hour; } else { total_report_data.file = 0; } //---- store the control data ---- total_report_array.push_back (total_report_data); } } //---- open the node XY file ---- if (xy_flag) { key = Get_Control_String (NODE_XY_FILE); if (key.empty ()) { Error ("Node XY File is Required for Stop Shapefiles"); } if (Check_Control_Key (NODE_XY_FORMAT)) { node_xy_file.Dbase_Format (Get_Control_String (NODE_XY_FORMAT)); } node_xy_file.File_Type ("Node XY File"); Print (1); node_xy_file.Open (Project_Filename (key)); } //---- link rider file data ---- num_files = Highest_Control_Group (NEW_LINK_RIDER_FILE); if (num_files > 0) { arcview_flag = false; //---- read the link rider keys ---- for (i=1; i <= num_files; i++) { //---- output data file --- key = Get_Control_String (NEW_LINK_RIDER_FILE, i); if (key.empty ()) continue; link_rider_data.number = i; if (Check_Control_Key (NEW_LINK_RIDER_FORMAT, i)) { format = Get_Control_String (NEW_LINK_RIDER_FORMAT, i); link_rider_data.arcview_flag = format.Equals ("ARCVIEW"); } else { link_rider_data.arcview_flag = false; } Print (1); if (link_rider_data.arcview_flag) { link_rider_data.file = link_rider_data.arc_file = new Arcview_File (); link_rider_data.arc_file->File_Type (String ("New Link Rider File #%d") % i); link_rider_data.arc_file->Shape_Type (VECTOR); link_rider_data.arc_file->Z_Flag (z_flag); link_rider_data.arc_file->M_Flag (m_flag); link_rider_data.arc_file->Create (Project_Filename (key)); link_rider_data.arc_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); arcview_flag = true; } else { link_rider_data.file = new Db_Header (); if (Check_Control_Key (NEW_LINK_RIDER_FORMAT, i)) { link_rider_data.file->Dbase_Format (format); } link_rider_data.file->File_Type (String ("New Link Rider File #%d") % i); link_rider_data.file->Create (Project_Filename (key)); } //---- selected modes ---- key = Get_Control_Text (LINK_RIDER_MODES, i); link_rider_data.modes.clear (); if (!key.empty () && !key.Equals ("ALL")) { link_rider_data.all_modes = false; if (!link_rider_data.modes.Add_Ranges (key)) { exe->Error ("Adding Modes Ranges"); } } else { link_rider_data.all_modes = true; } //---- selected lines ---- key = Get_Control_Text (LINK_RIDER_LINES, i); link_rider_data.lines.clear (); link_rider_data.all_lines = false; link_rider_data.each_line = false; if (key.empty ()) { link_rider_data.all_lines = true; } else if (key.Equals ("ALL")) { link_rider_data.all_lines = true; } else if (key.Equals ("EACH")) { link_rider_data.each_line = true; } else { key.Parse (link_rider_data.lines); } //---- peak hours ---- link_rider_data.peak_hours = (double) Get_Control_Time (LINK_RIDER_PEAK_HOURS, i) / hour; //---- peak factor ---- link_rider_data.peak_fac = Get_Control_Double (LINK_RIDER_PEAK_FACTOR, i); //---- peak capacity ---- link_rider_data.peak_cap = Get_Control_Double (LINK_RIDER_PEAK_CAPACITY, i); //---- offpeak hours ---- link_rider_data.offpeak = (double) Get_Control_Time (LINK_RIDER_OFFPEAK_HOURS, i) / hour; //---- open node file for arcview output ---- if (link_rider_data.arcview_flag) { key = Get_Control_String (LINK_RIDER_XY_FILE, i); if (key.empty ()) { Error ("A Link Rider XY File is required for Arcview Output"); } link_rider_data.xy_file = new Db_Header (); link_rider_data.xy_file->File_Type (String ("Link Rider XY File #%d") % i); if (Check_Control_Key (LINK_RIDER_XY_FORMAT, i)) { link_rider_data.xy_file->Dbase_Format (Get_Control_String (LINK_RIDER_XY_FORMAT, i)); } link_rider_data.xy_file->Open (Project_Filename (key)); link_rider_data.node_fld = link_rider_data.xy_file->Required_Field (NODE_FIELD_NAMES); link_rider_data.xcoord_fld = link_rider_data.xy_file->Required_Field (X_FIELD_NAMES); link_rider_data.ycoord_fld = link_rider_data.xy_file->Required_Field (Y_FIELD_NAMES); link_rider_data.offset = Get_Control_Double (LINK_RIDER_SIDE_OFFSET, i); } else { link_rider_data.offset = 0.0; } //---- store the control data ---- link_rider_array.push_back (link_rider_data); } //---- open the link shape file ---- if (arcview_flag) { key = Get_Control_String (LINK_SHAPE_FILE); if (!key.empty ()) { Print (1); shape_flag = true; link_shape.File_Type ("Link Shape File"); link_shape.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); link_shape.Open (Project_Filename (key)); //---- get the field numbers ---- key = Get_Control_Text (LINK_SHAPE_ANODE); anode_field = link_shape.Required_Field (key); Print (0, ", Number=") << anode_field; key = Get_Control_Text (LINK_SHAPE_BNODE); bnode_field = link_shape.Required_Field (key); Print (0, ", Number=") << bnode_field; } } //---- process service level files ---- key = Get_Control_String (SERVICE_FILE); if (!key.empty ()) { Print (1); service_file.File_Type ("Service File"); service_flag = true; //---- get the file format ---- if (Check_Control_Key (SERVICE_FORMAT)) { service_file.Dbase_Format (Get_Control_String (SERVICE_FORMAT)); } service_file.Open (Project_Filename (key)); //---- get the field numbers ---- key = Get_Control_Text (SERVICE_LINE_FIELD); line_fld = service_file.Required_Field (key); Print (0, ", Number=") << line_fld; if (Check_Control_Key (SERVICE_PEAK_FIELD)) { key = Get_Control_Text (SERVICE_PEAK_FIELD); peak_fld = service_file.Required_Field (key); Print (0, ", Number=") << peak_fld; } if (Check_Control_Key (SERVICE_OFFPEAK_FIELD)) { key = Get_Control_Text (SERVICE_OFFPEAK_FIELD); offpeak_fld = service_file.Required_Field (key); Print (0, ", Number=") << offpeak_fld; } } } //---- initialize the base routes ---- num_files = Highest_Control_Group (BASE_ROUTE_FILE, 0); if (num_files > 0) { base_routes.Initialize (num_files); Print (1); //---- open each file ---- for (i=1; i <= num_files; i++) { //---- open the base ridership file ---- key = Get_Control_String (BASE_ROUTE_FILE, i); if (key.empty ()) continue; fh = base_routes [i-1]; fh->File_Type (String ("Base Route File #%d") % i); fh->File_ID (String ("Base%d") % i); //---- get the file format ---- if (Check_Control_Key (BASE_ROUTE_FORMAT, i)) { fh->Dbase_Format (Get_Control_String (BASE_ROUTE_FORMAT, i)); } fh->Open (Project_Filename (key)); } } //---- initialize the alternative routes ---- num_files = Highest_Control_Group (ALTERNATIVE_ROUTE_FILE, 0); if (num_files > 0) { alt_routes.Initialize (num_files); Print (1); //---- open each file ---- for (i=1; i <= num_files; i++) { //---- open the alternative ridership file ---- key = Get_Control_String (ALTERNATIVE_ROUTE_FILE, i); if (key.empty ()) continue; fh = alt_routes [i-1]; fh->File_Type (String ("Alternative Route File #%d") % i); fh->File_ID (String ("Alte%d") % i); //---- get the file format ---- if (Check_Control_Key (ALTERNATIVE_ROUTE_FORMAT, i)) { fh->Dbase_Format (Get_Control_String (ALTERNATIVE_ROUTE_FORMAT, i)); } fh->Open (Project_Filename (key)); } } }
void NewFormat::Program_Control (void) { bool type_flag, flat_flag, time_flag; String key; //---- open the support files ---- Data_Service::Program_Control (); if (Check_Control_Key (VERSION4_PLAN_FILE) && Check_Control_Key (TRIP_SORT_TYPE)) { Warning ("Plan Sorting is Limited to Version 5 Plan files"); Show_Message (1); } Print (2, String ("%s Control Keys:") % Program ()); //---- copy existing fields ---- copy_flag = Get_Control_Flag (COPY_EXISTING_FIELDS); if (copy_flag) { if (System_File_Flag (LOCATION) && System_File_Flag (NEW_LOCATION)) { Location_File *file = (Location_File *) System_File_Handle (LOCATION); new_loc_file = (Location_File *) System_File_Handle (NEW_LOCATION); new_loc_file->Add_User_Fields (file); } if (System_File_Flag (ZONE) && System_File_Flag (NEW_ZONE)) { Zone_File *file = (Zone_File *) System_File_Handle (ZONE); new_zone_file = (Zone_File *) System_File_Handle (NEW_ZONE); new_zone_file->Add_User_Fields (file); } } //---- copy existing configuration ---- if (System_File_Flag (LINK_DELAY) && System_File_Flag (NEW_LINK_DELAY)) { Link_Delay_File *file = (Link_Delay_File *) System_File_Header (LINK_DELAY); if (file->Turn_Flag ()) { file = (Link_Delay_File *) System_File_Header (NEW_LINK_DELAY); file->Clear_Fields (); file->Turn_Flag (true); file->Set_Nesting (true); file->Create_Fields (); file->Write_Header (); } } if (System_File_Flag (PERFORMANCE) && System_File_Flag (NEW_PERFORMANCE)) { Performance_File *file = (Performance_File *) System_File_Header (PERFORMANCE); if (file->Turn_Flag ()) { file = (Performance_File *) System_File_Header (NEW_PERFORMANCE); file->Clear_Fields (); file->Turn_Flag (true); file->Set_Nesting (true); file->Create_Fields (); file->Write_Header (); } } //---- flatten output flag ---- flat_flag = Get_Control_Flag (FLATTEN_OUTPUT_FLAG); if (flat_flag) { if (System_File_Flag (NEW_SHAPE)) { System_File_Header (NEW_SHAPE)->Flatten_File (); } if (System_File_Flag (NEW_PARKING)) { System_File_Header (NEW_PARKING)->Flatten_File (); } if (System_File_Flag (NEW_SIGNAL)) { System_File_Header (NEW_SIGNAL)->Flatten_File (); } if (System_File_Flag (NEW_TIMING_PLAN)) { System_File_Header (NEW_TIMING_PLAN)->Flatten_File (); } if (System_File_Flag (NEW_PHASING_PLAN)) { System_File_Header (NEW_PHASING_PLAN)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_ROUTE)) { System_File_Header (NEW_TRANSIT_ROUTE)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_SCHEDULE)) { System_File_Header (NEW_TRANSIT_SCHEDULE)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_DRIVER)) { System_File_Header (NEW_TRANSIT_DRIVER)->Flatten_File (); } if (System_File_Flag (NEW_ROUTE_NODES)) { System_File_Header (NEW_ROUTE_NODES)->Flatten_File (); } if (System_File_Flag (NEW_HOUSEHOLD)) { System_File_Header (NEW_HOUSEHOLD)->Flatten_File (); } if (System_File_Flag (NEW_LINK_DELAY)) { System_File_Header (NEW_LINK_DELAY)->Flatten_File (); } if (System_File_Flag (NEW_PERFORMANCE)) { System_File_Header (NEW_PERFORMANCE)->Flatten_File (); } if (System_File_Flag (NEW_PLAN)) { System_File_Header (NEW_PLAN)->Flatten_File (); } } //---- toll file ---- key = Get_Control_String (TOLL_FILE); if (!key.empty ()) { toll_file.Open (Project_Filename (key)); toll_flag = true; } //---- activity file ---- key = Get_Control_String (ACTIVITY_FILE); if (!key.empty ()) { activity_file.Open (Project_Filename (key)); activity_flag = true; if (!System_File_Flag (NEW_TRIP)) { Error ("A New Trip file is required to convert an Activity File"); } if (!System_File_Flag (VEHICLE)) { Error ("A Vehicle file is required to convert an Activity File"); } } //---- person file ---- key = Get_Control_String (PERSON_FILE); if (!key.empty ()) { person_file.Open (Project_Filename (key)); person_flag = true; } //---- snapshot file ---- key = Get_Control_String (SNAPSHOT_FILE); if (!key.empty ()) { Print (1); snap_file.Open (Project_Filename (key)); snap_flag = true; } //---- new snapshot file ---- key = Get_Control_String (NEW_SNAPSHOT_FILE); if (!key.empty ()) { new_snap_file.Compress_Flag (Set_Control_Flag (NEW_SNAPSHOT_COMPRESSION)); if (new_snap_file.Compress_Flag ()) { new_snap_file.Dbase_Format (BINARY); } else { if (Check_Control_Key (NEW_SNAPSHOT_FORMAT)) { new_snap_file.Dbase_Format (Get_Control_String (NEW_SNAPSHOT_FORMAT)); } new_snap_file.Location_Flag (snap_file.Location_Flag ()); new_snap_file.Cell_Flag (snap_file.Cell_Flag ()); new_snap_file.Status_Flag (snap_file.Status_Flag ()); } new_snap_file.Create (Project_Filename (key)); Get_Control_Flag (NEW_SNAPSHOT_COMPRESSION); } else if (snap_flag) { Error ("A New Snapshot File is required for Output"); } //---- version 4 time format ---- time_units = Units_Code (Get_Control_Text (VERSION4_TIME_FORMAT)); time_flag = Check_Control_Key (VERSION4_TIME_FORMAT); if (time_flag) { int num; Field_Ptr fld_ptr; if (System_File_Flag (TRIP)) { Trip_File *file = (Trip_File *) System_File_Base (TRIP); if (file->Version () <= 40) { num = file->Optional_Field (START_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } num = file->Optional_Field (END_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } num = file->Optional_Field (DURATION_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } } } if (activity_flag) { num = activity_file.Optional_Field ("START_MIN", "START", "START_TIME", "STARTTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("START_MAX", "START", "START_TIME", "STARTTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("END_MIN", "END", "END_TIME", "ENDTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("END_MAX", "END", "END_TIME", "ENDTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("TIME_MIN", "DURATION"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("TIME_MAX", "DURATION"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } } } //---- plan file ---- if (Check_Control_Key (VERSION4_PLAN_FILE)) { if (System_File_Flag (PLAN)) { Error ("A plan file and Version 4 plan file must be processed separateley"); } if (!System_File_Flag (NEW_PLAN)) { Error ("A new plan file is required to convert a Version 4 plan file"); } Print (1); plan_flag = true; old_plan.File_Type ("Version4 Plan File"); //---- get the list type ---- key = Get_Control_String (NODE_LIST_PATHS); if (!key.empty ()) { type_flag = key.Bool (); } else { type_flag = true; } old_plan.Node_Based_Flag (type_flag); //---- get the traveler scale ---- key = Get_Control_String (TRAVELER_SCALING_FACTOR); if (!key.empty ()) { scale = key.Integer (); if (scale < 2 || scale > 100) { Control_Key_Error (TRAVELER_SCALING_FACTOR, "(2..100)"); } old_plan.Traveler_Scale (scale); } //---- get the file format ---- if (Check_Control_Key (VERSION4_PLAN_FORMAT)) { old_plan.File_Format (Get_Control_String (VERSION4_PLAN_FORMAT)); } //---- open the file and print the parameters ---- if (!old_plan.Open (Project_Filename (Get_Control_String (VERSION4_PLAN_FILE)))) { File_Error ("Opening Version4 Plan File", old_plan.Filename ()); } Get_Control_Text (VERSION4_PLAN_FORMAT); type_flag = old_plan.Node_Based_Flag (); if (type_flag) { Print (1, "Plan File contains Node List Paths"); if (!System_File_Flag (NODE) || !System_File_Flag (LINK) || !System_File_Flag (PARKING)) { Error ("A Node, Link and Parking Files are Required for Node-Based Plan Files"); } AB_Map_Flag (true); } else { Print (1, "Plan File contains Link List Paths"); } Get_Control_Integer (TRAVELER_SCALING_FACTOR); } else if (snap_flag && snap_file.Version () <= 40) { //---- get the traveler scale ---- scale= Get_Control_Integer (TRAVELER_SCALING_FACTOR); if (scale < 2 || scale > 100) { Control_Key_Error (TRAVELER_SCALING_FACTOR, "(2..100)"); } } //---- Version 4 Route Header and Node files ---- if (Check_Control_Key (VERSION4_ROUTE_HEADER)) { if (!System_File_Flag (NEW_ROUTE_NODES)) { Error ("A New Route Nodes File is Required"); } int i, num; String field; Field_Ptr fld_ptr; if (!time_flag) time_units = MINUTES; Print (1); route_flag = true; Route_Nodes_File *file = (Route_Nodes_File *) System_File_Base (NEW_ROUTE_NODES); key = Get_Control_String (VERSION4_ROUTE_HEADER); route_header.File_Type ("Version4 Route Header"); route_header.File_ID ("Header"); route_header.Open (Project_Filename (key)); for (i=1; i <= 24; i++) { field ("HEADWAY_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num < 0) break; fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); field ("OFFSET_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num >= 0) { fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); } field ("TTIME_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num >= 0) { fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); } } route_periods = i - 1; if (route_periods != file->Num_Periods ()) { file->Num_Periods (route_periods); file->Clear_Fields (); file->Create_Fields (); file->Write_Header (); } key = Get_Control_String (VERSION4_ROUTE_NODES); if (key.empty ()) { Error ("A Version4 Route Nodes file is Required"); } route_nodes.File_Type ("Version4 Route Nodes"); route_nodes.File_ID ("Nodes"); route_nodes.Open (Project_Filename (key)); } }
void PerfPrep::Program_Control (void) { String key; Strings list; Str_Itr str_itr; //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); Read_Flow_Time_Keys (); Print (2, String ("%s Control Keys:") % Program ()); new_file_flag = System_File_Flag (NEW_PERFORMANCE); //---- open the merge performance ---- key = Get_Control_String (MERGE_PERFORMANCE_FILE); if (!key.empty ()) { merge_file.File_Type ("Merge Performance File"); Print (1); if (Check_Control_Key (MERGE_PERFORMANCE_FORMAT)) { merge_file.Dbase_Format (Get_Control_String (MERGE_PERFORMANCE_FORMAT)); } merge_file.Open (Project_Filename (key)); merge_flag = true; if (!new_file_flag) { Error ("A New Performance File is required for Merge Processing"); } } //---- open the base performance ---- key = Get_Control_String (BASE_PERFORMANCE_FILE); if (!key.empty ()) { base_file.File_Type ("Base Performance File"); Print (1); if (Check_Control_Key (BASE_PERFORMANCE_FORMAT)) { base_file.Dbase_Format (Get_Control_String (BASE_PERFORMANCE_FORMAT)); } base_file.Open (Project_Filename (key)); base_flag = true; if (!new_file_flag) { Error ("A New Performance File is required for Base Processing"); } } //---- open the merge turn delay ---- turn_flag = System_File_Flag (TURN_DELAY); if (turn_flag) { key = Get_Control_String (MERGE_TURN_DELAY_FILE); if (!key.empty ()) { turn_file.File_Type ("Merge Turn Delay File"); Print (1); if (Check_Control_Key (MERGE_TURN_DELAY_FORMAT)) { turn_file.Dbase_Format (Get_Control_String (MERGE_TURN_DELAY_FORMAT)); } turn_file.Open (Project_Filename (key)); turn_merge_flag = true; if (!System_File_Flag (NEW_TURN_DELAY)) { Error ("A New Turn Delay File is required for Merge Processing"); } } } //---- processing method ---- Print (1); key = Get_Control_Text (PROCESSING_METHOD); if (!key.empty ()) { method = Combine_Code (key); if (method != UPDATE_TIMES) { if (merge_flag || turn_merge_flag) { if (method == WEIGHTED_LINK_AVG || method == REPLACE_AVERAGE) { //---- merge weighting factor ---- factor = Get_Control_Double (MERGE_WEIGHTING_FACTOR); } } else { //Error (String ("Processing Method %s requires Merge Files") % key); } } } //---- read the smoothing parameters ---- smooth_flag = smooth_data.Read_Control (); if (smooth_flag) { if (!smooth_data.Num_Input (time_periods.Num_Periods ())) { Error ("Smooth Parameters are Illogical"); } if (!new_file_flag) { Error ("A New Performance File is required for Data Smoothing"); } } //---- set min travel time ---- min_time_flag = Get_Control_Flag (SET_MIN_TRAVEL_TIME); if (min_time_flag && !new_file_flag) { Error ("A New Performance File is required for Minimum Travel Times"); } //---- set merge transit data ---- key = Get_Control_Text (MERGE_TRANSIT_DATA); if (!key.empty ()) { transit_flag = true; if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) || !System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER)) { Error ("Transit Network Files are Required for Transit Loading"); } if (!new_file_flag) { Error ("A New Performance File is required to Merge Transit Data"); } key.Parse (list); for (str_itr = list.begin (); str_itr != list.end (); str_itr++) { if (str_itr->Starts_With ("VEH")) { transit_veh_flag = true; } else if (str_itr->Starts_With ("PER")) { transit_person_flag = true; } else if (str_itr->Starts_With ("PCE") || str_itr->Starts_With ("CAR_EQ")) { transit_pce_flag = true; } } if (!System_File_Flag (VEHICLE_TYPE) && transit_pce_flag) { Warning ("Vehicle Type File is Required for Transit PCE Loading"); } if (!System_File_Flag (RIDERSHIP) && transit_person_flag) { Warning ("Ridership File is Required for Transit Person Loading"); } if (!merge_flag) { method = Combine_Code (Get_Control_Text (PROCESSING_METHOD)); } } //---- open the time constraint file ---- key = Get_Control_String (TIME_CONSTRAINT_FILE); if (!key.empty ()) { constraint_file.File_Type ("Time Constraint File"); Print (1); if (Check_Control_Key (TIME_CONSTRAINT_FORMAT)) { constraint_file.Dbase_Format (Get_Control_String (TIME_CONSTRAINT_FORMAT)); } constraint_file.Open (Project_Filename (key)); constraint_flag = true; } //---- open the time ratio file ---- key = Get_Control_String (NEW_TIME_RATIO_FILE); if (!key.empty ()) { time_ratio_file.File_Type ("New Time Ratio File"); time_ratio_file.Create (Project_Filename (key)); time_ratio_flag = true; } //---- open the deleted record file ---- key = Get_Control_String (NEW_DELETED_RECORD_FILE); if (!key.empty ()) { deleted_file.File_Type ("New Deleted Record File"); Print (1); if (Check_Control_Key (NEW_DELETED_RECORD_FORMAT)) { deleted_file.Dbase_Format (Get_Control_String (NEW_DELETED_RECORD_FORMAT)); } deleted_file.Create (Project_Filename (key)); del_file_flag = true; } List_Reports (); first_delete = deleted_flag = (Report_Flag (DELETED_RECORDS) || del_file_flag); }
void TPPlusNet::Program_Control (void) { int len; char *str_ptr, *format_ptr; //---- create the network files ---- Network_Service::Program_Control (); //---- get the projection data ---- proj_service.Read_Control (); projection.Set_Projection (proj_service.Input_Projection (), proj_service.Output_Projection ()); //---- open the TP+ link file ---- str_ptr = Get_Control_String (TPPLUS_LINK_FILE); if (str_ptr == NULL) goto control_error; len = (int) strlen (str_ptr); len = (len > 4) ? len - 4 : 0; if ((format_ptr = strchr (str_ptr + len, '.')) != NULL) { link_shape_flag = (str_cmp (format_ptr, ".shp") == 0); } if (link_shape_flag) { //---- set the projection data ---- link_shape_file.Set_Projection (proj_service.Input_Projection (), proj_service.Output_Projection ()); link_shape_file.File_Type ("TPPlus Link File"); link_shape_file.File_ID ("TPPLUS"); Print (1); link_shape_file.Open (Project_Filename (str_ptr)); link_shape_file.File_Access (MODIFY); } else { link_file.File_Type ("TPPlus Link File"); link_file.File_ID ("TPPLUS"); format_ptr = Get_Control_String (TPPLUS_LINK_FORMAT); if (format_ptr != NULL) { link_file.Dbase_Format (format_ptr); } Print (1); link_file.Open (Project_Filename (str_ptr)); link_file.File_Access (MODIFY); } //---- open the TP+ node file ---- str_ptr = Get_Control_String (TPPLUS_NODE_FILE); if (str_ptr == NULL) goto control_error; len = (int) strlen (str_ptr); len = (len > 4) ? len - 4 : 0; if ((format_ptr = strchr (str_ptr + len, '.')) != NULL) { node_shape_flag = (str_cmp (format_ptr, ".shp") == 0); } if (node_shape_flag) { //---- set the projection data ---- node_shape_file.Set_Projection (proj_service.Input_Projection (), proj_service.Output_Projection ()); node_shape_file.File_Type ("TPPlus Node File"); node_shape_file.File_ID ("TPPLUS"); Print (1); node_shape_file.Open (Project_Filename (str_ptr)); } else { node_file.File_Type ("TPPlus Node File"); node_file.File_ID ("TPPLUS"); format_ptr = Get_Control_String (TPPLUS_NODE_FORMAT); if (format_ptr != NULL) { node_file.Dbase_Format (format_ptr); } Print (1); node_file.Open (Project_Filename (str_ptr)); } //---- open the speed capacity table ---- str_ptr = Get_Control_String (TPPLUS_SPDCAP_FILE); if (str_ptr != NULL) { spdcap_file.File_Type ("TPPlus Speed-Capacity File"); spdcap_file.File_ID ("TPPLUS"); format_ptr = Get_Control_String (TPPLUS_SPDCAP_FORMAT); if (format_ptr != NULL) { spdcap_file.Dbase_Format (format_ptr); } else { spdcap_file.Dbase_Format (FIXED_COLUMN); } Print (1); spdcap_file.Open (Project_Filename (str_ptr)); spdcap_flag = true; //---- convert units ---- str_ptr = Get_Control_String (CONVERT_MPH_TO_MPS); if (str_ptr != NULL) { Print (1, "Convert MPH to MPS = %s", str_ptr); units_flag = Get_Control_Flag (CONVERT_MPH_TO_MPS); } //---- facility index field ---- str_ptr = Get_Control_String (FACILITY_INDEX_FIELD); if (str_ptr != NULL) { Print (1, "Facility Index Field = %s", str_ptr); if (link_shape_flag) { fac_fld = link_shape_file.Required_Field (str_ptr); } else { fac_fld = link_file.Required_Field (str_ptr); } Print (0, " (Number = %d)", fac_fld); } //---- area type index field ---- str_ptr = Get_Control_String (AREA_TYPE_INDEX_FIELD); if (str_ptr != NULL) { Print (1, "Area Type Index Field = %s", str_ptr); if (link_shape_flag) { at_fld = link_shape_file.Required_Field (str_ptr); } else { at_fld = link_file.Required_Field (str_ptr); } Print (0, " (Number = %d)", at_fld); } if ((fac_fld == 0 && at_fld > 0) || (fac_fld > 0 && at_fld == 0)) { Error ("Facility and Area Types Index Fields are Required"); } } //---- open the conversion script ---- str_ptr = Get_Control_String (CONVERSION_SCRIPT); if (str_ptr != NULL) { Print (1); script_file.File_Type ("Conversion Script"); script_file.Open (Project_Filename (str_ptr)); convert_flag = true; } //---- external zone number ---- str_ptr = Get_Control_String (EXTERNAL_ZONE_NUMBER); if (str_ptr != NULL) { ext_zone = atoi (str_ptr); if (ext_zone < 0 || ext_zone > 10000) { Error ("External Zone Number %d is Out of Range (0..10000)", ext_zone); } Print (2, "First External Zone Number = %d", ext_zone); } //---- open the link detail file ---- str_ptr = Get_Control_String (NEW_LINK_DETAIL_FILE); if (str_ptr != NULL) { Print (1); detail_file.Notes_Flag (Notes_Name_Flag ()); detail_file.Create (Project_Filename (str_ptr)); detail_flag = true; } if (link_shape_flag) { shape_file = (Shape_File *) Network_Db_Base (NEW_SHAPE); if (link_shape_file.Z_Flag () && shape_file != NULL) { shape_file->Z_Flag (true); shape_file->Clear_Fields (); shape_file->Create_Fields (); shape_file->Write_Header (); } } return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void ArcSnapshot::Program_Control (void) { int i; String key, text; bool z_flag, m_flag; string method_text [] = { "AT_INCREMENT", "TOTAL", "MAXIMUM", "" }; Set_Range_String (SUMMARY_TIME_INCREMENT, "0.0..1440.0"); //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); max_time = Model_End_Time (); //---- get the projection data ---- project_flag = projection.Read_Control (); //---- get the z coordinate flag ---- m_flag = projection.M_Flag (); z_flag = projection.Z_Flag (); //---- open the snapshot file ---- Print (2, String ("%s Control Keys:") % Program ()); key = Get_Control_String (SNAPSHOT_FILE); if (!key.empty ()) { if (Check_Control_Key (SNAPSHOT_FORMAT)) { snapshot_file.Dbase_Format (Get_Control_String (SNAPSHOT_FORMAT)); } snapshot_file.Open (Project_Filename (key)); } else { key = Get_Control_String (OCCUPANCY_FILE); if (key.empty ()) { Error ("A Snapshot or Occupancy file is Required"); } if (Check_Control_Key (OCCUPANCY_FORMAT)) { occupancy_file.Dbase_Format (Get_Control_String (OCCUPANCY_FORMAT)); } occupancy_file.Open (Project_Filename (key)); occupancy_flag = true; } //---- get the arcview snapshot file ---- key = Get_Control_String (NEW_ARC_SNAPSHOT_FILE); if (!key.empty ()) { if (key.Ends_With (".shp")) { key.Split_Last (text, "."); } shapename = Project_Filename (key); text = shapename + "_time_of_day.shp"; Print_Filename (2, "New Arc Snapshot File", text); snapshot_flag = true; } //---- new snapshot file ---- key = Get_Control_String (NEW_SNAPSHOT_FILE); if (!key.empty ()) { Print (1); if (Check_Control_Key (NEW_SNAPSHOT_FORMAT)) { new_snapshot_file.Dbase_Format (Get_Control_String (NEW_SNAPSHOT_FORMAT)); } new_snapshot_file.Location_Flag (true); new_snapshot_file.Create (Project_Filename (key)); output_flag = true; if (project_flag) { project_coord.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); } } //---- new link summary file ---- key = Get_Control_String (NEW_LINK_SUMMARY_FILE); if (!key.empty ()) { if (occupancy_flag) { Error ("New Link Summary File requires a Snapshot File"); } Print (1); summary_file.File_Type ("Link Summary File"); if (Check_Control_Key (NEW_LINK_SUMMARY_FORMAT)) { summary_file.Dbase_Format (Get_Control_String (NEW_LINK_SUMMARY_FORMAT)); } sum_flag = true; summary_file.Create (Project_Filename (key)); } if (!snapshot_flag && !output_flag && !sum_flag) { Error ("An Arcview Snapshot, New Snapshot, or New Link Summary File is Required"); } //---- cell size ---- cell_size = Get_Control_Double (CELL_SIZE); //---- lane width ---- Read_Draw_Keys (); //---- draw vehicle shapes ---- if (snapshot_flag && !shape_flag) { circle_flag = Get_Control_Flag (ADD_PASSENGER_CIRCLE_SIZE); square_flag = Get_Control_Flag (ADD_PASSENGER_SQUARE_SIZE); } //---- pad file time labels ---- pad_flag = Get_Control_Flag (PAD_FILE_TIME_LABEL); //---- get the time processing method ---- key = Get_Control_Text (TIME_PROCESSING_METHOD); if (!key.empty ()) { for (i=0; (int) method_text [i].size () > 0; i++) { if (key.Equals (method_text [i])) { method = i; break; } } if ((int) method_text [i].size () == 0) { Error (String ("Unrecognized Time Processing Method = %s") % key); } if (!occupancy_flag && method == TOTAL) { Error ("Snapshot Files cannot be Totaled"); } } //---- initialize the shape file ---- arcview_snapshot.File_Type ("New Arc Snapshot File"); arcview_snapshot.File_Access (CREATE); arcview_snapshot.Shape_Type ((shape_flag) ? POLYGON : DOT); arcview_snapshot.Z_Flag (z_flag); arcview_snapshot.M_Flag (m_flag); if (occupancy_flag) { arcview_snapshot.Replicate_Fields (&occupancy_file); arcview_snapshot.LinkDir_Type ((Direction_Type) occupancy_file.LinkDir_Type ()); link_field = occupancy_file.Link_Field (); dir_field = occupancy_file.Dir_Field (); start_field = occupancy_file.Start_Field (); end_field = occupancy_file.End_Field (); lane_field = occupancy_file.Lane_Field (); offset_field = occupancy_file.Offset_Field (); occ_field = occupancy_file.Occupancy_Field (); type_field = -1; } else { Snapshot_File *file = &snapshot_file; if (file->Compress_Flag ()) { dummy_snapshot.Status_Flag (); dummy_snapshot.Create_Fields (); file = &dummy_snapshot; } arcview_snapshot.Replicate_Fields (file); arcview_snapshot.LinkDir_Type ((Direction_Type) file->LinkDir_Type ()); link_field = file->Link_Field (); dir_field = file->Dir_Field (); lane_field = file->Lane_Field (); offset_field = file->Offset_Field (); type_field = file->Type_Field (); cell_field = file->Cell_Field (); occ_field = start_field = end_field = -1; if (circle_flag) { arcview_snapshot.Add_Field ("RADIUS", DB_DOUBLE, 14.2); circle_field = arcview_snapshot.Field_Number ("RADIUS"); } if (square_flag) { arcview_snapshot.Add_Field ("SQUARE", DB_DOUBLE, 14.2); square_field = arcview_snapshot.Field_Number ("SQUARE"); } } arcview_snapshot.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); }
void ZoneData::Program_Control (void) { int i, size, num, decimal, existing; char *str_ptr, *format_ptr, name [FIELD_BUFFER], buffer [FIELD_BUFFER]; Db_Code::Field_Type type; Db_Header *file; //---- open network files ---- Network_Service::Program_Control (); input_file = (Zone_File *) Network_Db_File (ZONE); input_file->File_ID ("In"); output_file = (Zone_File *) Network_Db_File (NEW_ZONE); output_file->File_ID ("Out"); //---- copy existing fields ---- str_ptr = Get_Control_String (COPY_EXISTING_FIELDS); if (str_ptr != NULL) { Print (2, "Copy Existing Fields = %s", str_ptr); copy_flag = Get_Control_Flag (COPY_EXISTING_FIELDS); if (copy_flag) { output_file->Clear_Fields (); output_file->Replicate_Fields (input_file, false); } } //---- get the new zone fields ---- num = Highest_Control_Group (NEW_ZONE_FIELD_x, 0); if (num == 0) { if (Get_Control_String (NEW_ZONE_FIELD) != NULL) { num = 1; } } else { num++; } if (num == 0) { if (!copy_flag) { Warning ("No New Zone Fields"); } } else { Print (1); for (i=0; i < num; i++) { if (i == 0) { str_ptr = Get_Control_String (NEW_ZONE_FIELD); } else { str_ptr = Get_Control_String (NEW_ZONE_FIELD_x, i); } if (str_ptr == NULL) continue; if (i == 0) { Print (1, "New Zone Field = %s", str_ptr); } else { Print (1, "New Zone Field #%d = %s", i, str_ptr); } str_ptr = Get_Token (str_ptr, name, sizeof (name)); if (name [0] == '\0') goto data_error; existing = output_file->Field_Number (name); if (existing != 0) goto field_error; str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (buffer [0] == '\0' || buffer [0] == 'I') { type = INTEGER; } else if (buffer [0] == 'R' || buffer [0] == 'D') { type = DOUBLE; } else if (buffer [0] == 'S' || buffer [0] == 'C') { type = STRING; } else { goto data_error; } str_ptr = Get_Token (str_ptr, buffer); if (buffer [0] == '\0') { size = 10; if (type == DOUBLE) { decimal = 2; } else { decimal = 0; } } else { size = atoi (buffer); if (type == DOUBLE) { str_ptr = strchr (buffer, '.'); if (str_ptr != NULL) { decimal = atoi (str_ptr+1); } else { decimal = 2; } } else { decimal = 0; } } output_file->Add_Field (name, type, size, decimal); } } if (copy_flag && output_file->Notes_Flag ()) { if (output_file->Field_Number ("NOTES") == 0) { output_file->Add_Field ("NOTES", STRING, FIELD_BUFFER); } } output_file->Write_Header (); //---- check for data files ---- num_data_files = Highest_Control_Group (DATA_FILE_x, 0); if (num_data_files == 0) { if (Get_Control_String (DATA_FILE) != NULL) { num_data_files = 1; } } else { num_data_files++; } if (num_data_files > 0) { data_flag = true; } //---- check for polygon files ---- num_polygons = Highest_Control_Group (BOUNDARY_POLYGON_x, 0); if (num_polygons == 0) { if (Get_Control_String (BOUNDARY_POLYGON) != NULL) { num_polygons = 1; } } else { num_polygons++; } if (num_polygons > 0) { polygon_flag = true; } //---- read conversion script ---- str_ptr = Get_Control_String (CONVERSION_SCRIPT); if (str_ptr == NULL) { if (data_flag || polygon_flag) { Error ("A Convertion Script is needed for Data Processing"); } } else { script_flag = true; Print (1); program_file.File_Type ("Conversion Script"); program_file.Open (Project_Filename (str_ptr)); Print (1); } //---- read data files ---- if (data_flag) { //---- allocate data files ---- data_files = new Db_Header * [num_data_files]; data_field = new int [num_data_files]; zone_field = new int [num_data_files]; if (data_files == NULL || data_field == NULL || zone_field == NULL) { Error ("Insufficient Memory for %d Data Files", num_data_files); } memset (data_files, '\0', num_data_files * sizeof (Db_Header *)); memset (data_field, '\0', num_data_files * sizeof (int)); memset (zone_field, '\0', num_data_files * sizeof (int)); //---- open each file ---- for (i=0; i < num_data_files; i++) { if (i == 0) { str_ptr = Get_Control_String (DATA_FILE); } else { str_ptr = Get_Control_String (DATA_FILE_x, i); } if (str_ptr == NULL) continue; //---- create a header file and file labels ---- Print (1); data_files [i] = file = new Db_Header (); if (i == 0) { file->File_Type ("Data File"); file->File_ID ("Data"); format_ptr = Get_Control_String (DATA_FORMAT); } else { str_fmt (buffer, sizeof (buffer), "Data File #%d", i); file->File_Type (buffer); str_fmt (buffer, sizeof (buffer), "Data%d", i); file->File_ID (buffer); format_ptr = Get_Control_String (DATA_FORMAT_x, i); } //---- open the file ---- if (format_ptr != NULL) { file->Dbase_Format (format_ptr); } file->Open (Project_Filename (str_ptr)); //---- find the data join field ---- if (i == 0) { str_ptr = Get_Control_String (DATA_JOIN_FIELD); } else { str_ptr = Get_Control_String (DATA_JOIN_FIELD_x, i); } if (str_ptr == NULL) goto control_error; data_field [i] = file->Field_Number (str_ptr); if (data_field [i] == 0) { Error ("Data Join Field %s was Not Found", str_ptr); } if (i == 0) { Print (1, "Data Join Field = %s, Number = %d", str_ptr, data_field [i]); } else { Print (1, "Data Join Field #%d = %s, Number = %d", i, str_ptr, data_field [i]); } //---- find the zone join field ---- if (i == 0) { str_ptr = Get_Control_String (ZONE_JOIN_FIELD); } else { str_ptr = Get_Control_String (ZONE_JOIN_FIELD_x, i); } if (str_ptr == NULL) goto control_error; zone_field [i] = input_file->Field_Number (str_ptr); if (zone_field [i] == 0) { Error ("Zone Join Field %s was Not Found", str_ptr); } if (i == 0) { Print (1, "Zone Join Field = %s, Number = %d", str_ptr, zone_field [i]); } else { Print (1, "Zone Join Field #%d = %s, Number = %d", i, str_ptr, zone_field [i]); } } } //---- read the boundary polygons ---- if (polygon_flag) { Arcview_File *poly_file; projection.Read_Control (); //---- allocate data files ---- polygon_files = new Arcview_File * [num_polygons]; polygons = new Index_Array * [num_polygons]; polygon_db = new Db_Index_Array * [num_polygons]; if (polygon_files == NULL || polygons == NULL || polygon_db == NULL) { Error ("Insufficient Memory for %d Polygon Files", num_polygons); } memset (polygon_files, '\0', num_polygons * sizeof (Arcview_File *)); memset (polygons, '\0', num_polygons * sizeof (Index_Array *)); memset (polygon_db, '\0', num_polygons * sizeof (Db_Index_Array *)); //---- open each file ---- for (i=0; i < num_polygons; i++) { if (i == 0) { str_ptr = Get_Control_String (BOUNDARY_POLYGON); } else { str_ptr = Get_Control_String (BOUNDARY_POLYGON_x, i); } if (str_ptr == NULL) continue; //---- open the file ---- polygon_files [i] = poly_file = new Arcview_File (); polygons [i] = new Index_Array (sizeof (Boundary)); poly_file->Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); Print (1); if (i == 0) { poly_file->File_Type ("Boundary Polygon File"); poly_file->File_ID ("Polygon"); } else { str_fmt (buffer, sizeof (buffer), "Boundary Polygon File #%d", i); poly_file->File_Type (buffer); str_fmt (buffer, sizeof (buffer), "Polygon%d", i); poly_file->File_ID (buffer); } poly_file->Open (Project_Filename (str_ptr)); } } Show_Message (1); return; control_error: Error ("Missing Control Key = %s", Current_Key ()); data_error: Error ("New Zone Field %d is Improperly Specified", i); field_error: Error ("New Zone Field %s already exists as Field %d", name, existing); }
void TransimsNet::Program_Control (void) { int i, num, lvalue; double dvalue; char *str_ptr, buffer [FIELD_BUFFER]; Area_Type *type_ptr; //---- open network files ---- Network_Service::Program_Control (); //---- set the file flags ---- shape_flag = Network_File_Flag (NEW_SHAPE); zone_flag = Network_File_Flag (ZONE); zout_flag = Network_File_Flag (NEW_ZONE); name_flag = (((Link_File *) Network_Db_Base (LINK))->Name_Flag () && ((Link_File *) Network_Db_Base (NEW_LINK))->Name_Flag ()); turn_flag = Network_File_Flag (TURN_PROHIBITION); //---- set the zone fields ---- if (zout_flag) { if (!zone_flag) { Print (2, "Zone Centroids Copied from Node File"); } else { Zone_File *file = (Zone_File *) Network_Db_File (ZONE); Zone_File *new_file = (Zone_File *) Network_Db_File (NEW_ZONE); new_file->Clear_Fields (); new_file->Replicate_Fields (file); new_file->Write_Header (); } } //---- keep node list ---- str_ptr = Get_Control_String (KEEP_NODE_LIST); if (str_ptr != NULL) { Print (1); keep_nodes.File_Type ("Keep Node List File"); keep_nodes.Open (Network_Filename (str_ptr)); } //---- link node equivalance ---- str_ptr = Get_Control_String (LINK_NODE_EQUIVALENCE); if (str_ptr != NULL) { Print (1); node_string.File_Type ("Link Node Equivalence File"); node_string.Create (New_Filename (str_ptr)); } //---- get the pocket lane lengths ---- Print (1); num = Highest_Control_Group (POCKET_LENGTHS_FOR_FACILITY_x, 0); if (num >= EXTERNAL) num = EXTERNAL - 1; for (i=1; i <= num; i++) { str_ptr = Get_Control_String (POCKET_LENGTHS_FOR_FACILITY_x, i); if (str_ptr != NULL) { Print (1, "Pocket Lengths for Facility Type %d = %s meters", i, str_ptr); while (str_ptr != NULL) { str_ptr = Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > 2000.0) { Error ("Pocket Length %.1lf for Facility %d is Out of Range (0..2000)", dvalue, i); } if (!pocket_len [i].Add (Round (dvalue))) { Error ("Adding Pocket Lane Length"); } } } } //---- get the pocket to facility ---- str_ptr = Get_Control_String (POCKET_TO_FACILITY_BY_AREA_TYPE); if (str_ptr != NULL) { pocket_to_flag = true; Print (1, "Pocket To Facility Types by Area Type = %s", str_ptr); while (str_ptr != NULL) { str_ptr = Get_Integer (str_ptr, &lvalue); if (lvalue < 0 || lvalue > EXTERNAL) { Error ("Pocket To Facility %d is Out of Range (0..%d)", lvalue, EXTERNAL); } if (!pocket_to.Add (lvalue)) { Error ("Adding Pocket To Facility"); } } } //---- get the signal warrants ---- Print (1); num = Highest_Control_Group (SIGNAL_WARRANT_FOR_AREA_TYPE_x, 0); for (i=1; i <= num; i++) { str_ptr = Get_Control_String (SIGNAL_WARRANT_FOR_AREA_TYPE_x, i); if (str_ptr != NULL) { Area_Type type_rec (i); Print (1, "Signal Warrant for Area Type %d = %s", i, str_ptr); str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); type_rec.Primary (Facility_Code (buffer)); str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); type_rec.Secondary (Facility_Code (buffer)); str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (*buffer == '\0') { str_cpy (buffer, sizeof (buffer), "ACTUATED"); } type_rec.Signal_Type (Signal_Code (buffer)); str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (*buffer == '\0') { str_cpy (buffer, sizeof (buffer), "SINGLE_RING"); } type_rec.Ring_Type (Ring_Code (buffer)); if (!area_type.Add (&type_rec)) goto type_error; } } //---- get the sign warrants ---- Print (1); num = Highest_Control_Group (STOP_WARRANT_FOR_AREA_TYPE_x, 0); for (i=1; i <= num; i++) { str_ptr = Get_Control_String (STOP_WARRANT_FOR_AREA_TYPE_x, i); if (str_ptr != NULL) { type_ptr = area_type.Get (i); lvalue = Facility_Code (str_ptr); if (type_ptr == NULL) { Area_Type type_rec (i); type_rec.All_Stop (lvalue); if (!area_type.Add (&type_rec)) goto type_error; } else { type_ptr->All_Stop (lvalue); } Print (1, "Stop Warrant for Area Type %d = %s", i, str_ptr); } } //---- activity location side offset ---- str_ptr = Get_Control_String (ACTIVITY_LOCATION_SIDE_OFFSET); if (str_ptr != NULL) { Get_Double (str_ptr, &location_side); if (location_side < 0.0 || location_side > 100.0) { Error ("Activity Location Side Offset %.2lf is Out of Range (0..100)", location_side); } } Print (2, "Activity Location Side Offset = %.2lf meters", location_side); //---- get the facility type access flags ---- str_ptr = Get_Control_String (FACILITY_TYPE_ACCESS_FLAGS); if (str_ptr != NULL) { for (i=1; str_ptr != NULL; i++) { str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (*buffer == '\0') break; access_flag [i] = (*buffer == '1' || *buffer == 't' || *buffer == 'T' || *buffer == 'y' || *buffer == 'Y'); } } Print (2, "Facility Type Access Flags = "); for (i=1; i <= EXTERNAL; i++) { if (i > 1) { Print (0, ", %d", access_flag [i]); } else { Print (0, "%d", access_flag [i]); } } //---- get the number of access points ---- str_ptr = Get_Control_String (MAXIMUM_ACCESS_POINTS); if (str_ptr == NULL) goto control_error; Get_Integer (str_ptr, &max_splits); if (max_splits < 1 || max_splits > 20) { Error ("Maximum Number of Access Points %d is Out of Range", max_splits); } Print (2, "Maximum Number of Access Points Per Link = %d", max_splits); //---- get the min split length ---- str_ptr = Get_Control_String (MINIMUM_SPLIT_LENGTHS); if (str_ptr == NULL) goto control_error; Print (2, "Minimum Split Lengths = %s meters", str_ptr); for (i=1; str_ptr != NULL; i++) { str_ptr = Get_Integer (str_ptr, &lvalue); if (lvalue == 0) continue; if (lvalue < 40 || lvalue > 4000) { Error ("Minimum Split Length %d is Out of Range (40-4000)", lvalue); } lvalue = Round (lvalue); type_ptr = area_type.Get (i); if (type_ptr == NULL) { Area_Type type_rec (i); type_rec.Split_Len (lvalue); if (!area_type.Add (&type_rec)) goto type_error; } else { type_ptr->Split_Len (lvalue); } } //---- get the cell size ---- str_ptr = Get_Control_String (CELL_SIZE); if (str_ptr != NULL) { Get_Double (str_ptr, &cell_size); if (cell_size < 4.0 || cell_size > 9.0) { Error ("Cell Size %.2lf is Out of Range (4..9)", cell_size); } } Print (2, "Cell Size = %.2lf meters", cell_size); //---- get the minimum link length ---- str_ptr = Get_Control_String (MINIMUM_LINK_LENGTH); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < cell_size || dvalue > 100.0) { Error ("Minimum Link Length %.1lf is Out of Range (%.1lf..100.0)", dvalue, cell_size); } } else { dvalue = cell_size * 5.0; } min_length = Round (dvalue); Print (2, "Minimum Link Length = %.1lf meters", UnRound (min_length)); //---- get the maximum length factor ---- str_ptr = Get_Control_String (MAXIMUM_LENGTH_TO_XY_RATIO); if (str_ptr != NULL) { Get_Double (str_ptr, &max_length_factor); if (max_length_factor < 1.0 || max_length_factor > 2.0) { Error ("Maximum Length to XY Ratio %.1lf is Out of Range (1.0..2.0)", max_length_factor); } } Print (2, "Maximum Length to XY Ratio = %.2lf", max_length_factor); //---- get the maximum connection angle ---- str_ptr = Get_Control_String (MAXIMUM_CONNECTION_ANGLE); if (str_ptr != NULL) { Get_Integer (str_ptr, &lvalue); if (lvalue < 90 || lvalue > 180) { Error ("Maximum Connection Angle %d is Out of Range (90..180)", lvalue); } max_angle = compass.Num_Points () * lvalue / 360; } Print (2, "Maximum Connection Angle = %d degrees", max_angle * 360 / compass.Num_Points ()); //---- uturn flag ---- uturn_flag = Get_Control_Flag (ADD_UTURN_TO_DEADEND_LINKS); if (uturn_flag) { Print (1, "U-Turns will be added to Dead-End Links"); } else { Print (1, "U-Turns will not be added to Dead-End Links"); } //---- get the setback distance ---- str_ptr = Get_Control_String (INTERSECTION_SETBACK_DISTANCE); if (str_ptr != NULL) { Get_Double (str_ptr, &dvalue); if (dvalue < 0.0 || dvalue > 20.0) { Error ("Intersection Setback Distance %.1lf is Out of Range (0.0..20.0)", dvalue); } } else { dvalue = 0.0; } setback = Round (dvalue); Print (2, "Intersection Setback Distance = %.1lf meters", UnRound (setback)); //---- get the external zone number ---- str_ptr = Get_Control_String (FIRST_EXTERNAL_ZONE_NUMBER); if (str_ptr != NULL) { Get_Integer (str_ptr, &ext_zone); if (ext_zone < 0 || ext_zone > 10000) { Error ("External Zone Number %d is Out of Range (0..10000)", ext_zone); } } else { ext_zone = 0; } Print (2, "First External Zone Number = %d", ext_zone); //---- get the zone connector flag ---- str_ptr = Get_Control_String (KEEP_ZONE_CONNECTORS_AS_LOCALS); if (str_ptr != NULL) { Print (1, "Keep Zone Connectors as Locals = %s", str_ptr); connect_flag = Get_Control_Flag (KEEP_ZONE_CONNECTORS_AS_LOCALS); } //---- get the replicate MPO network ---- str_ptr = Get_Control_String (REPLICATE_MPO_NETWORK); if (str_ptr != NULL) { Print (1, "Replication MPO Network = %s", str_ptr); replicate_flag = Get_Control_Flag (REPLICATE_MPO_NETWORK); } //---- collapse nodes flag ---- if (Get_Control_String (COLLAPSE_NODES_FLAG) != NULL) { collapse_flag = Get_Control_Flag (COLLAPSE_NODES_FLAG); } if (collapse_flag) { Print (2, "Extra Nodes will be Removed from the Network"); } else { Print (2, "All Nodes in the Network will be Kept"); } //---- update node range ---- str_ptr = Get_Control_String (UPDATE_NODE_RANGE); if (str_ptr != NULL) { update_flag = true; Print (2, "Update Node Range = %s", str_ptr); if (!update_nodes.Add_Ranges (str_ptr)) { Error ("Adding Update Nodes"); } } //---- update node file ---- str_ptr = Get_Control_String (UPDATE_NODE_FILE); if (str_ptr != NULL) { update_flag = update_node_flag = true; Print (1); update_node_file.File_Type ("Update Node File"); if (!update_node_file.Open (Project_Filename (str_ptr))) { Error ("Opening %s", update_node_file.File_Type ()); } } //---- update link range ---- str_ptr = Get_Control_String (UPDATE_LINK_RANGE); if (str_ptr != NULL) { update_flag = true; Print (2, "Update Link Range = %s", str_ptr); if (!update_links.Add_Ranges (str_ptr)) { Error ("Adding Update Links"); } } //---- update link file ---- str_ptr = Get_Control_String (UPDATE_LINK_FILE); if (str_ptr != NULL) { update_flag = update_link_flag = true; Print (1); update_link_file.File_Type ("Update Link File"); if (!update_link_file.Open (Project_Filename (str_ptr))) { Error ("Opening %s", update_link_file.File_Type ()); } } //---- delete node range ---- str_ptr = Get_Control_String (DELETE_NODE_RANGE); if (str_ptr != NULL) { delete_flag = true; Print (2, "Delete Node Range = %s", str_ptr); if (!delete_nodes.Add_Ranges (str_ptr)) { Error ("Adding Delete Nodes"); } } //---- delete node file ---- str_ptr = Get_Control_String (DELETE_NODE_FILE); if (str_ptr != NULL) { delete_flag = delete_node_flag = true; Print (1); delete_node_file.File_Type ("Delete Node File"); if (!delete_node_file.Open (Project_Filename (str_ptr))) { Error ("Opening %s", delete_node_file.File_Type ()); } } //---- delete link range ---- str_ptr = Get_Control_String (DELETE_LINK_RANGE); if (str_ptr != NULL) { delete_flag = true; Print (2, "Delete Link Range = %s", str_ptr); if (!delete_links.Add_Ranges (str_ptr)) { Error ("Adding Delete Links"); } } //---- delete link file ---- str_ptr = Get_Control_String (DELETE_LINK_FILE); if (str_ptr != NULL) { delete_flag = delete_link_flag = true; Print (1); delete_link_file.File_Type ("Delete Link File"); if (!delete_link_file.Open (Project_Filename (str_ptr))) { Error ("Opening %s", delete_link_file.File_Type ()); } } //---- link detail file ---- str_ptr = Get_Control_String (LINK_DETAIL_FILE); if (str_ptr != NULL) { Print (1); detail_flag = true; if (!detail_file.Open (Project_Filename (str_ptr))) { Error ("Opening %s", detail_file.File_Type ()); } lane_use_flag = Network_File_Flag (NEW_LANE_USE); } //---- get the projection data ---- projection.Read_Control (); coord.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); Set_Projection (&coord); return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); type_error: Error ("Adding Area Type Record"); }