use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeBasedNodeContractorTest method testShortcutMergeBug.
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void testShortcutMergeBug(boolean reverse) {
// We refer to this real world situation http://www.openstreetmap.org/#map=19/52.71205/-1.77326
// assume the following graph:
//
// ---1---->----2-----3
// \--------/
//
// where there are two roads from 1 to 2 and the directed road has a smaller weight. to get from 2 to 1 we
// have to use the bidirectional edge despite the higher weight and therefore we need an extra shortcut for
// this.
final EdgeIteratorState edge1to2bidirected = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(2));
final EdgeIteratorState edge1to2directed = GHUtility.setSpeed(60, true, false, encoder, graph.edge(1, 2).setDistance(1));
final EdgeIteratorState edge2to3 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(2, 3).setDistance(1));
freeze();
setMaxLevelOnAllNodes();
if (reverse) {
contractInOrder(2, 1, 3);
checkShortcuts(expectedShortcut(1, 3, edge1to2directed, edge2to3, true, false), expectedShortcut(1, 3, edge1to2bidirected, edge2to3, false, true));
} else {
contractInOrder(2, 3, 1);
checkShortcuts(expectedShortcut(3, 1, edge2to3, edge1to2bidirected, true, false), expectedShortcut(3, 1, edge2to3, edge1to2directed, false, true));
}
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeBasedNodeContractorTest method testContractNode_bidirected_shortcutsRequired.
@Test
public void testContractNode_bidirected_shortcutsRequired() {
// 0 -- 1 -- 2
final EdgeIteratorState edge1 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(0, 1).setDistance(1));
final EdgeIteratorState edge2 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(2));
freeze();
contractInOrder(1, 2, 0);
checkShortcuts(expectedShortcut(2, 0, edge2, edge1, true, true));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeBasedNodeContractorTest method testFindShortcuts_Roundabout.
@Test
public void testFindShortcuts_Roundabout() {
// 1 -- 3 -- 4 ---> 5 ---> 6 -- 7
// \ /
// <--- 8 <---
final EdgeIteratorState iter1to3 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 3).setDistance(1));
final EdgeIteratorState iter3to4 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(3, 4).setDistance(1));
final EdgeIteratorState iter4to5 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(4, 5).setDistance(1));
final EdgeIteratorState iter5to6 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(5, 6).setDistance(1));
final EdgeIteratorState iter6to8 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(6, 8).setDistance(2));
final EdgeIteratorState iter8to4 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(8, 4).setDistance(1));
GHUtility.setSpeed(60, true, true, encoder, graph.edge(6, 7).setDistance(1));
freeze();
contractInOrder(3, 5, 7, 8, 4, 1, 6);
// note: after contraction of nodes 3, 5, 8 the graph looks like this:
// 1 -- 4 -->-- 6 -- 7
// \ |
// --<----
RoutingCHGraph lg = graph.createCHGraph(store, chConfig);
checkShortcuts(expectedShortcut(4, 1, iter3to4, iter1to3, true, true), expectedShortcut(4, 6, iter8to4, iter6to8, false, true), expectedShortcut(4, 6, iter4to5, iter5to6, true, false), // there should be two different shortcuts for both directions!
expectedShortcut(1, 6, lg.getEdgeIteratorState(8, 4), lg.getEdgeIteratorState(7, 6), true, false), expectedShortcut(1, 6, lg.getEdgeIteratorState(8, 1), lg.getEdgeIteratorState(9, 4), false, true));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeBasedNodeContractorTest method testContractNode_directed_shortcutRequired_reverse.
@Test
public void testContractNode_directed_shortcutRequired_reverse() {
// 0 <-- 1 <-- 2
final EdgeIteratorState edge1 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(2, 1).setDistance(1));
final EdgeIteratorState edge2 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(1, 0).setDistance(2));
freeze();
setMaxLevelOnAllNodes();
contractInOrder(1, 2, 0);
checkShortcuts(expectedShortcut(2, 0, edge1, edge2, true, false));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeBasedNodeContractorTest method testContractNode_directed_shortcutRequired.
@Test
public void testContractNode_directed_shortcutRequired() {
// 0 --> 1 --> 2
final EdgeIteratorState edge1 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(0, 1).setDistance(1));
final EdgeIteratorState edge2 = GHUtility.setSpeed(60, true, false, encoder, graph.edge(1, 2).setDistance(2));
freeze();
setMaxLevelOnAllNodes();
contractInOrder(1, 0, 2);
checkShortcuts(expectedShortcut(0, 2, edge1, edge2, true, false));
}
Aggregations