PC*MILER Connect includes simplified functions for distance calculation between an origin and a destination, using PC*MILER's industry standard mileage database. 

  1. Create a new trip by calling PCMSNewTrip.
  2. Call PCMSCalcTrip to return the distance between an origin and destination using the trip’s current routing type. (The default is practical routing.)
  3. Call PCMSDeleteTrip to free all resources associated with a trip handle created with PCMSNewTrip.
  4. Repeat with as many origin-destination pairs as you want.

Additional Options

With simple distance calculations, you can also:

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);