The sample code below uses five stops. A formula for converting thousandths of hours to hours and minutes is included below the sample code.


void TestRouteMatrix_UserGuide(PCMServerID server)
{
    //The Lat/Longs for the stops used in each comparison
    const int NUM_STOPS = 5;
    const char* latLongs[] = {     "35.173099517822266n,107.89029693603516w",
                                   "35.160099029541016n,103.70149993896484w",
                                   "35.232200622558594n,97.485397338867188w",
                                   "34.064998626708984n,81.024497985839844w",
                                   "43.603099822998047n,96.767799377441406w"};
                                                
    Trip matTrip = PCMSNewTrip(server);

    // Set up the Matrix Routing options
    PCMSSetCalcType(matTrip, CALC_PRACTICAL);
    PCMSMatrixSetOptions(matTrip);


    // Set the number of threads to be used internally
    PCMSMatrixSetThreadCount(2);

    // Add the stops onto the matrix
    for (int i = 0; i < NUM_STOPS; i++)
    {
           PCMSMatrixAddStop(latLongs[i]);
    }

    // Error check to see if the stops are loaded to the matrix correctly
    long lStopCount =  PCMSMatrixGetStopCount();
    if (lStopCount <= 0)
    {
           printf("ERROR: Could not load stops!\n");
    }
    else
    {

           // Calculate the routes
           PCMSMatrixCalculate(NULL);

           // Print the distance results
           for (long i = 0; i < lStopCount; i++)
           {
                  for (long j = 0; j < lStopCount; j++)
                  {
                        char szBuffer[256]= {0};
                        PCMSMatrixGetCell(i, j, 0, szBuffer, sizeof(szBuffer));
                        printf("%s\t", szBuffer);
                  }
                  printf("\n");
           } 
    }

    //Clear the matrix of all data so that it can be run again
    PCMSMatrixClear();
}


To convert thousandths of hours to hours and minutes, use the following formula:

Public int ConvertDurationHours(double duration, out long hours, out long minutes) 
  {
    // Duration is stored in thousandths of an hour 
      bool bLessThan0 = duration < 0;
      duration = bLessThan0 ? -duration : duration;

      double time = (double)(duration) / 1000;
 
      hours = (int)(time);
      minutes = (int)((60.0 * (time - hours)) + 0.5);
      if (60 == minutes)
      {
        hours++;
        minutes = 0;
      }

      hours = bLessThan0 ? -hours : hours;
      minutes = bLessThan0 ? -minutes : minutes;
      return (0);
  }