|
1 | 1 | package org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers; |
2 | 2 |
|
| 3 | +import static java.util.function.Predicate.not; |
| 4 | +import static java.util.stream.Collectors.collectingAndThen; |
| 5 | +import static java.util.stream.Collectors.toList; |
3 | 6 | import static org.opentripplanner.raptor.api.request.Optimization.PARALLEL; |
4 | 7 |
|
5 | 8 | import io.micrometer.core.instrument.MeterRegistry; |
6 | 9 | import java.time.Duration; |
7 | 10 | import java.time.Instant; |
8 | 11 | import java.time.ZonedDateTime; |
9 | 12 | import java.util.Collection; |
| 13 | +import java.util.List; |
| 14 | +import java.util.Optional; |
10 | 15 | import org.opentripplanner.framework.application.OTPFeature; |
11 | 16 | import org.opentripplanner.raptor.api.model.RaptorAccessEgress; |
12 | 17 | import org.opentripplanner.raptor.api.model.RaptorConstants; |
13 | 18 | import org.opentripplanner.raptor.api.request.Optimization; |
| 19 | +import org.opentripplanner.raptor.api.request.PassThroughPoint; |
| 20 | +import org.opentripplanner.raptor.api.request.PassThroughPoints; |
14 | 21 | import org.opentripplanner.raptor.api.request.RaptorRequest; |
15 | 22 | import org.opentripplanner.raptor.api.request.RaptorRequestBuilder; |
16 | 23 | import org.opentripplanner.raptor.rangeraptor.SystemErrDebugLogger; |
17 | 24 | import org.opentripplanner.routing.algorithm.raptoradapter.router.performance.PerformanceTimersForRaptor; |
18 | 25 | import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule; |
19 | 26 | import org.opentripplanner.routing.api.request.RouteRequest; |
| 27 | +import org.opentripplanner.transit.model.site.StopLocation; |
20 | 28 |
|
21 | 29 | public class RaptorRequestMapper { |
22 | 30 |
|
@@ -105,12 +113,29 @@ private RaptorRequest<TripSchedule> doMap() { |
105 | 113 | if (preferences.transfer().maxAdditionalTransfers() != null) { |
106 | 114 | searchParams.numberOfAdditionalTransfers(preferences.transfer().maxAdditionalTransfers()); |
107 | 115 | } |
| 116 | + |
| 117 | + final Optional<PassThroughPoints> passThroughPoints = request |
| 118 | + .getPassThroughPoints() |
| 119 | + .stream() |
| 120 | + .map(p -> { |
| 121 | + final int[] stops = p |
| 122 | + .getStopLocations() |
| 123 | + .stream() |
| 124 | + .mapToInt(StopLocation::getIndex) |
| 125 | + .toArray(); |
| 126 | + return new PassThroughPoint(stops, p.getName()); |
| 127 | + }) |
| 128 | + .collect(collectingAndThen(toList(), Optional::ofNullable)) |
| 129 | + .filter(not(List::isEmpty)) |
| 130 | + .map(PassThroughPoints::new); |
| 131 | + |
108 | 132 | builder.withMultiCriteria(mcBuilder -> { |
109 | 133 | preferences |
110 | 134 | .transit() |
111 | 135 | .raptor() |
112 | 136 | .relaxGeneralizedCostAtDestination() |
113 | 137 | .ifPresent(mcBuilder::withRelaxCostAtDestination); |
| 138 | + passThroughPoints.ifPresent(pt -> mcBuilder.withPassThroughPoints(pt)); |
114 | 139 | }); |
115 | 140 |
|
116 | 141 | for (Optimization optimization : preferences.transit().raptor().optimizations()) { |
|
0 commit comments