Search in sources :

Example 11 with Stop

use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.

the class LegacyGraphQLNodeTypeResolver method getType.

@Override
public GraphQLObjectType getType(TypeResolutionEnvironment environment) {
    Object o = environment.getObject();
    GraphQLSchema schema = environment.getSchema();
    if (o instanceof Agency)
        return schema.getObjectType("Agency");
    if (o instanceof TransitAlert)
        return schema.getObjectType("Alert");
    if (o instanceof BikePark)
        return schema.getObjectType("BikePark");
    if (o instanceof BikeRentalStation)
        return schema.getObjectType("BikeRentalStation");
    // if (o instanceof Cluster) return schema.getObjectType("Cluster");
    if (o instanceof PatternAtStop)
        return schema.getObjectType("DepartureRow");
    if (o instanceof TripPattern)
        return schema.getObjectType("Pattern");
    if (o instanceof PlaceAtDistance)
        return schema.getObjectType("placeAtDistance");
    if (o instanceof Route)
        return schema.getObjectType("Route");
    if (o instanceof Stop)
        return schema.getObjectType("Stop");
    if (o instanceof Station)
        return schema.getObjectType("Stop");
    if (o instanceof TripTimeShort)
        return schema.getObjectType("Stoptime");
    if (o instanceof StopAtDistance)
        return schema.getObjectType("stopAtDistance");
    if (o instanceof FareRuleSet)
        return schema.getObjectType("TicketType");
    if (o instanceof Trip)
        return schema.getObjectType("Trip");
    return null;
}
Also used : TransitAlert(org.opentripplanner.routing.alertpatch.TransitAlert) Trip(org.opentripplanner.model.Trip) Agency(org.opentripplanner.model.Agency) Stop(org.opentripplanner.model.Stop) PatternAtStop(org.opentripplanner.routing.graphfinder.PatternAtStop) PlaceAtDistance(org.opentripplanner.routing.graphfinder.PlaceAtDistance) FareRuleSet(org.opentripplanner.routing.core.FareRuleSet) BikePark(org.opentripplanner.routing.bike_park.BikePark) GraphQLSchema(graphql.schema.GraphQLSchema) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) TripPattern(org.opentripplanner.model.TripPattern) Station(org.opentripplanner.model.Station) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) TripTimeShort(org.opentripplanner.model.TripTimeShort) PatternAtStop(org.opentripplanner.routing.graphfinder.PatternAtStop) StopAtDistance(org.opentripplanner.routing.graphfinder.StopAtDistance) Route(org.opentripplanner.model.Route)

Example 12 with Stop

use of org.opentripplanner.model.Stop 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 13 with Stop

use of org.opentripplanner.model.Stop 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 14 with Stop

use of org.opentripplanner.model.Stop 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)

Example 15 with Stop

use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.

the class TransferMapper method doMap.

private Collection<Transfer> doMap(org.onebusaway.gtfs.model.Transfer rhs) {
    Trip fromTrip = tripMapper.map(rhs.getFromTrip());
    Trip toTrip = tripMapper.map(rhs.getToTrip());
    Route fromRoute = routeMapper.map(rhs.getFromRoute());
    Route toRoute = routeMapper.map(rhs.getToRoute());
    TransferType transferType = TransferType.valueOfGtfsCode(rhs.getTransferType());
    int transferTime = rhs.getMinTransferTime();
    // Transfers may be specified using parent stations
    // (https://developers.google.com/transit/gtfs/reference/transfers-file)
    // "If the stop ID refers to a station that contains multiple stops, this transfer rule
    // applies to all stops in that station." we thus expand transfers that use parent stations
    // to all the member stops.
    Collection<Stop> fromStops = getStopOrChildStops(rhs.getFromStop());
    Collection<Stop> toStops = getStopOrChildStops(rhs.getToStop());
    Collection<Transfer> lhs = new ArrayList<>();
    for (Stop fromStop : fromStops) {
        for (Stop toStop : toStops) {
            lhs.add(new Transfer(fromStop, toStop, fromRoute, toRoute, fromTrip, toTrip, transferType, transferTime));
        }
    }
    return lhs;
}
Also used : Trip(org.opentripplanner.model.Trip) Stop(org.opentripplanner.model.Stop) Transfer(org.opentripplanner.model.Transfer) ArrayList(java.util.ArrayList) TransferType(org.opentripplanner.model.TransferType) Route(org.opentripplanner.model.Route)

Aggregations

Stop (org.opentripplanner.model.Stop)73 FeedScopedId (org.opentripplanner.model.FeedScopedId)25 ArrayList (java.util.ArrayList)24 TripPattern (org.opentripplanner.model.TripPattern)24 Trip (org.opentripplanner.model.Trip)21 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)13 RoutingService (org.opentripplanner.routing.RoutingService)13 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)13 HashSet (java.util.HashSet)12 Station (org.opentripplanner.model.Station)12 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)11 List (java.util.List)10 Test (org.junit.Test)8 Route (org.opentripplanner.model.Route)8 StopTime (org.opentripplanner.model.StopTime)8 Collectors (java.util.stream.Collectors)7 GET (javax.ws.rs.GET)7 Path (javax.ws.rs.Path)7 ApiStop (org.opentripplanner.api.model.ApiStop)7 TripTimeShort (org.opentripplanner.model.TripTimeShort)7