use of com.graphhopper.routing.querygraph.QueryRoutingCHGraph in project graphhopper by graphhopper.
the class CHTurnCostTest method testRouteViaVirtualNode_withAlternative.
@ParameterizedTest
@ValueSource(strings = { DIJKSTRA_BI, ASTAR_BI })
public void testRouteViaVirtualNode_withAlternative(String algo) {
// 3
// 0-x-1
// \ |
// \-2
GHUtility.setSpeed(60, true, true, encoder, graph.edge(0, 1).setDistance(1));
GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(1));
GHUtility.setSpeed(60, true, true, encoder, graph.edge(2, 0).setDistance(1));
updateDistancesFor(graph, 0, 0.01, 0.00);
updateDistancesFor(graph, 1, 0.01, 0.02);
updateDistancesFor(graph, 2, 0.00, 0.02);
graph.freeze();
automaticPrepareCH();
LocationIndexTree index = new LocationIndexTree(graph, new RAMDirectory());
index.prepareIndex();
Snap snap = index.findClosest(0.01, 0.01, EdgeFilter.ALL_EDGES);
QueryGraph queryGraph = QueryGraph.create(graph, snap);
assertEquals(3, snap.getClosestNode());
assertEquals(0, snap.getClosestEdge().getEdge());
QueryRoutingCHGraph routingCHGraph = new QueryRoutingCHGraph(chGraph, queryGraph);
RoutingAlgorithm chAlgo = new CHRoutingAlgorithmFactory(routingCHGraph).createAlgo(new PMap().putObject(ALGORITHM, algo));
Path path = chAlgo.calcPath(1, 0);
assertEquals(IntArrayList.from(1, 3, 0), path.calcNodes());
}
Aggregations