Search in sources :

Example 1 with RaptorTransfer

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());
}
Also used : EgressPathLeg(org.opentripplanner.transit.raptor.api.path.EgressPathLeg) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer)

Example 2 with RaptorTransfer

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();
}
Also used : RaptorRequest(org.opentripplanner.transit.raptor.api.request.RaptorRequest) TripSchedule(org.opentripplanner.routing.algorithm.raptor.transit.TripSchedule) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer) RaptorProfile(org.opentripplanner.transit.raptor.api.request.RaptorProfile) RaptorRequestBuilder(org.opentripplanner.transit.raptor.api.request.RaptorRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) Collection(java.util.Collection) SlackProvider(org.opentripplanner.routing.algorithm.raptor.transit.SlackProvider) Optimization(org.opentripplanner.transit.raptor.api.request.Optimization) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Collectors(java.util.stream.Collectors) SlackProvider(org.opentripplanner.routing.algorithm.raptor.transit.SlackProvider) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer) TripSchedule(org.opentripplanner.routing.algorithm.raptor.transit.TripSchedule) RaptorRequestBuilder(org.opentripplanner.transit.raptor.api.request.RaptorRequestBuilder)

Example 3 with RaptorTransfer

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);
}
Also used : EgressPathLeg(org.opentripplanner.transit.raptor.api.path.EgressPathLeg) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer)

Example 4 with RaptorTransfer

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;
}
Also used : RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer)

Example 5 with RaptorTransfer

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));
}
Also used : AccessPathLeg(org.opentripplanner.transit.raptor.api.path.AccessPathLeg) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer)

Aggregations

RaptorTransfer (org.opentripplanner.transit.raptor.api.transit.RaptorTransfer)7 AccessPathLeg (org.opentripplanner.transit.raptor.api.path.AccessPathLeg)2 EgressPathLeg (org.opentripplanner.transit.raptor.api.path.EgressPathLeg)2 ZonedDateTime (java.time.ZonedDateTime)1 Collection (java.util.Collection)1 Collectors (java.util.stream.Collectors)1 SlackProvider (org.opentripplanner.routing.algorithm.raptor.transit.SlackProvider)1 TripSchedule (org.opentripplanner.routing.algorithm.raptor.transit.TripSchedule)1 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)1 Optimization (org.opentripplanner.transit.raptor.api.request.Optimization)1 RaptorProfile (org.opentripplanner.transit.raptor.api.request.RaptorProfile)1 RaptorRequest (org.opentripplanner.transit.raptor.api.request.RaptorRequest)1 RaptorRequestBuilder (org.opentripplanner.transit.raptor.api.request.RaptorRequestBuilder)1