Skip to content

Commit

Permalink
Set the default u-turn time to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Aug 15, 2024
1 parent c54a883 commit da748e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 10.0 [not yet released]

- the default u-turn time is now 0, the default u-turn weight is still infinite
- turn restriction support for restrictions with overlapping and/or multiple via-edges/ways, #3030
- constructor of BaseGraph.Builder uses byte instead of integer count.
- KeyValue is now KValue as it holds the value only. Note, the two parameter constructor uses one value for the forward and one for the backward direction (and no longer "key, value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ public double calcTurnWeight(int edgeFrom, int nodeVia, int edgeTo) {

@Override
public long calcTurnMillis(int inEdge, int viaNode, int outEdge) {
return (long) (1000 * calcTurnWeight(inEdge, viaNode, outEdge));
// Making a proper assumption about the turn time is very hard. Assuming zero is the
// simplest way to deal with this. This also means the u-turn time is zero. Provided that
// the u-turn weight is large enough, u-turns only occur in special situations like curbsides
// pointing to the end of dead-end streets where it is unclear if a finite u-turn time would
// be a good choice.
return 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ public void calcWeightAndTime_withTurnCosts() {
EdgeIteratorState edge = graph.edge(1, 2).set(avSpeedEnc, 60, 60).setDistance(100);
setTurnRestriction(graph, 0, 1, 2);
assertTrue(Double.isInfinite(GHUtility.calcWeightWithTurnWeight(weighting, edge, false, 0)));
assertEquals(Long.MAX_VALUE, GHUtility.calcMillisWithTurnMillis(weighting, edge, false, 0));
// the time only reflects the time for the edge, the turn time is 0
assertEquals(6000, GHUtility.calcMillisWithTurnMillis(weighting, edge, false, 0));
}

@Test
Expand All @@ -419,7 +420,7 @@ public void calcWeightAndTime_uTurnCosts() {
Weighting weighting = CustomModelParser.createWeighting(encodingManager, new DefaultTurnCostProvider(turnRestrictionEnc, graph.getTurnCostStorage(), 40), customModel);
EdgeIteratorState edge = graph.edge(0, 1).set(avSpeedEnc, 60, 60).setDistance(100);
assertEquals(6 + 40, GHUtility.calcWeightWithTurnWeight(weighting, edge, false, 0), 1.e-6);
assertEquals((6 + 40) * 1000, GHUtility.calcMillisWithTurnMillis(weighting, edge, false, 0), 1.e-6);
assertEquals(6 * 1000, GHUtility.calcMillisWithTurnMillis(weighting, edge, false, 0), 1.e-6);
}

@Test
Expand Down

0 comments on commit da748e6

Please sign in to comment.