From 5567b4cc908cfee3f7a06fbd3339f2b0a6b2f353 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 25 Jul 2024 12:03:37 +0200 Subject: [PATCH] Add costs for car u-turn --- ...SimpleIntersectionTraversalCalculator.java | 30 +++++++++++++++++++ 1 file changed, 30 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..f76f8abe053 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,14 @@ 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 +85,13 @@ public double getExpectedLeftAtLightTimeSec() { return 15.0; } + /** + * Expected time it perform a U-turn at a light. + */ + public double getExpectedUTurnAtLightTimeSec() { + return 20.0; + } + /** * Expected time it takes to make a right without a stop light. */ @@ -84,6 +99,13 @@ public double getExpectedRightNoLightTimeSec() { return 8.0; } + /** + * Expected time it takes to make a u-turn without a stop light. + */ + public double getExpectedUTurnNoLightTimeSec() { + return 40.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 +181,8 @@ private double computeDrivingTraversalDuration( return getExpectedRightAtLightTimeSec(); } else if (isTurnAcrossTraffic(turnAngle)) { return getExpectedLeftAtLightTimeSec(); + } else if (isUTurn(turnAngle)) { + return getExpectedUTurnAtLightTimeSec(); } else { return getExpectedStraightAtLightTimeSec(); } @@ -173,6 +197,8 @@ private double computeDrivingTraversalDuration( return getExpectedRightNoLightTimeSec(); } else if (isTurnAcrossTraffic(turnAngle)) { return getExpectedLeftNoLightTimeSec(); + } else if (isUTurn(turnAngle)) { + return getExpectedUTurnNoLightTimeSec(); } else { return getExpectedStraightNoLightTimeSec(); } @@ -218,4 +244,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(); + } }