Get the fastest and shortest routes simultaneously

You can generate routes using different criteria of speed and accessibility, such as routes for private vehicles, or for walking, or for cycling, or the shortest route instead of the fastest route.

 fastest and shortest route

The map above shows the fastest route in orange and the shortest route in blue. The CartoType framework API makes it very easy to add extra routing profiles, or change the main routing profile (which is by default the private car profile). Here's some sample code from a Windows app showing the creation of the framework and the addition of a new profile:

CFrameworkEngine& engine = app->Engine();
 CFrameworkMapDataSet& dataset = doc->MapDataSet();
 iFramework = CFramework::New(error,engine,dataset,app->DefaultStyleSheetName(),w,h);
 if (error)
 app->ShowError("error creating CartoType framework",error);
// Tell the framework to send us navigation messages.
// Add an extra routing profile for the shortest route, not the fastest.
 Router::TProfile profile;
 profile.iShortest = true;

A routing profile contains estimated speeds, restricted vehicle types, and weightings.

class TProfile
TProfile(TProfileType aProfileType = ECarProfile);
 Flags taken from KArcWrongWayFlag ... KArcHazardousAccessFlag indicating the vehicle type.
 Arcs with restrictions matching any of these flags will not be taken.
 uint32 iVehicleType;
/** Speeds along roads in kilometres per hour. */ 
 TFixedSizeArray<double,KArcRoadTypeCount> iSpeed;
 Bonuses or penalties in notional km per hour to be added to road types to make them more or less likely to be used.
 For example, a penalty of 1kph is applied to walking routes along major roads because it is pleasanter to walk along quieter minor roads.
 TFixedSizeArray<double,KArcRoadTypeCount> iBonus;
/** The estimated average time in seconds taken for a turn that is not straight ahead. */
 int32 iTurnTime;
/** If true, ignore the speed when routing; get the shortest route, not the fastest. */
 bool iShortest;
// ...

When CartoType calculates a route, the speed and bonus for each route segment are added together. If the result is zero or negative the segment is not used. Otherwise this 'notional speed' is used to calculate a weighting for the segment, based on its distance. The speeds alone, without the bonuses are used to calculate an estimated time. If iShortest is true, though, the same notional speed is used for every legal route segment, giving an even weighting and thus the shortest distance.

There are API functions for choosing a route among alternatives, and all the alternative routes are displayed when you call DisplayRoute.