Skip to content

Commit a529753

Browse files
committed
Makes 1574 test ready for direction-dependent speeds.
1 parent c979cbd commit a529753

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,24 +509,25 @@ public int getNumNodes() {
509509
queryGraph.lookup(Collections.singletonList(qr));
510510

511511
// we make sure our weight fine tunings do what they are supposed to
512-
double weight03 = getWeight(queryGraph, fastestWeighting, 0, 3);
513-
double scWeight23 = weight03 + ((CHEdgeIteratorState) getEdge(lg, 2, 3)).getWeight();
514-
double scWeight34 = weight03 + ((CHEdgeIteratorState) getEdge(lg, 3, 4)).getWeight();
515-
double sptWeight2 = weight03 + getWeight(queryGraph, fastestWeighting, 3, 8) + getWeight(queryGraph, fastestWeighting, 8, 1) + getWeight(queryGraph, fastestWeighting, 1, 2);
516-
double sptWeight4 = sptWeight2 + getWeight(queryGraph, fastestWeighting, 2, 4);
512+
double weight03 = getWeight(queryGraph, fastestWeighting, 0, 3, false);
513+
double scWeight23 = weight03 + ((CHEdgeIteratorState) getEdge(lg, 2, 3, true)).getWeight();
514+
double scWeight34 = weight03 + ((CHEdgeIteratorState) getEdge(lg, 3, 4, false)).getWeight();
515+
double sptWeight2 = weight03 + getWeight(queryGraph, fastestWeighting, 3, 8, false) + getWeight(queryGraph, fastestWeighting, 8, 1, false) + getWeight(queryGraph, fastestWeighting, 1, 2, false);
516+
double sptWeight4 = sptWeight2 + getWeight(queryGraph, fastestWeighting, 2, 4, false);
517517
assertTrue("incoming shortcut weight 3->2 should be smaller than sptWeight at node 2 to make sure 2 gets stalled", scWeight23 < sptWeight2);
518518
assertTrue("sptWeight at node 4 should be smaller than shortcut weight 3->4 to make sure node 4 gets stalled", sptWeight4 < scWeight34);
519519

520520
Path path = pch.createAlgo(queryGraph, AlgorithmOptions.start().build()).calcPath(0, 7);
521521
assertEquals("wrong or no path found", IntArrayList.from(0, 3, 8, 1, 2, 4, 5, 6, 7), path.calcNodes());
522522
}
523523

524-
private double getWeight(Graph graph, Weighting w, int from, int to) {
525-
return w.calcWeight(getEdge(graph, from, to), false, -1);
524+
private double getWeight(Graph graph, Weighting w, int from, int to, boolean incoming) {
525+
return w.calcWeight(getEdge(graph, from, to, false), incoming, -1);
526526
}
527527

528-
private EdgeIteratorState getEdge(Graph graph, int from, int to) {
529-
EdgeIterator iter = graph.createEdgeExplorer().setBaseNode(from);
528+
private EdgeIteratorState getEdge(Graph graph, int from, int to, boolean incoming) {
529+
EdgeFilter filter = incoming ? DefaultEdgeFilter.inEdges(carEncoder) : DefaultEdgeFilter.outEdges(carEncoder);
530+
EdgeIterator iter = graph.createEdgeExplorer(filter).setBaseNode(from);
530531
while (iter.next()) {
531532
if (iter.getAdjNode() == to) {
532533
return iter;

0 commit comments

Comments
 (0)