Skip to content

Commit

Permalink
Allow bike walking through bicycle no thru traffic areas
Browse files Browse the repository at this point in the history
  • Loading branch information
flaktack authored and richardkoszegi committed Oct 18, 2024
1 parent f9ea044 commit 561be76
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ else if (s0.currentMode() == TraverseMode.BICYCLE) {

State state = editor != null ? editor.makeState() : null;

// Add an explicit bike-walking state for no-thru-traffic edges, so that dismounting and walking
// is an option to avoid the restriction
if (
s0.getBackMode() == TraverseMode.BICYCLE &&
canTraverse(TraverseMode.BICYCLE) &&
isBicycleNoThruTraffic() &&
!s0.hasEnteredNoThruTrafficArea()
) {
var bikeWalk = doTraverse(s0, TraverseMode.WALK, true);
if (bikeWalk != null) {
State forkState = bikeWalk.makeState();
return State.ofNullable(forkState, state);
}
}

// we are transitioning into a no-drop-off zone therefore we add a second state for dropping
// off the vehicle and walking
if (state != null && !fromv.rentalDropOffBanned(s0) && tov.rentalDropOffBanned(s0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,75 @@ public void testElevatorBiking() {
);
}

@Test
public void testBicycleBicycleNoThruTrafficStart() {
CD.setBicycleNoThruTraffic(true);

assertPath(
C,
F,
StreetMode.BIKE,
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 5 / 10.0 - CD street",
"BICYCLE - 5 / 10.0 - DE street",
"BICYCLE - 5 / 10.0 - EF street"
),
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 5 / 10.0 - CD street",
"BICYCLE - 5 / 10.0 - DE street",
"BICYCLE - 5 / 10.0 - EF street"
)
);
}

@Test
public void testBicycleBicycleNoThruTrafficMiddle() {
DE.setBicycleNoThruTraffic(true);

assertPath(
C,
F,
StreetMode.BIKE,
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 5 / 10.0 - CD street",
"🚲WALK - 120 / 1100.0 - DE street",
"BICYCLE - 105 / 1010.0 - EF street"
),
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 105 / 1010.0 - CD street",
"🚲WALK - 120 / 1100.0 - DE street",
"BICYCLE - 5 / 10.0 - EF street"
)
);
}

@Test
public void testBicycleBicycleNoThruTrafficEnd() {
EF.setBicycleNoThruTraffic(true);

assertPath(
C,
F,
StreetMode.BIKE,
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 5 / 10.0 - CD street",
"BICYCLE - 5 / 10.0 - DE street",
"BICYCLE - 5 / 10.0 - EF street"
),
List.of(
"null - 0 / 0.0 - null",
"BICYCLE - 5 / 10.0 - CD street",
"BICYCLE - 5 / 10.0 - DE street",
"BICYCLE - 5 / 10.0 - EF street"
)
);
}

@BeforeEach
protected void setUp() throws Exception {
// Generate a very simple graph
Expand Down

0 comments on commit 561be76

Please sign in to comment.