@@ -248,11 +248,11 @@ public void directedRouting() {
248
248
int leftNorth = graph .edge (9 , 0 , 1 , true ).getEdge ();
249
249
250
250
// make paths fully deterministic by applying some turn costs at junction node 2
251
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 7 , 2 ). getEdge (), 2 , GHUtility . getEdge ( graph , 2 , 3 ). getEdge () , 1 );
252
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 7 , 2 ). getEdge (), 2 , GHUtility . getEdge ( graph , 2 , 6 ). getEdge () , 3 );
253
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 1 , 2 ). getEdge (), 2 , GHUtility . getEdge ( graph , 2 , 3 ). getEdge () , 5 );
254
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 1 , 2 ). getEdge (), 2 , GHUtility . getEdge ( graph , 2 , 6 ). getEdge () , 7 );
255
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 1 , 2 ). getEdge (), 2 , GHUtility . getEdge ( graph , 2 , 7 ). getEdge () , 9 );
251
+ setTurnCost ( 7 , 2 , 3 , 1 );
252
+ setTurnCost ( 7 , 2 , 6 , 3 );
253
+ setTurnCost ( 1 , 2 , 3 , 5 );
254
+ setTurnCost ( 1 , 2 , 6 , 7 );
255
+ setTurnCost ( 1 , 2 , 7 , 9 );
256
256
257
257
final double unitEdgeWeight = 0.06 ;
258
258
assertPath (calcPath (9 , 9 , leftNorth , leftSouth ),
@@ -322,8 +322,8 @@ public void worksWithTurnCosts() {
322
322
graph .edge (4 , 5 , 1 , true );
323
323
graph .edge (5 , 2 , 1 , true );
324
324
325
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 0 , 3 ). getEdge (), 3 , GHUtility . getEdge ( graph , 3 , 4 ). getEdge (), Double . POSITIVE_INFINITY );
326
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 4 , 5 ). getEdge (), 5 , GHUtility . getEdge ( graph , 5 , 2 ). getEdge () , 6 );
325
+ setRestriction ( 0 , 3 , 4 );
326
+ setTurnCost ( 4 , 5 , 2 , 6 );
327
327
328
328
// due to the restrictions we have to take the expensive path with turn costs
329
329
assertPath (calcPath (0 , 2 , 0 , 6 ), 6.24 , 4 , 6240 , nodes (0 , 1 , 4 , 5 , 2 ));
@@ -356,8 +356,8 @@ public void finiteUTurnCosts() {
356
356
int right6 = graph .edge (9 , 6 , 10 , true ).getEdge ();
357
357
358
358
// enforce p-turn (using the loop in clockwise direction)
359
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 0 , 1 ). getEdge (), 1 , GHUtility . getEdge ( graph , 1 , 6 ). getEdge (), Double . POSITIVE_INFINITY );
360
- turnCostStorage . set ( turnCostEnc , GHUtility . getEdge ( graph , 5 , 4 ). getEdge (), 4 , GHUtility . getEdge ( graph , 4 , 3 ). getEdge (), Double . POSITIVE_INFINITY );
359
+ setRestriction ( 0 , 1 , 6 );
360
+ setRestriction ( 5 , 4 , 3 );
361
361
362
362
assertPath (calcPath (0 , 6 , right0 , left6 ), 64.2 , 1070 , 64200 , nodes (0 , 1 , 2 , 3 , 4 , 5 , 2 , 1 , 6 ));
363
363
// if the u-turn cost is finite it depends on its value if we rather do the p-turn or do an immediate u-turn at node 2
@@ -535,4 +535,12 @@ private void assertNotFound(Path path) {
535
535
assertEquals (0 , path .getTime ());
536
536
assertEquals (nodes (), path .calcNodes ());
537
537
}
538
+
539
+ private void setRestriction (int fromNode , int node , int toNode ) {
540
+ setTurnCost (fromNode , node , toNode , Double .POSITIVE_INFINITY );
541
+ }
542
+
543
+ private void setTurnCost (int fromNode , int node , int toNode , double turnCost ) {
544
+ turnCostStorage .set (turnCostEnc , GHUtility .getEdge (graph , fromNode , node ).getEdge (), node , GHUtility .getEdge (graph , node , toNode ).getEdge (), turnCost );
545
+ }
538
546
}
0 commit comments