use of com.graphhopper.storage.TurnCostExtension in project graphhopper by graphhopper.
the class EdgeBasedRoutingAlgorithmTest method testTurnCostsBug_991.
@Test
public void testTurnCostsBug_991() {
final GraphHopperStorage g = createStorage(createEncodingManager(false));
initGraph(g);
TurnCostExtension tcs = (TurnCostExtension) g.getExtension();
long tflags = carEncoder.getTurnFlags(false, 2);
tcs.addTurnInfo(getEdge(g, 5, 2).getEdge(), 2, getEdge(g, 2, 3).getEdge(), tflags);
tcs.addTurnInfo(getEdge(g, 2, 0).getEdge(), 0, getEdge(g, 0, 1).getEdge(), tflags);
tcs.addTurnInfo(getEdge(g, 5, 6).getEdge(), 6, getEdge(g, 6, 3).getEdge(), tflags);
tflags = carEncoder.getTurnFlags(false, 1);
tcs.addTurnInfo(getEdge(g, 6, 7).getEdge(), 7, getEdge(g, 7, 4).getEdge(), tflags);
Path p = createAlgo(g, AlgorithmOptions.start().weighting(new TurnWeighting(new FastestWeighting(carEncoder), tcs) {
@Override
public double calcTurnWeight(int edgeFrom, int nodeVia, int edgeTo) {
if (edgeFrom >= 0)
assertNotNull("edge " + edgeFrom + " to " + nodeVia + " does not exist", g.getEdgeIteratorState(edgeFrom, nodeVia));
if (edgeTo >= 0)
assertNotNull("edge " + edgeTo + " to " + nodeVia + " does not exist", g.getEdgeIteratorState(edgeTo, nodeVia));
return super.calcTurnWeight(edgeFrom, nodeVia, edgeTo);
}
}.setDefaultUTurnCost(40)).traversalMode(TraversalMode.EDGE_BASED_2DIR).build()).calcPath(5, 1);
assertEquals(Helper.createTList(5, 6, 7, 4, 3, 1), p.calcNodes());
assertEquals(301, p.getTime(), .1);
}
Aggregations