Search in sources :

Example 36 with Itinerary

use of org.opentripplanner.model.plan.Itinerary in project OpenTripPlanner by opentripplanner.

the class DirectStreetRouter method route.

public static List<Itinerary> route(Router router, RoutingRequest request) {
    request.setRoutingContext(router.graph);
    try {
        if (request.modes.directMode == null) {
            return Collections.emptyList();
        }
        if (!streetDistanceIsReasonable(request)) {
            return Collections.emptyList();
        }
        RoutingRequest nonTransitRequest = request.getStreetSearchRequest(request.modes.directMode);
        // we could also get a persistent router-scoped GraphPathFinder but there's no setup cost here
        GraphPathFinder gpFinder = new GraphPathFinder(router);
        List<GraphPath> paths = gpFinder.graphPathFinderEntryPoint(nonTransitRequest);
        // Convert the internal GraphPaths to itineraries
        List<Itinerary> response = GraphPathToItineraryMapper.mapItineraries(paths, request);
        ItinerariesHelper.decorateItinerariesWithRequestData(response, request);
        return response;
    } catch (PathNotFoundException e) {
        return Collections.emptyList();
    }
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) Itinerary(org.opentripplanner.model.plan.Itinerary) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) PathNotFoundException(org.opentripplanner.routing.error.PathNotFoundException) GraphPathFinder(org.opentripplanner.routing.impl.GraphPathFinder)

Aggregations

Itinerary (org.opentripplanner.model.plan.Itinerary)36 Test (org.junit.Test)18 TestItineraryBuilder.newItinerary (org.opentripplanner.model.plan.TestItineraryBuilder.newItinerary)18 ArrayList (java.util.ArrayList)8 Leg (org.opentripplanner.model.plan.Leg)8 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)7 GraphPath (org.opentripplanner.routing.spt.GraphPath)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Comparator (java.util.Comparator)3 RoutingService (org.opentripplanner.routing.RoutingService)3 Scalars (graphql.Scalars)2 DefaultConnection (graphql.relay.DefaultConnection)2 DefaultPageInfo (graphql.relay.DefaultPageInfo)2 Relay (graphql.relay.Relay)2 SimpleListConnection (graphql.relay.SimpleListConnection)2 GraphQLArgument (graphql.schema.GraphQLArgument)2 GraphQLEnumType (graphql.schema.GraphQLEnumType)2 GraphQLFieldDefinition (graphql.schema.GraphQLFieldDefinition)2 GraphQLInputObjectField (graphql.schema.GraphQLInputObjectField)2