PC*MILER|Connect includes simplified functions for distance calculation between an origin and a destination without any stops, using PC*MILER's industry standard mileage database. These functions do not allow access to any Connect trip options or features, but they do make it easy to calculate miles without managing trips from your application. The steps for this process, which is the simplest use of the PCMSRV32 DLL, are:

  1. Start the PC*MILER Connect engine.
  2. Calculate the miles from point A to point B.
  3. Repeat with as many origin-destination pairs as you want.
  4. Shut down the engine.

Calculating Distances

Before calculating distances, it is strongly recommended that you validate your city names and ZIP codes using the function PCMSLookup with option 5, which returns extended geocoding error codes when an exact match to your input is not found.

Once the trip is created using PCMSNewTrip, you can do simple calculations with a trip or more complex ones using various route and report options. Here are the main functions for simple distance calculation:

Sample code to calculate the distance between Chicago, IL, and New York, NY, using three different route types.

  void RunRoutes(PCMServerID server)
      long minutes;
      long hours;
      long miles;
      int matches;
    /* Note: Server must already be initialized. */
      Trip trip = PCMSNewTrip(server);
    /* Calculate the distance using default calculation */
      miles = PCMSCalcTrip(trip, “Chicago, IL”,
        “New York, NY”);
      printf(“Practical: %f\n”, miles / 10.0);
    /* Calculate the distance using shortest algorithm */
      PCMSSetCalcType(trip, CALC_SHORTEST);
      miles = PCMSCalcTrip(trip, “Chicago, IL”,
        “New York, NY”);
      printf(“Shortest: %f\n”, miles / 10.0);
    /* Calculate the distance avoiding toll roads */
      PCMSSetCalcType(trip, CALC_AVOIDTOLL);
      miles = PCMSCalcTrip(trip, “Chicago, IL”,
        “New York, NY”);
      minutes = PCMSGetDuration(trip);
      printf(“Toll Avoid: %f miles\n”, miles / 10.0);
    /* Show the duration in hour:minute notation */
      hours = minutes / 60;
      minutes = minutes % 60;
      printf(“Duration: %ld:%ld\n”, hours, minutes);
    /* Check the spelling of a city and ZIP */
    matches = PCMSLookup(trip, “San Fran, CA”, 5);
    printf(“Matching city names: %d\n”, matches);