use of org.opentripplanner.transit.raptor.api.transit.RaptorTransfer in project OpenTripPlanner by opentripplanner.
the class ForwardPathMapper method createEgressPathLeg.
private EgressPathLeg<T> createEgressPathLeg(DestinationArrival<T> destinationArrival) {
RaptorTransfer egress = destinationArrival.egressLeg().egress();
int departureTime = destinationArrival.arrivalTime() - egress.durationInSeconds();
return new EgressPathLeg<>(egress, destinationArrival.previous().stop(), departureTime, destinationArrival.arrivalTime());
}
use of org.opentripplanner.transit.raptor.api.transit.RaptorTransfer in project OpenTripPlanner by opentripplanner.
the class RaptorRequestMapper method mapRequest.
public static RaptorRequest<TripSchedule> mapRequest(RoutingRequest request, ZonedDateTime startOfTime, Collection<? extends RaptorTransfer> accessTimes, Collection<? extends RaptorTransfer> egressTimes) {
RaptorRequestBuilder<TripSchedule> builder = new RaptorRequestBuilder<>();
int time = DateMapper.secondsSinceStartOfTime(startOfTime, request.getDateTime().toInstant());
if (request.arriveBy) {
builder.searchParams().latestArrivalTime(time);
} else {
builder.searchParams().earliestDepartureTime(time);
}
if (request.maxTransfers != null) {
builder.searchParams().maxNumberOfTransfers(request.maxTransfers);
}
builder.profile(RaptorProfile.MULTI_CRITERIA).enableOptimization(Optimization.PARETO_CHECK_AGAINST_DESTINATION).slackProvider(new SlackProvider(request.transferSlack, request.boardSlack, request.boardSlackForMode, request.alightSlack, request.alightSlackForMode));
builder.searchParams().searchWindow(request.searchWindow).addAccessStops(accessTimes.stream().map(t -> (RaptorTransfer) t).collect(Collectors.toList())).addEgressStops(egressTimes.stream().map(t -> (RaptorTransfer) t).collect(Collectors.toList())).boardSlackInSeconds(request.boardSlack).timetableEnabled(true);
builder.mcCostFactors().waitReluctanceFactor(request.waitReluctance).walkReluctanceFactor(request.walkReluctance);
return builder.build();
}
use of org.opentripplanner.transit.raptor.api.transit.RaptorTransfer in project OpenTripPlanner by opentripplanner.
the class ReversePathMapper method mapToEgressLeg.
private EgressPathLeg<T> mapToEgressLeg(ArrivalView<T> accessArrival) {
RaptorTransfer egress = accessArrival.accessLeg().access();
int targetDepartureTime = accessArrival.arrivalTime();
int targetArrivalTime = accessArrival.arrivalTime() + egress.durationInSeconds();
// No need to time-shift the egress leg, this is done when stopArrival is created
return new EgressPathLeg<>(egress, accessArrival.stop(), targetDepartureTime, targetArrivalTime);
}
use of org.opentripplanner.transit.raptor.api.transit.RaptorTransfer in project OpenTripPlanner by opentripplanner.
the class HeuristicsAdapter method calculateAggregatedResults.
/**
* Lazy calculate some of the result values.
*/
private void calculateAggregatedResults() {
if (aggregatedResultsCalculated) {
return;
}
for (RaptorTransfer it : egressLegs) {
if (reached(it.stop())) {
int t = bestTravelDuration(it.stop()) + it.durationInSeconds();
minJourneyTravelDuration = Math.min(minJourneyTravelDuration, t);
int n = bestNumOfTransfers(it.stop());
minJourneyNumOfTransfers = Math.min(minJourneyNumOfTransfers, n);
}
}
aggregatedResultsCalculated = true;
}
use of org.opentripplanner.transit.raptor.api.transit.RaptorTransfer in project OpenTripPlanner by opentripplanner.
the class ReversePathMapper method mapAccessLeg.
AccessPathLeg<T> mapAccessLeg(DestinationArrival<T> destArrival) {
ArrivalView<T> prevArrival = destArrival.previous();
RaptorTransfer access = destArrival.egressLeg().egress();
int targetDepartureTime = destArrival.arrivalTime();
int targetArrivalTime = destArrival.arrivalTime() + access.durationInSeconds();
return new AccessPathLeg<>(access, prevArrival.stop(), targetDepartureTime, targetArrivalTime, // Recursive
mapToTransit(prevArrival));
}
Aggregations