Skip to content

Commit 096e43c

Browse files
Add Transmodel carpool streetMode (opentripplanner#7084)
* Adds a car_pool streetMode that can be used for directMode in the Transmodel API. * Changes the new streetmode car_pool to carpool so that it matches the transitmode. * Adds more extensive descriptions to the transit and street modes for carpooling. * Clarifies enum descriptions for carpooling. Co-authored-by: leonardehrenfried <mail@leonard.io> --------- Co-authored-by: leonardehrenfried <mail@leonard.io>
1 parent 2f86866 commit 096e43c

20 files changed

Lines changed: 91 additions & 16 deletions

File tree

application/src/ext/java/org/opentripplanner/ext/carpooling/internal/DefaultCarpoolingRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public Collection<CarpoolTrip> getCarpoolTrips() {
2424
public void upsertCarpoolTrip(CarpoolTrip trip) {
2525
CarpoolTrip existingTrip = trips.put(trip.getId(), trip);
2626
if (existingTrip != null) {
27-
LOG.info("Updated carpool trip {} with {} stops", trip.getId(), trip.stops().size());
27+
LOG.debug("Updated carpool trip {} with {} stops", trip.getId(), trip.stops().size());
2828
} else {
29-
LOG.info("Added new carpool trip {} with {} stops", trip.getId(), trip.stops().size());
29+
LOG.debug("Added new carpool trip {} with {} stops", trip.getId(), trip.stops().size());
3030
}
3131
}
3232
}

application/src/ext/java/org/opentripplanner/ext/carpooling/service/DefaultCarpoolingService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.opentripplanner.ext.carpooling.service;
22

33
import java.time.Duration;
4+
import java.util.Collections;
45
import java.util.Comparator;
56
import java.util.List;
67
import java.util.Objects;
@@ -18,6 +19,7 @@
1819
import org.opentripplanner.framework.geometry.WgsCoordinate;
1920
import org.opentripplanner.model.plan.Itinerary;
2021
import org.opentripplanner.routing.api.request.RouteRequest;
22+
import org.opentripplanner.routing.api.request.StreetMode;
2123
import org.opentripplanner.routing.api.response.InputField;
2224
import org.opentripplanner.routing.api.response.RoutingError;
2325
import org.opentripplanner.routing.api.response.RoutingErrorCode;
@@ -113,6 +115,10 @@ public DefaultCarpoolingService(
113115
@Override
114116
public List<Itinerary> route(RouteRequest request, LinkingContext linkingContext)
115117
throws RoutingValidationException {
118+
if (!StreetMode.CARPOOL.equals(request.journey().direct().mode())) {
119+
return Collections.emptyList();
120+
}
121+
116122
validateRequest(request);
117123

118124
WgsCoordinate passengerPickup = new WgsCoordinate(request.from().getCoordinate());

application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/AccessModeMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static GraphQLTypes.GraphQLPlanAccessMode map(StreetMode mode) {
3434
case CAR_PICKUP -> GraphQLTypes.GraphQLPlanAccessMode.CAR_DROP_OFF;
3535
case FLEXIBLE -> GraphQLTypes.GraphQLPlanAccessMode.FLEX;
3636
case SCOOTER_RENTAL -> GraphQLTypes.GraphQLPlanAccessMode.SCOOTER_RENTAL;
37-
case WALK, CAR_HAILING, NOT_SET -> GraphQLTypes.GraphQLPlanAccessMode.WALK;
37+
case WALK, CAR_HAILING, CARPOOL, NOT_SET -> GraphQLTypes.GraphQLPlanAccessMode.WALK;
3838
};
3939
}
4040
}

application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/DirectModeMapper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public static GraphQLTypes.GraphQLPlanDirectMode map(StreetMode mode) {
3232
case CAR_TO_PARK -> GraphQLTypes.GraphQLPlanDirectMode.CAR_PARKING;
3333
case FLEXIBLE -> GraphQLTypes.GraphQLPlanDirectMode.FLEX;
3434
case SCOOTER_RENTAL -> GraphQLTypes.GraphQLPlanDirectMode.SCOOTER_RENTAL;
35-
case WALK, CAR_HAILING, CAR_PICKUP, NOT_SET -> GraphQLTypes.GraphQLPlanDirectMode.WALK;
35+
case WALK,
36+
CAR_HAILING,
37+
CAR_PICKUP,
38+
CARPOOL,
39+
NOT_SET -> GraphQLTypes.GraphQLPlanDirectMode.WALK;
3640
};
3741
}
3842
}

application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/EgressModeMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static GraphQLTypes.GraphQLPlanEgressMode map(StreetMode mode) {
3232
case SCOOTER_RENTAL -> GraphQLTypes.GraphQLPlanEgressMode.SCOOTER_RENTAL;
3333
case WALK,
3434
CAR_HAILING,
35+
CARPOOL,
3536
CAR_TO_PARK,
3637
BIKE_TO_PARK,
3738
NOT_SET -> GraphQLTypes.GraphQLPlanEgressMode.WALK;

application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/StreetModeMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ private static boolean isAlwaysPresentInLeg(StreetMode mode) {
103103
mode == StreetMode.BIKE ||
104104
mode == StreetMode.CAR ||
105105
mode == StreetMode.WALK ||
106+
mode == StreetMode.CARPOOL ||
106107
mode.includesParking()
107108
);
108109
}

application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/TransferModeMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static GraphQLTypes.GraphQLPlanTransferMode map(StreetMode mode) {
2525
CAR_HAILING,
2626
CAR_RENTAL,
2727
CAR_PICKUP,
28+
CARPOOL,
2829
CAR_TO_PARK,
2930
BIKE_TO_PARK,
3031
FLEXIBLE,

application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ public class EnumTypes {
421421
"the road, drive to a drop-off point along the road, and walk the rest of the way. " +
422422
"This can include car rentals at fixed locations or free-floating services."
423423
)
424+
.value(
425+
"carpool",
426+
StreetMode.CARPOOL,
427+
"Share a car ride with a driver and other passengers going in the same direction."
428+
)
424429
.value(
425430
"flexible",
426431
StreetMode.FLEXIBLE,

application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StreetModeToFormFactorMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static RentalFormFactor map(StreetMode streetMode) {
2222
CAR_TO_PARK,
2323
CAR_PICKUP,
2424
CAR_HAILING,
25+
CARPOOL,
2526
FLEXIBLE -> throw new IllegalStateException(
2627
"Cannot convert street mode %s to a form factor".formatted(streetMode)
2728
);

application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StreetModeToRentalTraverseModeMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static TraverseMode map(StreetMode mode) {
2121
CAR_TO_PARK,
2222
CAR_PICKUP,
2323
CAR_HAILING,
24+
CARPOOL,
2425
FLEXIBLE -> throw new IllegalArgumentException("%s is not a rental mode.".formatted(mode));
2526
};
2627
}

0 commit comments

Comments
 (0)