In the sample code we saw how the fastest route was defined by setting:
RWcalc1.CostDist = 0
RWcalc1.CostTime = 1
This means the weight on distance is 0 and the weight on time is 1. If we want the shortest path, we just swap 1 and 0.
But it is also possible to use a linear combinations of these values and still get access to both the time and length of a calculated route:
RWcalc1.CostDist = 0.4
RWcalc1.CostTime = 1
RWcalc1.ExtraDist = 0
RWcalc1.ExtraTime = 1
Now the route is optimized according to minimizing "1.0 * time + 0.4 * distance". This means most weight is on time, while the length of the trip is also taken into consideration, so that very long routes are not chosen, just because they are slightly faster.
In order to get the time and length of the route, use this method:
Cost = RWcalc1.Route(node1,node2)
RouteTime = RWcalc1.GetNodeExtra(node2)
RouteDistance = (Cost-RouteTime) / 0.4