|
@@ -8,6 +8,16 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
8
|
8
|
super(data);
|
9
|
9
|
}
|
10
|
10
|
|
|
11
|
+ private double getMaxSpeed(Graph graph, ShortestPathData inputData) {
|
|
12
|
+ final double graphMaxSpeed = graph.getGraphInformation().getMaximumSpeed();
|
|
13
|
+ final double inputMaxSpeed = inputData.getMaximumSpeed();
|
|
14
|
+ double maxSpeed = Double.min(graphMaxSpeed, inputMaxSpeed);
|
|
15
|
+
|
|
16
|
+ if (inputMaxSpeed < 0)
|
|
17
|
+ maxSpeed = graphMaxSpeed;
|
|
18
|
+ return maxSpeed;
|
|
19
|
+ }
|
|
20
|
+
|
11
|
21
|
@Override
|
12
|
22
|
protected ShortestPathSolution doRun() {
|
13
|
23
|
final ShortestPathData data = getInputData();
|
|
@@ -19,7 +29,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
19
|
29
|
final double distance = graph.getNodes().get(i).getPoint().distanceTo(
|
20
|
30
|
data.getDestination().getPoint()
|
21
|
31
|
);
|
22
|
|
- final double maxSpeed = graph.getGraphInformation().getMaximumSpeed();
|
|
32
|
+ final double maxSpeed = getMaxSpeed(graph, data);
|
23
|
33
|
double estimatedCost = distance;
|
24
|
34
|
if (data.getMode() == ShortestPathData.Mode.TIME)
|
25
|
35
|
estimatedCost /= maxSpeed;
|