Skip to content

Commit

Permalink
Revert "Revert "Merge branch 'car-ferry-changes' into dev-2.x""
Browse files Browse the repository at this point in the history
This reverts commit d14e6af.
  • Loading branch information
vesameskanen committed Oct 23, 2024
1 parent d14e6af commit 7742400
Show file tree
Hide file tree
Showing 33 changed files with 1,371 additions and 318 deletions.
4 changes: 2 additions & 2 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-16T19:58/assets/index-4w7I5Ind.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-16T19:58/assets/index-BcsxnGE8.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T07:45/assets/index-CZI6LO02.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T07:45/assets/index-BqgnKsMX.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ public enum GraphQLPlanAccessMode {
BICYCLE,
BICYCLE_PARKING,
BICYCLE_RENTAL,
CAR,
CAR_DROP_OFF,
CAR_PARKING,
CAR_RENTAL,
Expand Down Expand Up @@ -1575,6 +1576,7 @@ public enum GraphQLPlanDirectMode {
public enum GraphQLPlanEgressMode {
BICYCLE,
BICYCLE_RENTAL,
CAR,
CAR_PICKUP,
CAR_RENTAL,
FLEX,
Expand Down Expand Up @@ -1877,6 +1879,7 @@ public void setGraphQLWalk(GraphQLWalkPreferencesInput walk) {

public enum GraphQLPlanTransferMode {
BICYCLE,
CAR,
WALK,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static StreetMode map(GraphQLTypes.GraphQLPlanAccessMode mode) {
case BICYCLE -> StreetMode.BIKE;
case BICYCLE_RENTAL -> StreetMode.BIKE_RENTAL;
case BICYCLE_PARKING -> StreetMode.BIKE_TO_PARK;
case CAR -> StreetMode.CAR;
case CAR_RENTAL -> StreetMode.CAR_RENTAL;
case CAR_PARKING -> StreetMode.CAR_TO_PARK;
case CAR_DROP_OFF -> StreetMode.CAR_PICKUP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static StreetMode map(GraphQLTypes.GraphQLPlanEgressMode mode) {
return switch (mode) {
case BICYCLE -> StreetMode.BIKE;
case BICYCLE_RENTAL -> StreetMode.BIKE_RENTAL;
case CAR -> StreetMode.CAR;
case CAR_RENTAL -> StreetMode.CAR_RENTAL;
case CAR_PICKUP -> StreetMode.CAR_PICKUP;
case FLEX -> StreetMode.FLEXIBLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,10 @@ private static void validateStreetModes(JourneyRequest journey) {
"If BICYCLE is used for access, egress or transfer, then it should be used for all."
);
}
if (modes.contains(StreetMode.CAR) && modes.size() != 1) {
throw new IllegalArgumentException(
"If CAR is used for access, egress or transfer, then it should be used for all."
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class TransferModeMapper {

public static StreetMode map(GraphQLTypes.GraphQLPlanTransferMode mode) {
return switch (mode) {
case CAR -> StreetMode.CAR;
case BICYCLE -> StreetMode.BIKE;
case WALK -> StreetMode.WALK;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class RequestModesMapper {

private static final Predicate<StreetMode> IS_BIKE = m -> m == StreetMode.BIKE;
private static final Predicate<StreetMode> IS_BIKE_OR_CAR = m ->
m == StreetMode.BIKE || m == StreetMode.CAR;
private static final String accessModeKey = "accessMode";
private static final String egressModeKey = "egressMode";
private static final String directModeKey = "directMode";
Expand All @@ -27,7 +28,10 @@ static RequestModes mapRequestModes(Map<String, ?> modesInput) {
ensureValueAndSet(accessMode, mBuilder::withAccessMode);
ensureValueAndSet((StreetMode) modesInput.get(egressModeKey), mBuilder::withEgressMode);
ensureValueAndSet((StreetMode) modesInput.get(directModeKey), mBuilder::withDirectMode);
Optional.ofNullable(accessMode).filter(IS_BIKE).ifPresent(mBuilder::withTransferMode);
// The only cases in which the transferMode isn't WALK are when the accessMode is either BIKE or CAR.
// In these cases, the transferMode is the same as the accessMode. This check is not strictly necessary
// if there is a need for more freedom for specifying the transferMode.
Optional.ofNullable(accessMode).filter(IS_BIKE_OR_CAR).ifPresent(mBuilder::withTransferMode);

return mBuilder.build();
}
Expand Down
Loading

0 comments on commit 7742400

Please sign in to comment.