From 64420c7937ee50b95ee7151cbd75f64124017d53 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Mon, 8 Jul 2024 13:09:57 +0200 Subject: [PATCH] Add costs for car u-turn --- ...SimpleIntersectionTraversalCalculator.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/org/opentripplanner/street/search/intersection_model/SimpleIntersectionTraversalCalculator.java b/src/main/java/org/opentripplanner/street/search/intersection_model/SimpleIntersectionTraversalCalculator.java index 3c04c9383f7..acc8402e2bc 100644 --- a/src/main/java/org/opentripplanner/street/search/intersection_model/SimpleIntersectionTraversalCalculator.java +++ b/src/main/java/org/opentripplanner/street/search/intersection_model/SimpleIntersectionTraversalCalculator.java @@ -56,6 +56,12 @@ public int getMaxLeftTurnAngle() { return 315; } + public int getMinUTurnAngle() { return 170; } + + public int getMaxUTurnAngle() { + return 190; + } + /** * Expected time it takes to make a right at a light. */ @@ -77,6 +83,13 @@ public double getExpectedLeftAtLightTimeSec() { return 15.0; } + /** + * Expected time it perform a U-turn at a light. + */ + public double getExpectedUTurnAtLightTimeSec() { + return 15.0; + } + /** * Expected time it takes to make a right without a stop light. */ @@ -84,6 +97,13 @@ public double getExpectedRightNoLightTimeSec() { return 8.0; } + /** + * Expected time it takes to make a u-turn without a stop light. + */ + public double getExpectedUTurnNoLightTimeSec() { + return 20.0; + } + /** * Expected time it takes to continue straight without a stop light. This used to be higher, but * it caused unrealistically slow car travel. @@ -159,6 +179,8 @@ private double computeDrivingTraversalDuration( return getExpectedRightAtLightTimeSec(); } else if (isTurnAcrossTraffic(turnAngle)) { return getExpectedLeftAtLightTimeSec(); + } else if (isUTurn(turnAngle)) { + return getExpectedUTurnAtLightTimeSec(); } else { return getExpectedStraightAtLightTimeSec(); } @@ -173,6 +195,8 @@ private double computeDrivingTraversalDuration( return getExpectedRightNoLightTimeSec(); } else if (isTurnAcrossTraffic(turnAngle)) { return getExpectedLeftNoLightTimeSec(); + } else if (isUTurn(turnAngle)) { + return getExpectedUTurnNoLightTimeSec(); } else { return getExpectedStraightNoLightTimeSec(); } @@ -218,4 +242,8 @@ private boolean isLeftTurn(int turnAngle) { private boolean isRightTurn(int turnAngle) { return turnAngle >= getMinRightTurnAngle() && turnAngle < getMaxRightTurnAngle(); } + + private boolean isUTurn(int turnAngle) { + return turnAngle >= getMinUTurnAngle() && turnAngle < getMaxUTurnAngle(); + } }