use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getStopTimesForStop.
/**
* Return upcoming vehicle arrival/departure times at the given stop.
*
* @param stopIdString Stop ID in Agency:Stop ID format
* @param startTime Start time for the search. Seconds from UNIX epoch
* @param timeRange Searches forward for timeRange seconds from startTime
* @param numberOfDepartures Number of departures to fetch per pattern
*/
@GET
@Path("/stops/{stopId}/stoptimes")
public Collection<ApiStopTimesInPattern> getStopTimesForStop(@PathParam("stopId") String stopIdString, @QueryParam("startTime") long startTime, @QueryParam("timeRange") @DefaultValue("86400") int timeRange, @QueryParam("numberOfDepartures") @DefaultValue("2") int numberOfDepartures, @QueryParam("omitNonPickups") boolean omitNonPickups) {
RoutingService routingService = createRoutingService();
Stop stop = getStop(routingService, stopIdString);
return routingService.stopTimesForStop(stop, startTime, timeRange, numberOfDepartures, omitNonPickups).stream().map(StopTimesInPatternMapper::mapToApi).collect(Collectors.toList());
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getAlertsForStop.
/**
* Return all alerts for a stop
*/
@GET
@Path("/stops/{stopId}/alerts")
public Collection<ApiAlert> getAlertsForStop(@PathParam("stopId") String stopId) {
RoutingService routingService = createRoutingService();
// TODO: Add locale
AlertMapper alertMapper = new AlertMapper(null);
FeedScopedId id = createId("stopId", stopId);
return alertMapper.mapToApi(routingService.getTransitAlertService().getStopAlerts(id));
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getAlertsForPattern.
/**
* Return all alerts for a pattern
*/
@GET
@Path("/patterns/{patternId}/alerts")
public Collection<ApiAlert> getAlertsForPattern(@PathParam("patternId") String patternId) {
RoutingService routingService = createRoutingService();
// TODO: Add locale
AlertMapper alertMapper = new AlertMapper(null);
FeedScopedId id = createId("patternId", patternId);
return alertMapper.mapToApi(routingService.getTransitAlertService().getTripPatternAlerts(id));
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getRoutes.
/**
* Return a list of all routes in the graph.
*/
// with repeated hasStop parameters, replaces old routesBetweenStops
@GET
@Path("/routes")
public List<ApiRouteShort> getRoutes(@QueryParam("hasStop") List<String> stopIds) {
RoutingService routingService = createRoutingService();
Collection<Route> routes = routingService.getAllRoutes();
// Filter routes to include only those that pass through all given stops
if (stopIds != null) {
// Protective copy, we are going to calculate the intersection destructively
routes = new ArrayList<>(routes);
for (String stopId : stopIds) {
Stop stop = getStop(routingService, stopId);
Set<Route> routesHere = new HashSet<>();
for (TripPattern pattern : routingService.getPatternsForStop(stop)) {
routesHere.add(pattern.route);
}
routes.retainAll(routesHere);
}
}
return RouteMapper.mapToApiShort(routes);
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getPatternsForRoute.
/**
* Return all stop patterns used by trips on the given route.
*/
@GET
@Path("/routes/{routeId}/patterns")
public List<ApiPatternShort> getPatternsForRoute(@PathParam("routeId") String routeId) {
RoutingService routingService = createRoutingService();
Collection<TripPattern> patterns = routingService.getPatternsForRoute().get(getRoute(routingService, routeId));
return TripPatternMapper.mapToApiShort(patterns);
}
Aggregations