private StopTime doMap(org.onebusaway.gtfs.model.StopTime rhs) { StopTime lhs = new StopTime(); lhs.setTrip(tripMapper.map(rhs.getTrip())); lhs.setStop(stopMapper.map(rhs.getStop())); lhs.setArrivalTime(rhs.getArrivalTime()); lhs.setDepartureTime(rhs.getDepartureTime()); lhs.setTimepoint(rhs.getTimepoint()); lhs.setStopSequence(rhs.getStopSequence()); lhs.setStopHeadsign(rhs.getStopHeadsign()); lhs.setRouteShortName(rhs.getRouteShortName()); lhs.setPickupType(rhs.getPickupType()); lhs.setDropOffType(rhs.getDropOffType()); lhs.setShapeDistTraveled(rhs.getShapeDistTraveled()); lhs.setFarePeriodId(rhs.getFarePeriodId()); // Skip mapping of proxy // private transient StopTimeProxy proxy; if (rhs.getProxy() != null) { throw new IllegalStateException("Did not expect proxy to be set!"); } return lhs; }
public TripWithStartTime(Trip trip) { this.trip = trip; List<StopTime> stopTimes = _gtfsMutableRelationalDao.getStopTimesForTrip(trip); startTime = stopTimes.get(0).getDepartureTime(); }
private Date getServiceDate(long currentTime, boolean useArrival) { int scheduleTime = useArrival ? hop.getEndStopTime().getArrivalTime() : hop .getStartStopTime().getDepartureTime(); Calendar c = Calendar.getInstance(); c.setTimeInMillis(currentTime); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); int dayOverflow = scheduleTime / SECS_IN_DAY; c.add(Calendar.DAY_OF_YEAR, -dayOverflow); return c.getTime(); } }
private Date getServiceDate(long currentTime, boolean useArrival) { int scheduleTime = useArrival ? hop.getEndStopTime().getArrivalTime() : hop .getStartStopTime().getDepartureTime(); Calendar c = Calendar.getInstance(); c.setTimeInMillis(currentTime); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); int dayOverflow = scheduleTime / Board.SECS_IN_DAY; c.add(Calendar.DAY_OF_YEAR, -dayOverflow); return c.getTime(); } }
private int getMinStopTime(List<StopTime> stopTimes) { int minTime = Integer.MAX_VALUE; for (StopTime stopTime : stopTimes) { if (stopTime.isArrivalTimeSet()) { minTime = Math.min(minTime, stopTime.getArrivalTime()); } if (stopTime.isDepartureTimeSet()) { minTime = Math.min(minTime, stopTime.getDepartureTime()); } } return minTime; }
public static TripKey getTripKeyForTrip(GtfsMutableRelationalDao dao, Trip trip) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); Stop[] stops = new Stop[stopTimes.size()]; int[] arrivalTimes = new int[stopTimes.size()]; int[] departureTimes = new int[stopTimes.size()]; for (int i = 0; i < stopTimes.size(); i++) { StopTime stopTime = stopTimes.get(i); stops[i] = stopTime.getStop(); arrivalTimes[i] = stopTime.getArrivalTime(); departureTimes[i] = stopTime.getDepartureTime(); } return new TripKey(stops, arrivalTimes, departureTimes); }
private int calculateMaxStopTime() { Set<Integer> times = new HashSet<Integer>(); for (StopTime st : _dao.getAllStopTimes()) { if (st.isArrivalTimeSet()) { times.add(st.getArrivalTime()); } if (st.isDepartureTimeSet()) { times.add(st.getDepartureTime()); } } return Collections.max(times); } }
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 static StopSequencePattern getPatternForStopTimes(List<StopTime> stopTimes) { 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 StopSequencePattern(stopIds, arrivalTimes, departureTimes); } }
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 shiftStopTimes(List<StopTime> stopTimes, int time) { for (StopTime stopTime : stopTimes) { if (stopTime.isArrivalTimeSet()) { stopTime.setArrivalTime(stopTime.getArrivalTime() + time); } if (stopTime.isDepartureTimeSet()) { stopTime.setDepartureTime(stopTime.getDepartureTime() + time); } } }
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); }
public TraverseResult traverse(State state0, TraverseOptions wo) { if (!wo.modes.contains(hop.getMode())) { return null; } if (wo.wheelchairAccessible && !wheelchairAccessible) { return null; } long currentTime = state0.getTime(); Date serviceDate = getServiceDate(currentTime, false); int secondsSinceMidnight = (int) ((currentTime - serviceDate.getTime()) / 1000); CalendarService service = wo.getCalendarService(); Set<ServiceDate> serviceDates = service.getServiceDatesForServiceId(hop.getServiceId()); if (!serviceDates.contains(serviceDate)) return null; int wait = hop.getStartStopTime().getDepartureTime() - secondsSinceMidnight; if (wait < 0) { return null; } State state1 = state0.clone(); state1.incrementTimeInSeconds(-wait); return new TraverseResult(wait, state1); }
@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()) + ")"; } }
/**** * {@link Collection} Interface ****/ @Override public boolean add(StopTime stopTime) { int index = size; size++; ensureCapacity(size); trips[index] = stopTime.getTrip(); stops[index] = stopTime.getStop(); arrivalTimes[index] = stopTime.getArrivalTime(); departureTimes[index] = stopTime.getDepartureTime(); timepoints[index] = stopTime.getTimepoint(); stopSequences[index] = stopTime.getStopSequence(); stopHeadsigns[index] = stopTime.getStopHeadsign(); routeShortNames[index] = stopTime.getRouteShortName(); pickupTypes[index] = stopTime.getPickupType(); dropOffTypes[index] = stopTime.getDropOffType(); shapeDistTraveled[index] = stopTime.getShapeDistTraveled(); return true; }
/**** * {@link Collection} Interface ****/ @Override public boolean add(StopTime stopTime) { int index = size; size++; ensureCapacity(size); trips[index] = stopTime.getTrip(); stops[index] = stopTime.getStop(); arrivalTimes[index] = stopTime.getArrivalTime(); departureTimes[index] = stopTime.getDepartureTime(); timepoints[index] = stopTime.getTimepoint(); stopSequences[index] = stopTime.getStopSequence(); stopHeadsigns[index] = stopTime.getStopHeadsign(); routeShortNames[index] = stopTime.getRouteShortName(); pickupTypes[index] = stopTime.getPickupType(); dropOffTypes[index] = stopTime.getDropOffType(); shapeDistTraveled[index] = stopTime.getShapeDistTraveled(); return true; }
private StopTime cloneStopTime(StopTime original) { StopTime anew = new StopTime(); anew.setTrip(original.getTrip()); anew.setStopSequence(original.getStopSequence()); anew.setStopHeadsign(original.getStopHeadsign()); anew.setStop(original.getStop()); anew.setRouteShortName(original.getRouteShortName()); anew.setPickupType(original.getPickupType()); anew.setId(original.getId()); anew.setDropOffType(original.getDropOffType()); if(original.isShapeDistTraveledSet()) anew.setShapeDistTraveled(original.getShapeDistTraveled()); if(original.isArrivalTimeSet()) anew.setArrivalTime(original.getArrivalTime()); if(original.isDepartureTimeSet()) anew.setDepartureTime(original.getDepartureTime()); return anew; } }