Hiyas, I have my routes calculating but just wanted to see if there is a better way of getting distance between jobs and total route distance.
for (VehicleRoute route : Solutions.bestOf(solutions).getRoutes()) {
totalTime += route.getEnd().getArrTime();
prevAct = route.getStart();
for (TourActivity act : route.getActivities()) {
if(act == route.getStart()){
prevAct = act;
}else{
routeDistance += getDistance(prevAct, act, costMatrix);
prevAct = act;
}
}
}
static double getDistance(TourActivity from, TourActivity to, VehicleRoutingTransportCostsMatrix costMatrix) {
return costMatrix.getDistance(from.getLocation().getId(), to.getLocation().getId());
}
Iām happy with the route time, but am I correct in using the costMatrix to produce distances?