Package org.onebusaway.gtfs.model

Examples of org.onebusaway.gtfs.model.Trip


      for (int i = 0; i < journies.size(); ++i) {
        JourneyHeaderElement journey = journies.get(i);
        if (journey.getOperatorId().equals("EU")) {
          continue;
        }
        Trip trip = new Trip();
        String id = journey.getOperatorId() + "-"
            + journey.getJourneyIdentifier();
        if (journies.size() > 1) {
          id += "-" + i;
        }
        trip.setId(new AgencyAndId(journey.getOperatorId(), id));
        trip.setRoute(getRouteForJourney(journey));
        trip.setServiceId(getServiceIdForJourney(journey));

        AgencyAndId routeId = trip.getRoute().getId();
        RouteMetadata metadata = getMetadataForRouteId(routeId);

        String directionName = metadata.getDirectionNameForDirectionId(journey.getRouteDirection());
        if (!isEmpty(directionName)) {
          trip.setTripHeadsign(directionName);
        }
        Integer directionId = metadata.getDirectionIdForDirection(journey.getRouteDirection());
        if (directionId != null) {
          trip.setDirectionId(directionId.toString());
        }

        if (constructTimepoints(journey, trip)) {
          _dao.saveEntity(trip);
        }
View Full Code Here


          rides.add(newRide);

          newRide.firstStop = ((HopEdge) backEdge).getBeginStop();

          newRide.route = routeId;
          Trip trip = state.getBackTrip();
          Route route = trip.getRoute();
          int type = route.getType();
          newRide.classifier = type;
          String shortName = route.getShortName();
          if (shortName == null ) {
            newRide.classifier = SUBWAY;
View Full Code Here

    /** @return A list containing one AgencyAndId (trip_id) for each vehicle boarded in this path,
     * in the chronological order they are boarded. */
    public List<AgencyAndId> getTrips() {
        List<AgencyAndId> ret = new LinkedList<AgencyAndId>();
        Trip lastTrip = null;
        for (State s : states) {
            if (s.getBackEdge() != null) {
                Trip trip = s.getBackTrip();
                if (trip != null && trip != lastTrip) {
                    ret.add(trip.getId());
                    lastTrip = trip;
                }
            }
        }
        return ret;
View Full Code Here

        RoutingRequest opt = ctx.opt;
        opt.rctx = ctx;

        /* 1. Get the list of PatternHop for the given trip ID. */
        AgencyAndId tripId = opt.startingTransitTripId;
        Trip trip = ctx.graph.index.tripForId.get(tripId);
        TripPattern tripPattern = ctx.graph.index.patternForTrip.get(trip);
        if (tripPattern == null) {
            // TODO Shouldn't we bailout on a normal trip plan here, returning null ?
            throw new IllegalArgumentException("Unknown/invalid trip ID: " + tripId);
        }
View Full Code Here

                        bestTripTimes  = tripTimes;
                    }
                }
            }
            if (bestWait < 0) return null; // no appropriate trip was found
            Trip trip = bestTripTimes.trip;
           
            /* check if route and/or Agency are banned for this plan */
            // FIXME this should be done WHILE searching for a trip.
            if (options.tripIsBanned(trip)) return null;

            /* Check if route is preferred by the user. */
            long preferences_penalty = options.preferencesPenaltyForRoute(getPattern().route);
           
            /* Compute penalty for non-preferred transfers. */
            int transferPenalty = 0;
            /* If this is not the first boarding, then we are transferring. */
            if (s0.isEverBoarded()) {
                TransferTable transferTable = options.getRoutingContext().transferTable;
                int transferTime = transferTable.getTransferTime(s0.getPreviousStop(),
                                   getStop(), s0.getPreviousTrip(), trip, boarding);
                transferPenalty  = transferTable.determineTransferPenalty(transferTime,
                                   options.nonpreferredTransferPenalty);
            }           

            /* Found a trip to board. Now make the child state. */
            StateEditor s1 = s0.edit(this);
            s1.setBackMode(getMode());
            s1.setServiceDay(bestServiceDay);
            // Save the trip times in the State to ensure that router has a consistent view
            // and constant-time access to them.
            s1.setTripTimes(bestTripTimes);
            s1.incrementTimeInSeconds(bestWait);
            s1.incrementNumBoardings();
            s1.setTripId(trip.getId());
            s1.setPreviousTrip(trip);
            s1.setZone(getPattern().getZone(stopIndex));
            s1.setRoute(trip.getRoute().getId());

            double wait_cost = bestWait;

            if (!s0.isEverBoarded() && !options.reverseOptimizing) {
                wait_cost *= options.waitAtBeginningFactor;
View Full Code Here

            for (Trip trip : graphIndex.tripForId.values()) {
                map.put(trip.getId().getId(), trip);
            }
            graphIndex.tripForIdWithoutAgency = map;
        }
        Trip trip = graphIndex.tripForIdWithoutAgency.get(tripIdWithoutAgency);
        TripPattern pattern = graphIndex.patternForTrip.get(trip);
        return pattern;
    }
View Full Code Here

    @Override
    public State traverse(State state0) {

        RoutingRequest options = state0.getOptions();
        Trip oldTrip = state0.getBackTrip();
        Trip newTrip = options.arriveBy ? trips.inverse().get(oldTrip) : trips.get(oldTrip);
        if (newTrip == null) return null;

        TripPattern newPattern;
        TripTimes newTripTimes;
        TripTimes oldTripTimes = state0.getTripTimes();
        int arrivalTime;
        int departureTime;
        AgencyAndId tripId = state0.getTripId();

        if (options.arriveBy) {
            // traversing backward
            newPattern = ((OnboardVertex) fromv).getTripPattern();
            newTripTimes = newPattern.getResolvedTripTimes(newTrip, state0);
            arrivalTime = newTripTimes.getArrivalTime(newTripTimes.getNumStops() - 1); // FIXME with getLastTime method
            departureTime = oldTripTimes.getDepartureTime(0);
        } else {
            // traversing forward
            newPattern = ((OnboardVertex) tov).getTripPattern();
            newTripTimes = newPattern.getResolvedTripTimes(newTrip, state0);
            arrivalTime = oldTripTimes.getArrivalTime(oldTripTimes.getNumStops() - 1); // FIXME with getLastTime method
            departureTime = newTripTimes.getDepartureTime(0);
        }

//        BannedStopSet banned = options.bannedTrips.get(newTrip.getId());
//        if (banned != null && banned.contains(0)) // i.e. if the first stop is banned.
//            return null;

        int dwellTime = departureTime - arrivalTime;
        if (dwellTime < 0) return null;

        StateEditor s1 = state0.edit(this);
        s1.incrementTimeInSeconds(dwellTime);
        s1.setTripId(newTrip.getId()); // TODO check meaning
        s1.setPreviousTrip(oldTrip);   // TODO check meaning
        s1.setTripTimes(newTripTimes);
        s1.incrementWeight(dwellTime);
        // Mode should not change.
        return s1.makeState();
View Full Code Here

        // Reverse from and to if we are moving backwards in time
        if (!forwardInTime) {
            Stop tempStop = fromStop;
            fromStop = toStop;
            toStop = tempStop;
            Trip tempTrip = fromTrip;
            fromTrip = toTrip;
            toTrip = tempTrip;
        }
       
        // Get transfer time between the two stops
View Full Code Here

   @GET
   @Path("/trips/{tripId}")
   public Response getTrip (@PathParam("tripId") String tripIdString) {
       AgencyAndId tripId = GtfsLibrary.convertIdFromString(tripIdString);
       Trip trip = index.tripForId.get(tripId);
       if (trip != null) {
           return Response.status(Status.OK).entity(trip).build();
       } else {
           return Response.status(Status.NOT_FOUND).entity(MSG_404).build();
       }
View Full Code Here

   @GET
   @Path("/trips/{tripId}/stops")
   public Response getStopsForTrip (@PathParam("tripId") String tripIdString) {
       AgencyAndId tripId = GtfsLibrary.convertIdFromString(tripIdString);
       Trip trip = index.tripForId.get(tripId);
       if (trip != null) {
           TripPattern pattern = index.patternForTrip.get(trip);
           Collection<Stop> stops = pattern.getStops();
           return Response.status(Status.OK).entity(StopShort.list(stops)).build();
       } else {
View Full Code Here

TOP

Related Classes of org.onebusaway.gtfs.model.Trip

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.