use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getAlertsForTrip.
/**
* Return all alerts for a trip
*/
@GET
@Path("/trips/{tripId}/alerts")
public Collection<ApiAlert> getAlertsForTrip(@PathParam("tripId") String tripId) {
RoutingService routingService = createRoutingService();
// TODO: Add locale
AlertMapper alertMapper = new AlertMapper(null);
FeedScopedId id = createId("tripId", tripId);
return alertMapper.mapToApi(routingService.getTransitAlertService().getTripAlerts(id));
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getStoptimesForStopAndDate.
/**
* Return upcoming vehicle arrival/departure times at the given stop.
* @param date in YYYYMMDD or YYYY-MM-DD format
*/
@GET
@Path("/stops/{stopId}/stoptimes/{date}")
public List<ApiStopTimesInPattern> getStoptimesForStopAndDate(@PathParam("stopId") String stopId, @PathParam("date") String date, @QueryParam("omitNonPickups") boolean omitNonPickups) {
RoutingService routingService = createRoutingService();
Stop stop = getStop(routingService, stopId);
ServiceDate serviceDate = parseServiceDate("date", date);
List<StopTimesInPattern> stopTimes = routingService.getStopTimesForStop(stop, serviceDate, omitNonPickups);
return StopTimesInPatternMapper.mapToApi(stopTimes);
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getTransfers.
/**
* Return the generated transfers a stop in the graph, by stop ID
*/
@GET
@Path("/stops/{stopId}/transfers")
public Collection<ApiTransfer> getTransfers(@PathParam("stopId") String stopId) {
RoutingService routingService = createRoutingService();
Stop stop = getStop(routingService, stopId);
// get the transfers for the stop
return routingService.getTransfersByStop(stop).stream().map(TransferMapper::mapToApi).collect(Collectors.toList());
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getAgencyRoutes.
/**
* Return all routes for the specific agency.
*/
@GET
@Path("/agencies/{feedId}/{agencyId}/routes")
public Response getAgencyRoutes(@PathParam("feedId") String feedId, @PathParam("agencyId") String agencyId) {
RoutingService routingService = createRoutingService();
Agency agency = getAgency(routingService, feedId, agencyId);
Collection<Route> routes = routingService.getAllRoutes().stream().filter(r -> r.getAgency() == agency).collect(Collectors.toList());
if (detail) {
return Response.status(Status.OK).entity(RouteMapper.mapToApi(routes)).build();
} else {
return Response.status(Status.OK).entity(RouteMapper.mapToApiShort(routes)).build();
}
}
use of org.opentripplanner.routing.RoutingService in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getStopsForRoute.
/**
* Return all stops in any pattern on a given route.
*/
@GET
@Path("/routes/{routeId}/stops")
public List<ApiStopShort> getStopsForRoute(@PathParam("routeId") String routeId) {
RoutingService routingService = createRoutingService();
Route route = getRoute(routingService, routeId);
Set<Stop> stops = new HashSet<>();
Collection<TripPattern> patterns = routingService.getPatternsForRoute().get(route);
for (TripPattern pattern : patterns) {
stops.addAll(pattern.getStops());
}
return StopMapper.mapToApiShort(stops);
}
Aggregations