use of com.graphhopper.routing.weighting.TurnCostProvider in project graphhopper by graphhopper.
the class AlternativeRouteEdgeCHTest method testAssumptions.
@Test
public void testAssumptions() {
GraphHopperStorage g = createTestGraph(em);
TurnCostProvider turnCostProvider = new DefaultTurnCostProvider(carFE, g.getTurnCostStorage());
CHConfig chConfig = CHConfig.edgeBased("profile", new FastestWeighting(carFE, turnCostProvider));
CHStorage chStorage = g.createCHStorage(chConfig);
RoutingCHGraph chGraph = g.createCHGraph(chStorage, chConfig);
DijkstraBidirectionEdgeCHNoSOD router = new DijkstraBidirectionEdgeCHNoSOD(chGraph);
Path path = router.calcPath(5, 10);
assertTrue(path.isFound());
assertEquals(IntArrayList.from(5, 6, 7, 8, 4, 10), path.calcNodes());
assertEquals(50000.0, path.getDistance(), 0.0);
// 6 -> 3 -> 4 is forbidden
g = createTestGraph(em);
RoutingCHGraph routingCHGraph = prepareCH(g);
router = new DijkstraBidirectionEdgeCHNoSOD(routingCHGraph);
path = router.calcPath(5, 3, ANY_EDGE, GHUtility.getEdge(g, 2, 3).getEdge());
assertEquals(IntArrayList.from(5, 1, 9, 2, 3), path.calcNodes());
assertEquals(40000.0, path.getDistance(), 0.0);
// We can specifically route to the desired in-edge at node 3
// which does not lie upstream of the turn-restriction.
}
use of com.graphhopper.routing.weighting.TurnCostProvider in project graphhopper by graphhopper.
the class AlternativeRouteEdgeCHTest method prepareCH.
private RoutingCHGraph prepareCH(GraphHopperStorage graph) {
TurnCostProvider turnCostProvider = new DefaultTurnCostProvider(carFE, graph.getTurnCostStorage());
CHConfig chConfig = CHConfig.edgeBased("profile", new FastestWeighting(carFE, turnCostProvider));
PrepareContractionHierarchies contractionHierarchies = PrepareContractionHierarchies.fromGraphHopperStorage(graph, chConfig);
PrepareContractionHierarchies.Result res = contractionHierarchies.doWork();
return graph.createCHGraph(res.getCHStorage(), res.getCHConfig());
}
Aggregations