If the Tolls add-on feature is licensed and installed, there are five PC*MILER Connect functions that support toll calculations. A sixth function, PCMSSetVehicleConfig, enables toll cost calculation with custom vehicle dimensions and number of axles taken into account.


Once the toll information and optional vehicle information have been passed in, the routing results can be retrieved using the standard PCMSGetRpt and PCMSGetRptLine APIs.

  • PCMSSetTollMode sets whether no tolls are calculated; tolls are to be calculated on an all-cash basis; or discount programs are to be used in toll calculations during a trip. By default, toll discount programs are enabled.
  • PCMSGetToll request the total toll charges for the trip.
  • PCMSNumTollDiscounts returns the number of available toll discount programs.
  • PCMSGetTollDiscountName retrieves the available toll discount program name by index value.
  • PCMSGetTollBreakdown gets the toll amount attributable to a particular discount program.


The following sample code demonstrates the use of most of the toll functions:

void Test_tolls(PCMServerID serv)

{
    Trip trip1;
    int I, numPrograms;
    float miles;
    float TollsTotal, programTolls;
    char programName[20];

    /* create a new trip */
    trip1 = PCMSNewTrip(server);

    /* run a route */
    miles = PCMSCalcTrip(trip1, "New York, NY",
                         "Washington, DC") / 10.0;
    
printf("Total mileage = %.1f miles\n", miles);
    
/* get total tolls on all-cash basis */
    PCMSSetTollMode(trip1, TOLL_CASH);
    TollsTotal = PCMSGetToll(trip1) / 100.0;
    printf("All-cash tolls = $%.2f\n", TollsTotal);
    
/* get total tolls using discount programs */
    PCMSSetTollMode(trip1, TOLL_DISCOUNT);
    TollsTotal = PCMSGetToll(trip1) / 100.0;
    printf("Discounted tolls = $%.2f\n", TollsTotal);
    
/* get breakdown of tolls by cash part (i=0) and
       each discount program */
    PCMSSetTollMode(trip1, TOLL_DISCOUNT);
    numPrograms = PCMSNumTollDiscounts(server);
    for (i=0; i<numPrograms; ++i)
    {
    PCMSGetTollDiscountName(server, i, programName, 20);
    programTolls = PCMSGetTollBreakdown(trip1, I, “ “)/ 100.0;
    printf("%s Tolls = $%.2f\n", programName, programTolls);
}

/* delete the trip */