@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { Map<String, List<Trip>> tripsByBlockId = TripsByBlockInSortedOrder.getTripsByBlockInSortedOrder(dao); int hits = 0; int total = 0; int maxDeviation = 0; for (List<Trip> trips : tripsByBlockId.values()) { StopTime prev = null; for (Trip trip : trips) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); for (StopTime stopTime : stopTimes) { total++; if (prev != null) { if (prev.getDepartureTime() > stopTime.getArrivalTime()) { hits++; int deviation = prev.getDepartureTime() - stopTime.getArrivalTime(); maxDeviation = Math.max(maxDeviation, deviation); if (deviation > 60) _log.info( "out_of_order_stop_times: prev=" + prev + " next=" + stopTime + " deviation=" + deviation); stopTime.setArrivalTime(prev.getDepartureTime()); if (stopTime.getDepartureTime() < stopTime.getArrivalTime()) stopTime.setDepartureTime(stopTime.getArrivalTime()); } } prev = stopTime; } } } _log.info("stop times out of order: " + hits + "/" + total + " maxDeviation=" + maxDeviation); }
/** ** {@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; }