Improved max speed detection
This commit is contained in:
parent
ac18c2d522
commit
79e82989f4
1 changed files with 11 additions and 1 deletions
|
@ -8,6 +8,16 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
|||
super(data);
|
||||
}
|
||||
|
||||
private double getMaxSpeed(Graph graph, ShortestPathData inputData) {
|
||||
final double graphMaxSpeed = graph.getGraphInformation().getMaximumSpeed();
|
||||
final double inputMaxSpeed = inputData.getMaximumSpeed();
|
||||
double maxSpeed = Double.min(graphMaxSpeed, inputMaxSpeed);
|
||||
|
||||
if (inputMaxSpeed < 0)
|
||||
maxSpeed = graphMaxSpeed;
|
||||
return maxSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShortestPathSolution doRun() {
|
||||
final ShortestPathData data = getInputData();
|
||||
|
@ -19,7 +29,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
|||
final double distance = graph.getNodes().get(i).getPoint().distanceTo(
|
||||
data.getDestination().getPoint()
|
||||
);
|
||||
final double maxSpeed = graph.getGraphInformation().getMaximumSpeed();
|
||||
final double maxSpeed = getMaxSpeed(graph, data);
|
||||
double estimatedCost = distance;
|
||||
if (data.getMode() == ShortestPathData.Mode.TIME)
|
||||
estimatedCost /= maxSpeed;
|
||||
|
|
Loading…
Reference in a new issue