Search in sources :

Example 1 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class NearbyStopFinder method findNearbyStopsViaStreets.

/**
 * Return all stops within a certain radius of the given vertex, using network distance along streets.
 * If the origin vertex is a StopVertex, the result will include it.
 *
 * @param originVertices the origin point of the street search
 * @param reverseDirection if true the paths returned instead originate at the nearby stops and have the
 *                         originVertex as the destination
 * @param removeTempEdges after creating a new routing request and routing context, remove all the temporary
 *                        edges that are part of that context. NOTE: this will remove _all_ temporary edges
 *                        coming out of the origin and destination vertices, including those in any other
 *                        RoutingContext referencing them, making routing from/to them totally impossible.
 *                        This is a stopgap solution until we rethink the lifecycle of RoutingContext.
 */
public List<StopAtDistance> findNearbyStopsViaStreets(Set<Vertex> originVertices, boolean reverseDirection, boolean removeTempEdges, RoutingRequest routingRequest) {
    routingRequest.arriveBy = reverseDirection;
    if (!reverseDirection) {
        routingRequest.setRoutingContext(graph, originVertices, null);
    } else {
        routingRequest.setRoutingContext(graph, null, originVertices);
    }
    int walkTime = (int) (radiusMeters / new RoutingRequest().walkSpeed);
    routingRequest.worstTime = routingRequest.dateTime + (reverseDirection ? -walkTime : walkTime);
    routingRequest.disableRemainingWeightHeuristic = true;
    routingRequest.rctx.remainingWeightHeuristic = new TrivialRemainingWeightHeuristic();
    routingRequest.dominanceFunction = new DominanceFunction.MinimumWeight();
    ShortestPathTree spt = astar.getShortestPathTree(routingRequest);
    List<StopAtDistance> stopsFound = Lists.newArrayList();
    Multimap<FlexStopLocation, State> locationsMap = ArrayListMultimap.create();
    if (spt != null) {
        // TODO use GenericAStar and a traverseVisitor? Add an earliestArrival switch to genericAStar?
        for (State state : spt.getAllStates()) {
            Vertex targetVertex = state.getVertex();
            if (originVertices.contains(targetVertex))
                continue;
            if (targetVertex instanceof TransitStopVertex && state.isFinal()) {
                stopsFound.add(StopAtDistance.stopAtDistanceForState(state, ((TransitStopVertex) targetVertex).getStop()));
            }
            if (OTPFeature.FlexRouting.isOn() && targetVertex instanceof StreetVertex && ((StreetVertex) targetVertex).flexStopLocations != null) {
                for (FlexStopLocation flexStopLocation : ((StreetVertex) targetVertex).flexStopLocations) {
                    // This is for a simplification, so that we only return one vertex from each
                    // stop location. All vertices are added to the multimap, which is filtered
                    // below, so that only the closest vertex is added to stopsFound
                    locationsMap.put(flexStopLocation, state);
                }
            }
        }
    }
    for (var locationStates : locationsMap.asMap().entrySet()) {
        FlexStopLocation flexStopLocation = locationStates.getKey();
        Collection<State> states = locationStates.getValue();
        // Select the vertex from all vertices that are reachable per FlexStopLocation by taking
        // the minimum walking distance
        State min = Collections.min(states, (s1, s2) -> (int) (s1.walkDistance - s2.walkDistance));
        stopsFound.add(StopAtDistance.stopAtDistanceForState(min, flexStopLocation));
    }
    /* Add the origin vertices if needed. The SPT does not include the initial state. FIXME shouldn't it? */
    for (Vertex vertex : originVertices) {
        if (vertex instanceof TransitStopVertex) {
            stopsFound.add(new StopAtDistance((TransitStopVertex) vertex, 0, Collections.emptyList(), null, new State(vertex, routingRequest)));
        }
    }
    if (removeTempEdges) {
        routingRequest.cleanup();
    }
    return stopsFound;
}
Also used : TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) Vertex(org.opentripplanner.routing.graph.Vertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) State(org.opentripplanner.routing.core.State) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) TrivialRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) StopAtDistance(org.opentripplanner.routing.graphfinder.StopAtDistance) FlexStopLocation(org.opentripplanner.model.FlexStopLocation) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) DominanceFunction(org.opentripplanner.routing.spt.DominanceFunction)

Example 2 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class WalkableAreaBuilder method pruneAreaEdges.

/**
 * Do an all-pairs shortest path search from a list of vertices over a specified set of edges,
 * and retain only those edges which are actually used in some shortest path.
 *
 * @param startingVertices
 * @param edges
 */
private void pruneAreaEdges(Collection<Vertex> startingVertices, Set<Edge> edges) {
    if (edges.size() == 0)
        return;
    TraverseMode mode;
    StreetEdge firstEdge = (StreetEdge) edges.iterator().next();
    if (firstEdge.getPermission().allows(StreetTraversalPermission.PEDESTRIAN)) {
        mode = TraverseMode.WALK;
    } else if (firstEdge.getPermission().allows(StreetTraversalPermission.BICYCLE)) {
        mode = TraverseMode.BICYCLE;
    } else {
        mode = TraverseMode.CAR;
    }
    RoutingRequest options = new RoutingRequest(mode);
    options.dominanceFunction = new DominanceFunction.EarliestArrival();
    options.setDummyRoutingContext(graph);
    AStar search = new AStar();
    search.setSkipEdgeStrategy(new ListedEdgesOnly(edges));
    Set<Edge> usedEdges = new HashSet<Edge>();
    for (Vertex vertex : startingVertices) {
        options.setRoutingContext(graph, vertex, null);
        options.rctx.remainingWeightHeuristic = new TrivialRemainingWeightHeuristic();
        ShortestPathTree spt = search.getShortestPathTree(options);
        for (Vertex endVertex : startingVertices) {
            GraphPath path = spt.getPath(endVertex, false);
            if (path != null) {
                for (Edge edge : path.edges) {
                    usedEdges.add(edge);
                }
            }
        }
    }
    for (Edge edge : edges) {
        if (!usedEdges.contains(edge)) {
            graph.removeEdge(edge);
        }
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) AStar(org.opentripplanner.routing.algorithm.astar.AStar) GraphPath(org.opentripplanner.routing.spt.GraphPath) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) TrivialRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic) TraverseMode(org.opentripplanner.routing.core.TraverseMode) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) DominanceFunction(org.opentripplanner.routing.spt.DominanceFunction) AreaEdge(org.opentripplanner.routing.edgetype.AreaEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Example 3 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TransmodelGraphQLPlanner method createRequest.

private RoutingRequest createRequest(DataFetchingEnvironment environment) {
    TransmodelRequestContext context = environment.getContext();
    Router router = context.getRouter();
    RoutingRequest request = router.defaultRoutingRequest.clone();
    DataFetcherDecorator callWith = new DataFetcherDecorator(environment);
    callWith.argument("locale", (String v) -> request.locale = Locale.forLanguageTag(v));
    callWith.argument("from", (Map<String, Object> v) -> request.from = toGenericLocation(v));
    callWith.argument("to", (Map<String, Object> v) -> request.to = toGenericLocation(v));
    callWith.argument("dateTime", millisSinceEpoch -> request.setDateTime(new Date((long) millisSinceEpoch)), Date::new);
    callWith.argument("searchWindow", (Integer m) -> request.searchWindow = Duration.ofMinutes(m));
    callWith.argument("wheelchair", request::setWheelchairAccessible);
    callWith.argument("numTripPatterns", request::setNumItineraries);
    callWith.argument("transitGeneralizedCostLimit", (DoubleFunction<Double> it) -> request.transitGeneralizedCostLimit = it);
    callWith.argument("maximumWalkDistance", request::setMaxWalkDistance);
    // callWith.argument("maxTransferWalkDistance", request::setMaxTransferWalkDistance);
    callWith.argument("maxPreTransitTime", request::setMaxPreTransitTime);
    // callWith.argument("preTransitReluctance", (Double v) ->  request.setPreTransitReluctance(v));
    // callWith.argument("maxPreTransitWalkDistance", (Double v) ->  request.setMaxPreTransitWalkDistance(v));
    callWith.argument("walkBoardCost", request::setWalkBoardCost);
    callWith.argument("walkReluctance", request::setWalkReluctance);
    callWith.argument("waitReluctance", request::setWaitReluctance);
    callWith.argument("walkBoardCost", request::setWalkBoardCost);
    // callWith.argument("walkOnStreetReluctance", request::setWalkOnStreetReluctance);
    callWith.argument("waitReluctance", request::setWaitReluctance);
    callWith.argument("waitAtBeginningFactor", request::setWaitAtBeginningFactor);
    callWith.argument("walkSpeed", (Double v) -> request.walkSpeed = v);
    callWith.argument("bikeSpeed", (Double v) -> request.bikeSpeed = v);
    callWith.argument("bikeSwitchTime", (Integer v) -> request.bikeSwitchTime = v);
    callWith.argument("bikeSwitchCost", (Integer v) -> request.bikeSwitchCost = v);
    // callWith.argument("transitDistanceReluctance", (Double v) -> request.transitDistanceReluctance = v);
    BicycleOptimizeType optimize = environment.getArgument("optimize");
    if (optimize == BicycleOptimizeType.TRIANGLE) {
        try {
            RoutingRequest.assertTriangleParameters(request.bikeTriangleSafetyFactor, request.bikeTriangleTimeFactor, request.bikeTriangleSlopeFactor);
            callWith.argument("triangle.safetyFactor", request::setBikeTriangleSafetyFactor);
            callWith.argument("triangle.slopeFactor", request::setBikeTriangleSlopeFactor);
            callWith.argument("triangle.timeFactor", request::setBikeTriangleTimeFactor);
        } catch (ParameterException e) {
            throw new RuntimeException(e);
        }
    }
    callWith.argument("arriveBy", request::setArriveBy);
    request.showIntermediateStops = true;
    callWith.argument("vias", (List<Map<String, Object>> v) -> request.intermediatePlaces = v.stream().map(this::toGenericLocation).collect(Collectors.toList()));
    callWith.argument("preferred.authorities", (Collection<String> authorities) -> request.setPreferredAgencies(mapIDsToDomain(authorities)));
    callWith.argument("unpreferred.authorities", (Collection<String> authorities) -> request.setUnpreferredAgencies(mapIDsToDomain(authorities)));
    callWith.argument("whiteListed.authorities", (Collection<String> authorities) -> request.setWhiteListedAgencies(mapIDsToDomain(authorities)));
    callWith.argument("banned.authorities", (Collection<String> authorities) -> request.setBannedAgencies(mapIDsToDomain(authorities)));
    callWith.argument("preferred.otherThanPreferredLinesPenalty", request::setOtherThanPreferredRoutesPenalty);
    callWith.argument("preferred.lines", (List<String> lines) -> request.setPreferredRoutes(mapIDsToDomain(lines)));
    callWith.argument("unpreferred.lines", (List<String> lines) -> request.setUnpreferredRoutes(mapIDsToDomain(lines)));
    callWith.argument("whiteListed.lines", (List<String> lines) -> request.setWhiteListedRoutes(mapIDsToDomain(lines)));
    callWith.argument("banned.lines", (List<String> lines) -> request.setBannedRoutes(mapIDsToDomain(lines)));
    callWith.argument("banned.serviceJourneys", (Collection<String> serviceJourneys) -> request.bannedTrips = toBannedTrips(serviceJourneys));
    // callWith.argument("banned.quays", quays -> request.setBannedStops(mappingUtil.prepareListOfFeedScopedId((List<String>) quays)));
    // callWith.argument("banned.quaysHard", quaysHard -> request.setBannedStopsHard(mappingUtil.prepareListOfFeedScopedId((List<String>) quaysHard)));
    // callWith.argument("heuristicStepsPerMainStep", (Integer v) -> request.heuristicStepsPerMainStep = v);
    // callWith.argument("compactLegsByReversedSearch", (Boolean v) -> { /* not used any more */ });
    // callWith.argument("banFirstServiceJourneysFromReuseNo", (Integer v) -> request.banFirstTripsFromReuseNo = v);
    callWith.argument("allowBikeRental", (Boolean v) -> request.bikeRental = v);
    callWith.argument("debugItineraryFilter", (Boolean v) -> request.debugItineraryFilter = v);
    callWith.argument("transferPenalty", (Integer v) -> request.transferCost = v);
    if (optimize == BicycleOptimizeType.TRANSFERS) {
        optimize = BicycleOptimizeType.QUICK;
        request.transferCost += 1800;
    }
    if (optimize != null) {
        request.optimize = optimize;
    }
    if (GqlUtil.hasArgument(environment, "modes")) {
        ElementWrapper<StreetMode> accessMode = new ElementWrapper<>();
        ElementWrapper<StreetMode> egressMode = new ElementWrapper<>();
        ElementWrapper<StreetMode> directMode = new ElementWrapper<>();
        ElementWrapper<ArrayList<TransitMode>> transitModes = new ElementWrapper<>();
        callWith.argument("modes.accessMode", accessMode::set);
        callWith.argument("modes.egressMode", egressMode::set);
        callWith.argument("modes.directMode", directMode::set);
        callWith.argument("modes.transportMode", transitModes::set);
        if (transitModes.get() == null) {
            // Default to all transport modes if transport modes not specified
            transitModes.set(new ArrayList<>(Arrays.asList(TransitMode.values())));
        }
        request.modes = new RequestModes(accessMode.get(), egressMode.get(), directMode.get(), new HashSet<>(transitModes.get()));
    }
    if (request.bikeRental && !GqlUtil.hasArgument(environment, "bikeSpeed")) {
        // slower bike speed for bike sharing, based on empirical evidence from DC.
        request.bikeSpeed = 4.3;
    }
    callWith.argument("minimumTransferTime", (Integer v) -> request.transferSlack = v);
    callWith.argument("transferSlack", (Integer v) -> request.transferSlack = v);
    callWith.argument("boardSlackDefault", (Integer v) -> request.boardSlack = v);
    callWith.argument("boardSlackList", (Object v) -> request.boardSlackForMode = TransportModeSlack.mapToDomain(v));
    callWith.argument("alightSlackDefault", (Integer v) -> request.alightSlack = v);
    callWith.argument("alightSlackList", (Object v) -> request.alightSlackForMode = TransportModeSlack.mapToDomain(v));
    callWith.argument("maximumTransfers", (Integer v) -> request.maxTransfers = v);
    final long NOW_THRESHOLD_MILLIS = 15 * 60 * 60 * 1000;
    boolean tripPlannedForNow = Math.abs(request.getDateTime().getTime() - new Date().getTime()) < NOW_THRESHOLD_MILLIS;
    // TODO the same thing for GTFS-RT
    request.useBikeRentalAvailabilityInformation = (tripPlannedForNow);
    callWith.argument("ignoreRealtimeUpdates", (Boolean v) -> request.ignoreRealtimeUpdates = v);
    return request;
}
Also used : BicycleOptimizeType(org.opentripplanner.routing.core.BicycleOptimizeType) ArrayList(java.util.ArrayList) DataFetcherDecorator(org.opentripplanner.ext.transmodelapi.support.DataFetcherDecorator) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) ParameterException(org.opentripplanner.api.common.ParameterException) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) StreetMode(org.opentripplanner.routing.api.request.StreetMode) Router(org.opentripplanner.standalone.server.Router) Date(java.util.Date) DoubleFunction(java.util.function.DoubleFunction) RequestModes(org.opentripplanner.routing.api.request.RequestModes) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class PlannerResource method plan.

// We inject info about the incoming request so we can include the incoming query
// parameters in the outgoing response. This is a TriMet requirement.
// Jersey uses @Context to inject internal types and @InjectParam or @Resource for DI objects.
@GET
@Produces(MediaType.APPLICATION_JSON)
public TripPlannerResponse plan(@Context UriInfo uriInfo, @Context Request grizzlyRequest) {
    /*
         * TODO: add Lang / Locale parameter, and thus get localized content (Messages & more...)
         * TODO: from/to inputs should be converted / geocoded / etc... here, and maybe send coords 
         *       or vertex ids to planner (or error back to user)
         * TODO: org.opentripplanner.routing.module.PathServiceImpl has COOORD parsing. Abstract that
         *       out so it's used here too...
         */
    // Create response object, containing a copy of all request parameters. Maybe they should be in the debug section of the response.
    TripPlannerResponse response = new TripPlannerResponse(uriInfo);
    RoutingRequest request = null;
    Router router = null;
    RoutingResponse res = null;
    try {
        /* Fill in request fields from query parameters via shared superclass method, catching any errors. */
        request = super.buildRequest();
        router = otpServer.getRouter();
        // Route
        RoutingService routingService = new RoutingService(router.graph);
        res = routingService.route(request, router);
        // Map to API
        TripPlanMapper tripPlanMapper = new TripPlanMapper(request.locale);
        response.setPlan(tripPlanMapper.mapTripPlan(res.getTripPlan()));
        response.setMetadata(TripSearchMetadataMapper.mapTripSearchMetadata(res.getMetadata()));
        if (!res.getRoutingErrors().isEmpty()) {
            // The api can only return one error message, so the first one is mapped
            response.setError(PlannerErrorMapper.mapMessage(res.getRoutingErrors().get(0)));
        }
        /* Populate up the elevation metadata */
        response.elevationMetadata = new ElevationMetadata();
        response.elevationMetadata.ellipsoidToGeoidDifference = router.graph.ellipsoidToGeoidDifference;
        response.elevationMetadata.geoidElevation = request.geoidElevation;
        response.debugOutput = res.getDebugAggregator().finishedRendering();
    } catch (Exception e) {
        LOG.error("System error", e);
        PlannerError error = new PlannerError();
        error.setMsg(Message.SYSTEM_ERROR);
        response.setError(error);
    }
    /* Log this request if such logging is enabled. */
    if (request != null && router != null && router.requestLogger != null) {
        StringBuilder sb = new StringBuilder();
        String clientIpAddress = grizzlyRequest.getRemoteAddr();
        // sb.append(LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
        sb.append(clientIpAddress);
        sb.append(' ');
        sb.append(request.arriveBy ? "ARRIVE" : "DEPART");
        sb.append(' ');
        sb.append(LocalDateTime.ofInstant(Instant.ofEpochSecond(request.dateTime), ZoneId.systemDefault()));
        sb.append(' ');
        sb.append(request.streetSubRequestModes.getAsStr());
        sb.append(' ');
        sb.append(request.from.lat);
        sb.append(' ');
        sb.append(request.from.lng);
        sb.append(' ');
        sb.append(request.to.lat);
        sb.append(' ');
        sb.append(request.to.lng);
        sb.append(' ');
        if (res != null) {
            for (Itinerary it : res.getTripPlan().itineraries) {
                sb.append(it.durationSeconds);
                sb.append(' ');
            }
        }
        router.requestLogger.info(sb.toString());
    }
    return response;
}
Also used : TripPlanMapper(org.opentripplanner.api.mapping.TripPlanMapper) RoutingService(org.opentripplanner.routing.RoutingService) Itinerary(org.opentripplanner.model.plan.Itinerary) Router(org.opentripplanner.standalone.server.Router) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) PlannerError(org.opentripplanner.api.model.error.PlannerError) RoutingResponse(org.opentripplanner.routing.api.response.RoutingResponse) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class RoutingRequestMapper method mapRoutingRequest.

public static RoutingRequest mapRoutingRequest(NodeAdapter c) {
    RoutingRequest dft = new RoutingRequest();
    if (c.isEmpty()) {
        return dft;
    }
    LOG.debug("Loading default routing parameters from JSON.");
    RoutingRequest request = new RoutingRequest();
    // Keep this alphabetically sorted so it is easy to check if a parameter is missing from the
    // mapping or duplicate exist.
    request.alightSlack = c.asInt("alightSlack", dft.alightSlack);
    request.alightSlackForMode = c.asEnumMap("alightSlackForMode", TraverseMode.class, NodeAdapter::asInt);
    request.bikeRental = c.asBoolean("allowBikeRental", dft.bikeRental);
    request.arriveBy = c.asBoolean("arriveBy", dft.arriveBy);
    request.bikeBoardCost = c.asInt("bikeBoardCost", dft.bikeBoardCost);
    request.bikeParkAndRide = c.asBoolean("bikeParkAndRide", dft.bikeParkAndRide);
    request.bikeParkTime = c.asInt("bikeParkTime", dft.bikeParkTime);
    request.bikeParkCost = c.asInt("bikeParkCost", dft.bikeParkCost);
    request.bikeRentalDropoffCost = c.asInt("bikeRentalDropoffCost", dft.bikeRentalDropoffCost);
    request.bikeRentalDropoffTime = c.asInt("bikeRentalDropoffTime", dft.bikeRentalDropoffTime);
    request.bikeRentalPickupCost = c.asInt("bikeRentalPickupCost", dft.bikeRentalPickupCost);
    request.bikeRentalPickupTime = c.asInt("bikeRentalPickupTime", dft.bikeRentalPickupTime);
    request.bikeSpeed = c.asDouble("bikeSpeed", dft.bikeSpeed);
    request.bikeTriangleSafetyFactor = c.asDouble("bikeTriangleSafetyFactor", dft.bikeTriangleSafetyFactor);
    request.bikeTriangleSlopeFactor = c.asDouble("bikeTriangleSlopeFactor", dft.bikeTriangleSlopeFactor);
    request.bikeTriangleTimeFactor = c.asDouble("bikeTriangleTimeFactor", dft.bikeTriangleTimeFactor);
    request.bikeSwitchTime = c.asInt("bikeSwitchTime", dft.bikeSwitchTime);
    request.bikeSwitchCost = c.asInt("bikeSwitchCost", dft.bikeSwitchCost);
    request.boardSlack = c.asInt("boardSlack", dft.boardSlack);
    request.boardSlackForMode = c.asEnumMap("boardSlackForMode", TraverseMode.class, NodeAdapter::asInt);
    request.debugItineraryFilter = c.asBoolean("debugItineraryFilter", dft.debugItineraryFilter);
    request.carAccelerationSpeed = c.asDouble("carAccelerationSpeed", dft.carAccelerationSpeed);
    request.carDecelerationSpeed = c.asDouble("carDecelerationSpeed", dft.carDecelerationSpeed);
    request.carDropoffTime = c.asInt("carDropoffTime", dft.carDropoffTime);
    request.carSpeed = c.asDouble("carSpeed", dft.carSpeed);
    request.debugItineraryFilter = c.asBoolean("debugItineraryFilter", dft.debugItineraryFilter);
    request.groupBySimilarityKeepOne = c.asDouble("groupBySimilarityKeepOne", dft.groupBySimilarityKeepOne);
    request.groupBySimilarityKeepNumOfItineraries = c.asDouble("groupBySimilarityKeepNumOfItineraries", dft.groupBySimilarityKeepNumOfItineraries);
    request.disableAlertFiltering = c.asBoolean("disableAlertFiltering", dft.disableAlertFiltering);
    request.disableRemainingWeightHeuristic = c.asBoolean("disableRemainingWeightHeuristic", dft.disableRemainingWeightHeuristic);
    request.driveOnRight = c.asBoolean("driveOnRight", dft.driveOnRight);
    request.elevatorBoardCost = c.asInt("elevatorBoardCost", dft.elevatorBoardCost);
    request.elevatorBoardTime = c.asInt("elevatorBoardTime", dft.elevatorBoardTime);
    request.elevatorHopCost = c.asInt("elevatorHopCost", dft.elevatorHopCost);
    request.elevatorHopTime = c.asInt("elevatorHopTime", dft.elevatorHopTime);
    request.geoidElevation = c.asBoolean("geoidElevation", dft.geoidElevation);
    request.ignoreRealtimeUpdates = c.asBoolean("ignoreRealtimeUpdates", dft.ignoreRealtimeUpdates);
    request.carPickup = c.asBoolean("kissAndRide", dft.carPickup);
    request.locale = c.asLocale("locale", dft.locale);
    request.maxHours = c.asDouble("maxHours", dft.maxHours);
    request.maxPreTransitTime = c.asInt("maxPreTransitTime", dft.maxPreTransitTime);
    request.maxTransferWalkDistance = c.asDouble("maxTransferWalkDistance", dft.maxTransferWalkDistance);
    // 'maxTransfers' is configured in the Raptor tuning parameters, not here
    request.maxWalkDistance = c.asDouble("maxWalkDistance", dft.maxWalkDistance);
    request.maxWeight = c.asDouble("maxWeight", dft.maxWeight);
    // ADA max wheelchair ramp slope is a good default.
    request.maxWheelchairSlope = c.asDouble("maxWheelchairSlope", dft.maxWheelchairSlope);
    request.modes = new RequestModes(StreetMode.WALK, StreetMode.WALK, StreetMode.WALK, new HashSet<>(// TODO Map default modes from config
    Arrays.asList(TransitMode.values())));
    request.nonpreferredTransferCost = c.asInt("nonpreferredTransferPenalty", dft.nonpreferredTransferCost);
    request.numItineraries = c.asInt("numItineraries", dft.numItineraries);
    request.onlyTransitTrips = c.asBoolean("onlyTransitTrips", dft.onlyTransitTrips);
    request.optimize = c.asEnum("optimize", dft.optimize);
    request.otherThanPreferredRoutesPenalty = c.asInt("otherThanPreferredRoutesPenalty", dft.otherThanPreferredRoutesPenalty);
    request.parkAndRide = c.asBoolean("parkAndRide", dft.parkAndRide);
    request.pathComparator = c.asText("pathComparator", dft.pathComparator);
    request.showIntermediateStops = c.asBoolean("showIntermediateStops", dft.showIntermediateStops);
    request.stairsReluctance = c.asDouble("stairsReluctance", dft.stairsReluctance);
    request.startingTransitTripId = c.asFeedScopedId("startingTransitTripId", dft.startingTransitTripId);
    request.transferCost = c.asInt("transferPenalty", dft.transferCost);
    request.transferSlack = c.asInt("transferSlack", dft.transferSlack);
    request.transitGeneralizedCostLimit = c.asLinearFunction("transitGeneralizedCostLimit", dft.transitGeneralizedCostLimit);
    request.turnReluctance = c.asDouble("turnReluctance", dft.turnReluctance);
    request.useBikeRentalAvailabilityInformation = c.asBoolean("useBikeRentalAvailabilityInformation", dft.useBikeRentalAvailabilityInformation);
    request.useRequestedDateTimeInMaxHours = c.asBoolean("useRequestedDateTimeInMaxHours", dft.useRequestedDateTimeInMaxHours);
    request.useUnpreferredRoutesPenalty = c.asInt("useUnpreferredRoutesPenalty", dft.useUnpreferredRoutesPenalty);
    request.waitAtBeginningFactor = c.asDouble("waitAtBeginningFactor", dft.waitAtBeginningFactor);
    request.waitReluctance = c.asDouble("waitReluctance", dft.waitReluctance);
    request.walkBoardCost = c.asInt("walkBoardCost", dft.walkBoardCost);
    request.walkReluctance = c.asDouble("walkReluctance", dft.walkReluctance);
    request.walkSpeed = c.asDouble("walkSpeed", dft.walkSpeed);
    request.walkingBike = c.asBoolean("walkingBike", dft.walkingBike);
    request.wheelchairAccessible = c.asBoolean("wheelchairAccessible", dft.wheelchairAccessible);
    request.worstTime = c.asLong("worstTime", dft.worstTime);
    return request;
}
Also used : RequestModes(org.opentripplanner.routing.api.request.RequestModes) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) TraverseMode(org.opentripplanner.routing.core.TraverseMode) HashSet(java.util.HashSet)

Aggregations

RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)102 GraphPath (org.opentripplanner.routing.spt.GraphPath)50 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)42 Test (org.junit.Test)37 State (org.opentripplanner.routing.core.State)33 Vertex (org.opentripplanner.routing.graph.Vertex)31 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)18 Edge (org.opentripplanner.routing.graph.Edge)17 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)17 AStar (org.opentripplanner.routing.algorithm.astar.AStar)16 Graph (org.opentripplanner.routing.graph.Graph)15 StateEditor (org.opentripplanner.routing.core.StateEditor)13 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)13 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)11 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)10 HashSet (java.util.HashSet)9 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)9 TraverseMode (org.opentripplanner.routing.core.TraverseMode)7 ArrayList (java.util.ArrayList)6 Coordinate (org.locationtech.jts.geom.Coordinate)6