GraphHopper.com | Forum | GitHub | Maps | Blog

How to add a speed factor?


#1

Hi all.
In the GraphHopper Route Optimization API you can specify a speed factor to adjust the driving times. In the open source version, is there a better way than using the inverse speed factor value in the VehicleCostParams.perDistanceUnit parameter? Eg, if the speed factor is 0.8, set the distance cost to 1.25?
Thanks!


#2

So that didn’t work.
Next, I tried using a time multiplier, which did work. But I had to create a wrapper for FastVehicleRoutingTransportCostsMatrix that does

@Override public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
	double time = matrix.getTransportTime(from, to, departureTime, driver, vehicle);
	if (vehicle != null) {
		VehicleTypeImpl.VehicleCostParams costParams = vehicle.getType().getVehicleCostParams();
		if (costParams.perTransportTimeUnit > 0)
			time *= costParams.perTransportTimeUnit;
	}
	return time;
}

Anybody knows a simpler way? Or one that doesn’t overload the meaning of the per-transport-time cost?
Thanks!