Search in sources :

Example 6 with RoutingService

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));
}
Also used : RoutingService(org.opentripplanner.routing.RoutingService) FeedScopedId(org.opentripplanner.model.FeedScopedId) AlertMapper(org.opentripplanner.api.mapping.AlertMapper) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 7 with RoutingService

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);
}
Also used : ServiceDate(org.opentripplanner.model.calendar.ServiceDate) ApiStop(org.opentripplanner.api.model.ApiStop) Stop(org.opentripplanner.model.Stop) RoutingService(org.opentripplanner.routing.RoutingService) StopTimesInPattern(org.opentripplanner.model.StopTimesInPattern) ApiStopTimesInPattern(org.opentripplanner.api.model.ApiStopTimesInPattern) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 8 with RoutingService

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());
}
Also used : ApiStop(org.opentripplanner.api.model.ApiStop) Stop(org.opentripplanner.model.Stop) RoutingService(org.opentripplanner.routing.RoutingService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 9 with RoutingService

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();
    }
}
Also used : RoutingService(org.opentripplanner.routing.RoutingService) Trip(org.opentripplanner.model.Trip) Produces(javax.ws.rs.Produces) StopTimesInPattern(org.opentripplanner.model.StopTimesInPattern) Path(javax.ws.rs.Path) ApiTripShort(org.opentripplanner.api.model.ApiTripShort) StopMapper(org.opentripplanner.api.mapping.StopMapper) StopTimesInPatternMapper(org.opentripplanner.api.mapping.StopTimesInPatternMapper) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) AgencyMapper(org.opentripplanner.api.mapping.AgencyMapper) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) TripTimeShort(org.opentripplanner.model.TripTimeShort) TripMapper(org.opentripplanner.api.mapping.TripMapper) DefaultValue(javax.ws.rs.DefaultValue) RouteMapper(org.opentripplanner.api.mapping.RouteMapper) BadRequestException(javax.ws.rs.BadRequestException) ApiStop(org.opentripplanner.api.model.ApiStop) ParseException(java.text.ParseException) FeedScopedId(org.opentripplanner.model.FeedScopedId) ApiRouteShort(org.opentripplanner.api.model.ApiRouteShort) Context(javax.ws.rs.core.Context) TripPatternMapper(org.opentripplanner.api.mapping.TripPatternMapper) TripPattern(org.opentripplanner.model.TripPattern) ApiTrip(org.opentripplanner.api.model.ApiTrip) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) Set(java.util.Set) ApiStopShort(org.opentripplanner.api.model.ApiStopShort) Collectors(java.util.stream.Collectors) ApiFeedInfo(org.opentripplanner.api.model.ApiFeedInfo) ApiStopTimesInPattern(org.opentripplanner.api.model.ApiStopTimesInPattern) NotFoundException(javax.ws.rs.NotFoundException) ApiRoute(org.opentripplanner.api.model.ApiRoute) List(java.util.List) PolylineEncoder(org.opentripplanner.util.PolylineEncoder) EncodedPolylineBean(org.opentripplanner.util.model.EncodedPolylineBean) Response(javax.ws.rs.core.Response) WgsCoordinate(org.opentripplanner.model.WgsCoordinate) UriInfo(javax.ws.rs.core.UriInfo) FeedInfoMapper(org.opentripplanner.api.mapping.FeedInfoMapper) OTPServer(org.opentripplanner.standalone.server.OTPServer) TransferMapper(org.opentripplanner.api.mapping.TransferMapper) PathParam(javax.ws.rs.PathParam) GET(javax.ws.rs.GET) ApiAlert(org.opentripplanner.api.model.ApiAlert) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ApiTransfer(org.opentripplanner.api.model.ApiTransfer) AlertMapper(org.opentripplanner.api.mapping.AlertMapper) Status(javax.ws.rs.core.Response.Status) ApiAgency(org.opentripplanner.api.model.ApiAgency) Timetable(org.opentripplanner.model.Timetable) Agency(org.opentripplanner.model.Agency) ApiPatternShort(org.opentripplanner.api.model.ApiPatternShort) LineString(org.locationtech.jts.geom.LineString) Route(org.opentripplanner.model.Route) FeedScopedIdMapper(org.opentripplanner.api.mapping.FeedScopedIdMapper) ApiAgency(org.opentripplanner.api.model.ApiAgency) Agency(org.opentripplanner.model.Agency) RoutingService(org.opentripplanner.routing.RoutingService) ApiRoute(org.opentripplanner.api.model.ApiRoute) Route(org.opentripplanner.model.Route) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 10 with RoutingService

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);
}
Also used : ApiStop(org.opentripplanner.api.model.ApiStop) Stop(org.opentripplanner.model.Stop) RoutingService(org.opentripplanner.routing.RoutingService) ApiRoute(org.opentripplanner.api.model.ApiRoute) Route(org.opentripplanner.model.Route) TripPattern(org.opentripplanner.model.TripPattern) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

RoutingService (org.opentripplanner.routing.RoutingService)32 GET (javax.ws.rs.GET)17 Path (javax.ws.rs.Path)16 Stop (org.opentripplanner.model.Stop)13 FeedScopedId (org.opentripplanner.model.FeedScopedId)12 TripPattern (org.opentripplanner.model.TripPattern)9 List (java.util.List)8 ApiStop (org.opentripplanner.api.model.ApiStop)8 Trip (org.opentripplanner.model.Trip)8 HashSet (java.util.HashSet)7 Collectors (java.util.stream.Collectors)7 Collection (java.util.Collection)5 Stream (java.util.stream.Stream)5 AlertMapper (org.opentripplanner.api.mapping.AlertMapper)5 Route (org.opentripplanner.model.Route)5 StopTimesInPattern (org.opentripplanner.model.StopTimesInPattern)5 TripTimeShort (org.opentripplanner.model.TripTimeShort)5 Relay (graphql.relay.Relay)4 ArrayList (java.util.ArrayList)4 Objects (java.util.Objects)4