trip.getId().setAgencyId(reader.getDefaultAgencyId());
private Trip doMap(org.onebusaway.gtfs.model.Trip rhs) { Trip lhs = new Trip(); lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); lhs.setRoute(routeMapper.map(rhs.getRoute())); lhs.setServiceId(AgencyAndIdMapper.mapAgencyAndId(rhs.getServiceId())); lhs.setTripShortName(rhs.getTripShortName()); lhs.setTripHeadsign(rhs.getTripHeadsign()); lhs.setRouteShortName(rhs.getRouteShortName()); lhs.setDirectionId(rhs.getDirectionId()); lhs.setBlockId(rhs.getBlockId()); lhs.setShapeId(AgencyAndIdMapper.mapAgencyAndId(rhs.getShapeId())); lhs.setWheelchairAccessible(rhs.getWheelchairAccessible()); lhs.setTripBikesAllowed(rhs.getTripBikesAllowed()); lhs.setBikesAllowed(rhs.getBikesAllowed()); lhs.setFareId(rhs.getFareId()); return lhs; }
public String toString() { return "<Trip " + getId() + ">"; }
public String toString() { return "<Trip " + getId() + ">"; }
@Override public int compare(Trip o1, Trip o2) { Integer st1 = _averageArrivalTimesByTrip.get(o1); Integer st2 = _averageArrivalTimesByTrip.get(o2); if (st1 == null && st2 == null) return o1.getId().compareTo(o2.getId()); else if (st1 == null) return 1; else if (st2 == null) return -1; else return st1.compareTo(st2); } }
private void warnOnMissingTrips() { for (Trip t : _gtfsMutableRelationalDao.getAllTrips()) { String blockId = t.getBlockId(); if (blockId == null || blockId.equals("")) { _log.warn("When matching GTFS to STIF, failed to find block in STIF for " + t.getId()); } } }
private AgencyAndId computeUpdatedTripIdForMergedTripsIfApplicable( Map<AgencyAndId, List<AgencyAndId>> mergeToolIdMapping, List<Trip> trips) { AgencyAndId unmergedTripId = null; for (Trip trip : trips) { AgencyAndId id = computeUnmergedTripId(trip.getId()); if (unmergedTripId == null) { unmergedTripId = id; } else if (!unmergedTripId.equals(id)) { return null; } } List<AgencyAndId> originalIds = mergeToolIdMapping.get(unmergedTripId); if (originalIds == null || originalIds.size() != trips.size()) return null; return unmergedTripId; }
private int[] getScheduleIntervalForTrip(GtfsRelationalDao dao, Trip trip) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); if (stopTimes.isEmpty()) { return null; } StopTime first = stopTimes.get(0); StopTime last = stopTimes.get(stopTimes.size() - 1); if (!first.isDepartureTimeSet() || !last.isArrivalTimeSet()) { throw new IllegalStateException( "expected departure time for first stop and arrival time for last stop to be set for trip with id " + trip.getId()); } int minTime = first.getDepartureTime(); int maxTime = last.getArrivalTime(); return new int[] {minTime, maxTime}; } }
private int[] getScheduleIntervalForTrip(GtfsRelationalDao dao, Trip trip) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); if (stopTimes.isEmpty()) { return null; } StopTime first = stopTimes.get(0); StopTime last = stopTimes.get(stopTimes.size() - 1); if (!first.isDepartureTimeSet() || !last.isArrivalTimeSet()) { throw new IllegalStateException( "expected departure time for first stop and arrival time for last stop to be set for trip with id " + trip.getId()); } int minTime = first.getDepartureTime(); int maxTime = last.getArrivalTime(); return new int[] {minTime, maxTime}; } }
public void generateTripNarratives(NarrativeProviderImpl provider) { int tripIndex = 0; Collection<Trip> trips = _gtfsDao.getAllTrips(); for (Trip trip : trips) { if (tripIndex % 200 == 0) { _log.info("trips=" + tripIndex + " of " + trips.size()); } tripIndex++; TripNarrative tripNarrative = getTripNarrative(trip); provider.setNarrativeForTripId(trip.getId(), tripNarrative); List<StopTime> stopTimes = _gtfsDao.getStopTimesForTrip(trip); int stopTimeIndex = 0; for (StopTime stopTime : stopTimes) { StopTimeNarrative stopTimeNarrative = getStopTimeNarrative(stopTime); provider.setNarrativeForStopTimeEntry(trip.getId(), stopTimeIndex++, stopTimeNarrative); } } }
public TraverseResult traverse(State state0, TraverseOptions wo) { State state1 = state0.clone(); AgencyAndId tripId = state0.tripId; InterlineDwellData dwellData = tripIdToInterlineDwellData.get(tripId); if (dwellData == null) { return null; } state1.incrementTimeInSeconds(dwellData.dwellTime); state1.tripId = targetTrip.getId(); state1.setPattern(dwellData.patternIndex); return new TraverseResult(dwellData.dwellTime, state1); }
public TraverseResult traverseBack(State state0, TraverseOptions wo) { State state1 = state0.clone(); AgencyAndId tripId = state0.tripId; InterlineDwellData dwellData = reverseTripIdToInterlineDwellData.get(tripId); if (dwellData == null) { return null; } state1.incrementTimeInSeconds(-dwellData.dwellTime); state1.tripId = targetTrip.getId(); state1.setPattern(dwellData.patternIndex); return new TraverseResult(dwellData.dwellTime, state1); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary(); String agency = dao.getAllTrips().iterator().next().getId().getAgencyId(); //Merge route 5X into route 5, then remove route 5X Route routeFive = dao.getRouteForId(new AgencyAndId(agency, "5")); Route routeFiveX = dao.getRouteForId(new AgencyAndId(agency, "5X")); if (routeFive != null && routeFiveX != null) { for (Trip trip : dao.getTripsForRoute(routeFiveX)) { trip.setRoute(routeFive); } dao.removeEntity(routeFiveX); } } }
private Trip createTrip(GtfsMutableRelationalDao dao, Trip referenceTrip, Trip atisTrip) { Trip trip = new Trip(); trip.setRoute(atisTrip.getRoute()); trip.setId(referenceTrip.getId()); trip.setTripHeadsign(atisTrip.getTripHeadsign()); trip.setDirectionId(atisTrip.getDirectionId()); trip.setShapeId(atisTrip.getShapeId()); trip.setPeakOffpeak(atisTrip.getPeakOffpeak()); trip.setMtaTripId(referenceTrip.getId().getId()); dao.saveOrUpdateEntity(trip); //_log.info("Created new trip: {}", trip.getId().getId()); return trip; }
@Override public String toString() { return "StopTime(seq=" + getStopSequence() + " stop=" + getStop().getId() + " trip=" + getTrip().getId() + " times=" + StopTimeFieldMappingFactory.getSecondsAsString(getArrivalTime()) + "-" + StopTimeFieldMappingFactory.getSecondsAsString(getDepartureTime()) + ")"; } }
@Override public String toString() { return "StopTime(seq=" + getStopSequence() + " stop=" + (getStop() == null?"NuLl":getStop().getId()) + " trip=" + (getTrip() == null?"NuLl":getTrip().getId()) + " times=" + StopTimeFieldMappingFactory.getSecondsAsString(getArrivalTime()) + "-" + StopTimeFieldMappingFactory.getSecondsAsString(getDepartureTime()) + ")"; } }