21
21
import com .graphhopper .routing .*;
22
22
import com .graphhopper .routing .weighting .Weighting ;
23
23
import com .graphhopper .storage .*;
24
+ import com .graphhopper .util .Helper ;
24
25
25
26
import static com .graphhopper .util .Parameters .Algorithms .*;
26
27
@@ -37,7 +38,7 @@ public RoutingAlgorithm createAlgo(Graph graph, AlgorithmOptions opts) {
37
38
// graph we have to use: the CH graph. Same with opts.weighting: The CHConfig already contains a weighting
38
39
// and we cannot really use it here. The real reason we do this the way its done atm is that graph might be
39
40
// a QueryGraph that wraps (our) CHGraph.
40
- RoutingAlgorithm algo = doCreateAlgo (graph , opts );
41
+ RoutingAlgorithm algo = doCreateAlgo (graph , AlgorithmOptions . start ( opts ). weighting ( getWeighting ()). build () );
41
42
algo .setMaxVisitedNodes (opts .getMaxVisitedNodes ());
42
43
return algo ;
43
44
}
@@ -50,16 +51,16 @@ private RoutingAlgorithm doCreateAlgo(Graph graph, AlgorithmOptions opts) {
50
51
if (turnCostStorage == null ) {
51
52
throw new IllegalArgumentException ("For edge-based CH you need a turn cost extension" );
52
53
}
53
- RoutingCHGraph g = new RoutingCHGraphImpl (graph , graph .wrapWeighting (getWeighting ()));
54
+ RoutingCHGraph g = new RoutingCHGraphImpl (graph , graph .wrapWeighting (opts . getWeighting ()));
54
55
return createAlgoEdgeBased (g , opts );
55
56
} else {
56
- RoutingCHGraph g = new RoutingCHGraphImpl (graph , chConfig .getWeighting ());
57
+ RoutingCHGraph g = new RoutingCHGraphImpl (graph , opts .getWeighting ());
57
58
return createAlgoNodeBased (g , opts );
58
59
}
59
60
}
60
61
61
62
private RoutingAlgorithm createAlgoEdgeBased (RoutingCHGraph g , AlgorithmOptions opts ) {
62
- if (ASTAR_BI .equals (opts .getAlgorithm ())) {
63
+ if (ASTAR_BI .equals (opts .getAlgorithm ()) || Helper . isEmpty ( opts . getAlgorithm ()) ) {
63
64
return new AStarBidirectionEdgeCHNoSOD (g )
64
65
.setApproximation (RoutingAlgorithmFactorySimple .getApproximation (ASTAR_BI , opts , g .getGraph ().getNodeAccess ()));
65
66
} else if (DIJKSTRA_BI .equals (opts .getAlgorithm ())) {
@@ -75,7 +76,7 @@ private RoutingAlgorithm createAlgoNodeBased(RoutingCHGraph g, AlgorithmOptions
75
76
if (ASTAR_BI .equals (opts .getAlgorithm ())) {
76
77
return new AStarBidirectionCH (g )
77
78
.setApproximation (RoutingAlgorithmFactorySimple .getApproximation (ASTAR_BI , opts , g .getGraph ().getNodeAccess ()));
78
- } else if (DIJKSTRA_BI .equals (opts .getAlgorithm ())) {
79
+ } else if (DIJKSTRA_BI .equals (opts .getAlgorithm ()) || Helper . isEmpty ( opts . getAlgorithm ()) ) {
79
80
if (opts .getHints ().getBool ("stall_on_demand" , true )) {
80
81
return new DijkstraBidirectionCH (g );
81
82
} else {
0 commit comments