PC*MILER Connect includes several time-based routing functions you can use to set a departure or an arrival time. If the Traffic add-on is licensed and installed, and you have an Internet connection, traffic data can be applied to boost the precision of time estimates. 


The setting below can be added to the PCMSERVE.INI file to activate traffic data for time-based routing. This setting is equivalent to the “Historical Traffic” option in the PC*MILER user interface. If set to TRUE, traffic will be enabled:


HistoricalRoadSpeeds=True/False


If traffic data is not used 

Travel times and ETAs are calculated based on average road speeds (either PC*MILER default or user-specified road speeds) by class of road in each state or province.


If traffic is enabled

When a departure or arrival time and date are entered, travel times and ETAs will be calculated based on historical, typical or real-time traffic data, depending on the arrive/depart and day/time settings. (Historical data reflects how average traffic patterns affect road speeds. Typical data uses road speeds that would occur if there were no traffic.)


If a departure or arrival time and date are not entered, default travel times reflect free-flow conditions—think middle of the night. (This is the “Typical” option mentioned above.)


The following functions can be used for time-based routing

  • PCMSSetDepartureTime sets a departure time from the origin.
  • PCMSSetArrivalTime sets an arrival time at the destination.
  • PCMSGetETA generates the estimated time of arrival based on the parameters in PCMSSetDepartureTime.
  • PCMSGetETD generates the estimated time of departure based on the parameters in PCMSSetArrivalTime.
  • PCMSSetRoadSpeedType indicates if time estimate calculations for a route will be based on the traditional PC*MILER average road speeds by road type or historical traffic data.
  • PCMSTrafficStatus queries the Traffic subscription status.


Sample code for using time-based routing

// Declarations
int ArrivalYear;  // Arrival Time Zone
int ArrivalMonth;  // Arrival Month (e.g. 10 for October)
int ArrivalDay;  // Arrival Day (e.g. 23 for 23rd day of October)
int ArrivalHour;  // Arrival Hour (e.g. 10 for ten o'clock
int ArrivalMinute;  // Arrival Minute (e.g. 10 for tenth minute)
int ArrivalSecond;  // Arrival Second (e.g. 0 for zeroth second)
int DepartYear;  // Arrival Time Zone
int DepartMonth;  // Arrival Month (e.g. 10 for October)
int DepartDay;  // Arrival Day (e.g. 23 for 23rd day of October)
int DepartHour;  // Arrival Hour (e.g. 10 for ten o'clock
int DepartMinute;  // Arrival Minute (e.g. 10 for tenth minute)
int DepartSecond;  // Arrival Second (e.g. 0 for zeroth second)

// Create a new trip
trip = PCMSNewTrip(server);  

// Add the stops to trip
ret = PCMSAddStop(trip, "Dublin, PA");
ret = PCMSAddStop(trip, "Boston, MA");
ret = PCMSAddStop(trip, "Philadelphia, PA");
ret = PCMSAddStop(trip, "Baltimore, MD");

// Set Road Speed Type 
// 0 = default road speeds, 2 = Historical Road Speeds
ret = PCMSSetRoadSpeedType(trip, 2);      

/*
** Date Type used below
** Date Type - user wants current system time = 1, user specifying 
** date and time = 2, user specifying day of week and time = 3
*/

// Set arrival time to be Jul-28-2017 at 8:30 AM
ret = PCMSSetArrivalTime(trip,  // Trip ID
  3,  // Date Type          
  6,  // EasternTimeZone  1;
  2017,  // Arrival Year (e.g. 2017)
  7,  // Arrival Month (e.g. 10 for October)
  28,  // Arrival Day(e.g. 23 for 23rd day of October)
  8,  // Arrival Hour (e.g. 23 for 11:00 PM)
  30,  // Arrival Minute (e.g. 10 for tenth minute)
  0,  // Arrival Second (e.g. 0 for zeroth second)
  5);  // Arrival Day Of Week (1 == Monday, ... 0 = Sunday)  
              
// Run trip
ret = PCMSCalculate(trip);
    
// Get the number of stops in trip
int numStops = PCMSNumStops(trip);

// Get the Estimated Time Of Departure for each stop
for (int j=0; j< numStops; j++)

{
  ret = PCMSGetETD( trip,    // Trip ID
  j,  // Stop Number
  &DepartYear,  // Departure Time Zone
  &DepartMonth,  // Departure Month (eg. 10 for October)
  &DepartDay,  // Departure Day (e.g. 23 for 23rd day)
  &DepartHour,  // Departure Hour
  &DepartMinute,  // Departure Minute (e.g tenth minute)
  &DepartSecond);  // Departure Second (e.g zeroth second)  
}

// Dump Detail Report
DumpReport(trip, 0, RF_Lines);        

// Delete the Trip
PCMSDeleteTrip(trip);