Search in sources :

Example 1 with NearbyStopFinder

use of org.opentripplanner.graph_builder.module.NearbyStopFinder in project OpenTripPlanner by opentripplanner.

the class AccessEgressRouter method streetSearch.

/**
 * @param rr the current routing request
 * @param fromTarget whether to route from or towards the point provided in the routing request
 *                   (access or egress)
 * @param distanceMeters the maximum street distance to search for access/egress stops
 * @return Transfer objects by access/egress stop
 */
public static Collection<AccessEgress> streetSearch(RoutingRequest rr, boolean fromTarget, int distanceMeters, StopIndexForRaptor stopIndex) {
    // TODO OTP2 This has to be done because we have not separated the main RoutingRequest from
    // the subrequest for street searches. From/to vertices are already set based on the main
    // request being arriveBy or not, but here we are actually setting arriveBy based on
    // whether we are doing an access or egress search, regardless of the direction of the
    // main request.
    Set<Vertex> vertices = fromTarget ^ rr.arriveBy ? rr.rctx.toVertices : rr.rctx.fromVertices;
    RoutingRequest nonTransitRoutingRequest = rr.getStreetSearchRequest(fromTarget ? rr.modes.egressMode : rr.modes.accessMode);
    NearbyStopFinder nearbyStopFinder = new NearbyStopFinder(rr.rctx.graph, distanceMeters, true);
    // We set removeTempEdges to false because this is a sub-request - the temporary edges for the origin and
    // target vertex will be cleaned up at the end of the super-request, and we don't want that to happen twice.
    List<StopAtDistance> stopAtDistanceList = nearbyStopFinder.findNearbyStopsViaStreets(vertices, fromTarget, false, nonTransitRoutingRequest);
    Collection<AccessEgress> result = new ArrayList<>();
    for (StopAtDistance stopAtDistance : stopAtDistanceList) {
        result.add(new AccessEgress(stopIndex.indexByStop.get(stopAtDistance.stop), (int) stopAtDistance.state.getElapsedTimeSeconds(), fromTarget ? stopAtDistance.state.reverse() : stopAtDistance.state));
    }
    LOG.debug("Found {} {} stops", result.size(), fromTarget ? "egress" : "access");
    return result;
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) ArrayList(java.util.ArrayList) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) StopAtDistance(org.opentripplanner.routing.graphfinder.StopAtDistance) NearbyStopFinder(org.opentripplanner.graph_builder.module.NearbyStopFinder) AccessEgress(org.opentripplanner.routing.algorithm.raptor.transit.AccessEgress)

Example 2 with NearbyStopFinder

use of org.opentripplanner.graph_builder.module.NearbyStopFinder in project OpenTripPlanner by opentripplanner.

the class EgressAccessRouter method route.

public void route(SpeedTestRequest request) {
    TIMER_ROUTE.time(() -> {
        // Search for access to / egress from transit on streets.
        NearbyStopFinder nearbyStopFinder = new NearbyStopFinder(graph, request.getAccessEgressMaxWalkDistanceMeters(), true);
        accessSearch = new StreetSearch(transitLayer, graph, splitter, nearbyStopFinder);
        egressSearch = new StreetSearch(transitLayer, graph, splitter, nearbyStopFinder);
        accessSearch.route(request.tc().fromPlace, true);
        egressSearch.route(request.tc().toPlace, false);
    });
}
Also used : NearbyStopFinder(org.opentripplanner.graph_builder.module.NearbyStopFinder)

Aggregations

NearbyStopFinder (org.opentripplanner.graph_builder.module.NearbyStopFinder)2 ArrayList (java.util.ArrayList)1 AccessEgress (org.opentripplanner.routing.algorithm.raptor.transit.AccessEgress)1 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)1 Vertex (org.opentripplanner.routing.graph.Vertex)1 StopAtDistance (org.opentripplanner.routing.graphfinder.StopAtDistance)1