Fix #9345 wrong time for short route
This commit is contained in:
parent
005aa87d14
commit
45991e8834
1 changed files with 9 additions and 1 deletions
|
@ -72,6 +72,8 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
private float defaultSpeed = 1f;
|
private float defaultSpeed = 1f;
|
||||||
// speed in m/s
|
// speed in m/s
|
||||||
private float maxSpeed = 10f;
|
private float maxSpeed = 10f;
|
||||||
|
// speed in m/s (used for shortest route)
|
||||||
|
private float maxVehicleSpeed;
|
||||||
|
|
||||||
private TLongHashSet impassableRoads;
|
private TLongHashSet impassableRoads;
|
||||||
private GeneralRouterProfile profile;
|
private GeneralRouterProfile profile;
|
||||||
|
@ -149,6 +151,7 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
if (params.containsKey(MAX_SPEED)) {
|
if (params.containsKey(MAX_SPEED)) {
|
||||||
maxSpeed = parseSilentFloat(params.get(MAX_SPEED), maxSpeed);
|
maxSpeed = parseSilentFloat(params.get(MAX_SPEED), maxSpeed);
|
||||||
}
|
}
|
||||||
|
maxVehicleSpeed = maxSpeed;
|
||||||
if (shortestRoute) {
|
if (shortestRoute) {
|
||||||
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
|
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
|
||||||
}
|
}
|
||||||
|
@ -489,10 +492,15 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float defineVehicleSpeed(RouteDataObject road) {
|
public float defineVehicleSpeed(RouteDataObject road) {
|
||||||
|
// don't use cache cause max/min is different for routing speed
|
||||||
|
if (maxVehicleSpeed != maxSpeed) {
|
||||||
|
float spd = getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed);
|
||||||
|
return Math.max(Math.min(spd, maxVehicleSpeed), minSpeed);
|
||||||
|
}
|
||||||
Float sp = getCache(RouteDataObjectAttribute.ROAD_SPEED, road);
|
Float sp = getCache(RouteDataObjectAttribute.ROAD_SPEED, road);
|
||||||
if (sp == null) {
|
if (sp == null) {
|
||||||
float spd = getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed);
|
float spd = getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed);
|
||||||
sp = Math.max(Math.min(spd, maxSpeed), minSpeed);
|
sp = Math.max(Math.min(spd, maxVehicleSpeed), minSpeed);
|
||||||
putCache(RouteDataObjectAttribute.ROAD_SPEED, road, sp);
|
putCache(RouteDataObjectAttribute.ROAD_SPEED, road, sp);
|
||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
|
|
Loading…
Reference in a new issue