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; }
@Override public Object invoke(Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return _dao.getCalendarForServiceId(((Trip) value).getServiceId()); } }
public Map<Set<AgencyAndId>, List<TripKey>> groupTripKeysByServiceIds( Map<TripKey, List<Trip>> tripsByKey) { Map<Set<AgencyAndId>, List<TripKey>> tripKeysByServiceIds = new FactoryMap<Set<AgencyAndId>, List<TripKey>>( new ArrayList<TripKey>()); for (Map.Entry<TripKey, List<Trip>> entry : tripsByKey.entrySet()) { TripKey key = entry.getKey(); List<Trip> tripsForKey = entry.getValue(); Set<AgencyAndId> serviceIds = new HashSet<AgencyAndId>(); for (Trip trip : tripsForKey) { serviceIds.add(trip.getServiceId()); } tripKeysByServiceIds.get(serviceIds).add(key); } return tripKeysByServiceIds; }
public static StopPattern stopPatternfromTrip(Trip trip, GtfsRelationalDao dao) { Vector<Stop> stops = new Vector<Stop>(); Vector<Boolean> pickups = new Vector<Boolean>(); Vector<Boolean> dropoffs = new Vector<Boolean>(); for (StopTime stoptime : dao.getStopTimesForTrip(trip)) { stops.add(stoptime.getStop()); pickups.add(stoptime.getPickupType() != 1); dropoffs.add(stoptime.getDropOffType() != 1); } StopPattern pattern = new StopPattern(stops, pickups, dropoffs, trip.getServiceId()); return pattern; }
BlockTask(Trip t) { this.route = t.getRoute(); this.cal = _dao.getCalendarForServiceId(t.getServiceId()); }
@Override public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) { if (_tripAgencyIdsByServiceId == null) { Map<AgencyAndId, Set<String>> agencyIdsByServiceIds = new HashMap<AgencyAndId, Set<String>>(); for (Trip trip : getAllTrips()) { AgencyAndId tripId = trip.getId(); String tripAgencyId = tripId.getAgencyId(); AgencyAndId tripServiceId = trip.getServiceId(); Set<String> agencyIds = agencyIdsByServiceIds.get(tripServiceId); if (agencyIds == null) { agencyIds = new HashSet<String>(); agencyIdsByServiceIds.put(tripServiceId, agencyIds); } agencyIds.add(tripAgencyId); } _tripAgencyIdsByServiceId = new HashMap<AgencyAndId, List<String>>(); for (Map.Entry<AgencyAndId, Set<String>> entry : agencyIdsByServiceIds.entrySet()) { AgencyAndId tripServiceId = entry.getKey(); List<String> agencyIds = new ArrayList<String>(entry.getValue()); Collections.sort(agencyIds); _tripAgencyIdsByServiceId.put(tripServiceId, agencyIds); } } List<String> agencyIds = _tripAgencyIdsByServiceId.get(serviceId); if (agencyIds == null) agencyIds = new ArrayList<String>(); return agencyIds; }
@Override public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) { if (_tripAgencyIdsByServiceId == null) { Map<AgencyAndId, Set<String>> agencyIdsByServiceIds = new HashMap<AgencyAndId, Set<String>>(); for (Trip trip : getAllTrips()) { AgencyAndId tripId = trip.getId(); String tripAgencyId = tripId.getAgencyId(); AgencyAndId tripServiceId = trip.getServiceId(); Set<String> agencyIds = agencyIdsByServiceIds.get(tripServiceId); if (agencyIds == null) { agencyIds = new HashSet<String>(); agencyIdsByServiceIds.put(tripServiceId, agencyIds); } agencyIds.add(tripAgencyId); } _tripAgencyIdsByServiceId = new HashMap<AgencyAndId, List<String>>(); for (Map.Entry<AgencyAndId, Set<String>> entry : agencyIdsByServiceIds.entrySet()) { AgencyAndId tripServiceId = entry.getKey(); List<String> agencyIds = new ArrayList<String>(entry.getValue()); Collections.sort(agencyIds); _tripAgencyIdsByServiceId.put(tripServiceId, agencyIds); } } List<String> agencyIds = _tripAgencyIdsByServiceId.get(serviceId); if (agencyIds == null) agencyIds = new ArrayList<String>(); return agencyIds; }
public Dwell(Vertex startJourney, Vertex endJourney, StopTime stopTime) { super(startJourney, endJourney); this.stopTime = stopTime; this._serviceId = stopTime.getTrip().getServiceId(); this.elapsed = stopTime.getDepartureTime() - stopTime.getArrivalTime(); }
public Hop(Vertex startJourney, Vertex endJourney, StopTime start, StopTime end) { super(startJourney, endJourney); this.start = start; this.end = end; this._serviceId = start.getTrip().getServiceId(); this.elapsed = end.getArrivalTime() - start.getDepartureTime(); }
private void loadStifBlocks(StifTripLoader loader) { Map<Trip, RawRunData> rawData = loader.getRawRunDataByTrip(); for (Map.Entry<Trip, RawRunData> entry : rawData.entrySet()) { Trip trip = entry.getKey(); if (trip.getBlockId() == null || trip.getBlockId().length() == 0) { RawRunData data = entry.getValue(); trip.setBlockId(trip.getServiceId().getId() + "_STIF_" + data.getDepotCode() + "_" + data.getBlock()); _gtfsMutableRelationalDao.updateEntity(trip); } } }
AgencyAndId mappedServiceId = serviceIdMapping.get(trip.getServiceId()); if (mappedServiceId != null) { trip.setServiceId(mappedServiceId);
private Pattern getPatternForTrip(GtfsMutableRelationalDao dao, Trip trip) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); int n = stopTimes.size(); AgencyAndId[] stopIds = new AgencyAndId[n]; int[] arrivalTimes = new int[n]; int[] departureTimes = new int[n]; for (int i = 0; i < n; i++) { StopTime stopTime = stopTimes.get(i); stopIds[i] = stopTime.getStop().getId(); arrivalTimes[i] = stopTime.getArrivalTime(); departureTimes[i] = stopTime.getDepartureTime(); } return new Pattern(trip.getRoute().getId(), trip.getServiceId(), stopIds, arrivalTimes, departureTimes); }
if (!dao.getCalendarDatesForServiceId(trip.getServiceId()).isEmpty()) { for (ServiceCalendarDate calDate : dao.getCalendarDatesForServiceId(trip.getServiceId())) { Date date = removeTime(calDate.getDate().getAsDate()); if (date.equals(testDate)) { ServiceCalendar servCal = dao.getCalendarForServiceId(trip.getServiceId()); if (servCal != null) {
public Trip resolve(String departingTerminalId, long departureTime, String arrivingTerminalId) { ServiceDate initialServiceDate = new ServiceDate( new Date(departureTime * 1000)); int lookBackDays = (_maxStopTime / 86400) + 1; AgencyAndId stopId = new AgencyAndId(_agencyId, departingTerminalId); AgencyAndId routeId = new AgencyAndId(_agencyId, departingTerminalId + arrivingTerminalId); for (StopTime st : _dao.getAllStopTimes()) { if (st.getStop().getId().equals(stopId) && st.getTrip().getRoute().getId().equals(routeId)) { ServiceDate sd = initialServiceDate; for (int i = 0; i < lookBackDays; i++) { if (_csd.getServiceIdsForDate(sd).contains( st.getTrip().getServiceId()) && st.getDepartureTime() == (departureTime - (sd.getAsCalendar(_agencyTimeZone).getTimeInMillis() / 1000))) { return st.getTrip(); } sd = sd.previous(); } } } _log.warn("no trip found for resolve(departId=" + departingTerminalId + ", departureTime=" + departureTime + ", arrivalId=" + arrivingTerminalId + ")"); return null; }
for (Trip trip : dao.getTripsForRoute(route)) { for (ServiceCalendarDate calDate : dao.getCalendarDatesForServiceId(trip.getServiceId())) { reftriploop: for (Trip refTrip : reference.getTripsForRoute(refRoute)) { Set<ServiceDate> activeDates = refCalendarService.getServiceDatesForServiceId(refTrip.getServiceId()); if (activeDates.contains(sDate)) { _log.info("On {} Reference has service for this route but ATIS has none: {}", testDate, route.getId());
shiftStopTimes(stopTimes, dayShift * SECONDS_IN_DAY); ShiftedServiceCalendar shifted = new ShiftedServiceCalendar( trip.getServiceId(), -dayShift); shiftedIds.add(shifted); trip.setServiceId(shifted.getShiftedServiceId());
LocalizedServiceId lsid = new LocalizedServiceId(trip.getServiceId(), tz);
private TripEntryImpl processTrip(TransitGraphImpl graph, Trip trip) { List<StopTime> stopTimes = _gtfsDao.getStopTimesForTrip(trip); // A trip without stop times is a trip we don't care about if (stopTimes.isEmpty()) return null; ShapePoints shapePoints = null; if (trip.getShapeId() != null) shapePoints = _shapePointsHelper.getShapePointsForShapeId(trip.getShapeId()); Agency agency = trip.getRoute().getAgency(); TimeZone tz = TimeZone.getTimeZone(agency.getTimezone()); LocalizedServiceId lsid = new LocalizedServiceId(trip.getServiceId(), tz); TripEntryImpl tripEntry = new TripEntryImpl(); tripEntry.setId(trip.getId()); tripEntry.setDirectionId(unique(trip.getDirectionId())); tripEntry.setServiceId(unique(lsid)); // Only set the shape id for a trip if there are actually shape points to // back it up if (!(shapePoints == null || shapePoints.isEmpty())) tripEntry.setShapeId(unique(trip.getShapeId())); List<StopTimeEntryImpl> stopTimesForTrip = _stopTimeEntriesFactory.processStopTimes( graph, stopTimes, tripEntry, shapePoints); double tripDistance = getTripDistance(stopTimesForTrip, shapePoints); tripEntry.setTotalTripDistance(tripDistance); tripEntry.setStopTimes(cast(stopTimesForTrip)); graph.putTripEntry(tripEntry); return tripEntry; }
private TripEntryImpl processTrip(TransitGraphImpl graph, Trip trip) { List<StopTime> stopTimes = _gtfsDao.getStopTimesForTrip(trip); // A trip without stop times is a trip we don't care about if (stopTimes.isEmpty()) return null; ShapePoints shapePoints = null; if (trip.getShapeId() != null) shapePoints = _shapePointsService.getShapePointsForShapeId(trip.getShapeId()); Agency agency = trip.getRoute().getAgency(); TimeZone tz = TimeZone.getTimeZone(agency.getTimezone()); LocalizedServiceId lsid = new LocalizedServiceId(trip.getServiceId(), tz); TripEntryImpl tripEntry = new TripEntryImpl(); tripEntry.setId(trip.getId()); tripEntry.setRouteId(unique(trip.getRoute().getId())); tripEntry.setDirectionId(unique(trip.getDirectionId())); tripEntry.setServiceId(unique(lsid)); // Only set the shape id for a trip if there are actually shape points to // back it up if (!(shapePoints == null || shapePoints.isEmpty())) tripEntry.setShapeId(unique(trip.getShapeId())); List<StopTimeEntryImpl> stopTimesForTrip = _stopTimeEntriesFactory.processStopTimes( graph, stopTimes, tripEntry, shapePoints); double tripDistance = getTripDistance(stopTimesForTrip, shapePoints); tripEntry.setTotalTripDistance(tripDistance); tripEntry.setStopTimes(cast(stopTimesForTrip)); graph.putTripEntry(tripEntry); return tripEntry; }
private void retainTrip(Trip trip, boolean retainUp) { if (retainUp) { for (StopTime stopTime : _dao.getStopTimesForTrip(trip)) retainUp(stopTime); if (_retainBlocks && trip.getBlockId() != null) { AgencyAndId blockId = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); retainUp(new BlockIdKey(blockId)); } for (Frequency frequency : _dao.getFrequenciesForTrip(trip)) retainUp(frequency); } else { retainDown(trip.getRoute()); retainDown(new ServiceIdKey(trip.getServiceId())); AgencyAndId shapeId = trip.getShapeId(); if (shapeId != null && shapeId.hasValues()) retainDown(new ShapeIdKey(shapeId)); } }