use of com.graphhopper.routing.VirtualEdgeIteratorState in project graphhopper by graphhopper.
the class FastestWeightingTest method testWeightWrongHeading.
@Test
public void testWeightWrongHeading() {
Weighting instance = new FastestWeighting(encoder, new PMap().put(Parameters.Routing.HEADING_PENALTY, "100"));
VirtualEdgeIteratorState virtEdge = new VirtualEdgeIteratorState(0, 1, 1, 2, 10, encoder.setProperties(10, true, true), "test", Helper.createPointList(51, 0, 51, 1));
double time = instance.calcWeight(virtEdge, false, 0);
virtEdge.setUnfavored(true);
// heading penalty on edge
assertEquals(time + 100, instance.calcWeight(virtEdge, false, 0), 1e-8);
// only after setting it
virtEdge.setUnfavored(true);
assertEquals(time + 100, instance.calcWeight(virtEdge, true, 0), 1e-8);
// but not after releasing it
virtEdge.setUnfavored(false);
assertEquals(time, instance.calcWeight(virtEdge, true, 0), 1e-8);
// test default penalty
virtEdge.setUnfavored(true);
instance = new FastestWeighting(encoder);
assertEquals(time + Routing.DEFAULT_HEADING_PENALTY, instance.calcWeight(virtEdge, false, 0), 1e-8);
}
Aggregations