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; } }
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; }
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 boolean isNonRevenue (StopTime s){ return (s.getDropOffType() ==1 && s.getPickupType() ==1); } }
boolean hasDeparture = stopTime.isDepartureTimeSet(); boolean hasArrival = stopTime.isArrivalTimeSet(); int departureTime = stopTime.getDepartureTime(); int arrivalTime = stopTime.getArrivalTime(); throw new IllegalStateException( "departure time is less than arrival time for stop time with trip_id=" + stopTime.getTrip().getId() + " stop_sequence=" + stopTime.getStopSequence()); Stop prevStop = prevStopTime.getStop(); Stop stop = stopTime.getStop(); + prevStopTime.getId() + " stopTimeB=" + stopTime.getId()); arrivalTimes[i] = departureTimes[i - 1]; if (departureTimes[i] < arrivalTimes[i]) for (int x = 0; x < stopTimes.size(); x++) { StopTime st = stopTimes.get(x); System.err.println(x + " " + st.getId() + " " + arrivalTimes[x] + " " + departureTimes[x]); + stopTime.getTrip().getId() + " stop_sequence=" + stopTime.getStopSequence());
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); } }
@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()) + ")"; } }
StopTime st = new StopTime(); st.setTrip(sdonAtisTrip); st.setStop(stopTime.getStop()); st.setArrivalTime(stopTime.getArrivalTime()); st.setDepartureTime(stopTime.getDepartureTime()); st.setStopSequence(stopTime.getStopSequence()); st.setDropOffType(stopTime.getDropOffType()); st.setDepartureBuffer(stopTime.getDepartureBuffer()); dao.saveOrUpdateEntity(st);
private List<StopTimeEntryImpl> createInitialStopTimeEntries( TransitGraphImpl graph, List<StopTime> stopTimes) { List<StopTimeEntryImpl> stopTimeEntries = new ArrayList<StopTimeEntryImpl>( stopTimes.size()); int sequence = 0; for (StopTime stopTime : stopTimes) { Stop stop = stopTime.getStop(); AgencyAndId stopId = stop.getId(); StopEntryImpl stopEntry = graph.getStopEntryForId(stopId); StopTimeEntryImpl stopTimeEntry = new StopTimeEntryImpl(); stopTimeEntry.setId(stopTime.getId()); stopTimeEntry.setSequence(sequence); stopTimeEntry.setGtfsSequence(stopTime.getStopSequence()); stopTimeEntry.setDropOffType(stopTime.getDropOffType()); stopTimeEntry.setPickupType(stopTime.getPickupType()); stopTimeEntry.setStop(stopEntry); stopTimeEntries.add(stopTimeEntry); sequence++; } return stopTimeEntries; }
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; }
for(Frequency freq : frequencies) { for(int i = freq.getStartTime(); i < freq.getEndTime(); i += freq.getHeadwaySecs()) { int diff = i - originalStopTimes.get(0).getArrivalTime(); List<StopTime> newStopTimes = new ArrayList<StopTime>(); if(st.isArrivalTimeSet()) modified.setArrivalTime(st.getArrivalTime() + diff); if(st.isDepartureTimeSet()) modified.setDepartureTime(st.getDepartureTime() + diff); newStopTimes.add(modified); .getDepartureTime()); if (insertionPoint < 0) { StopTime st0 = stopTimes.get(i); st1 = stopTimes.get(i + 1); int dwellTime = st0.getDepartureTime() - st0.getArrivalTime(); int runningTime = st1.getArrivalTime() - st0.getDepartureTime(); try { tripPattern.addHop(i, insertionPoint, st0.getDepartureTime(), runningTime, st1.getArrivalTime(), dwellTime, trip); } catch (TripOvertakingException e) { List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip); StopTime lastStopTime = stopTimes.get(stopTimes.size() - 1); Stop lastStop = lastStopTime.getStop(); TreeSet<EncodedTrip> possiblePosts = null; if (blockStops.containsKey(lastStop)) {
if (stopTime != null && stopTime.getStop() != null && stopTime.getStop().getId() != null) { newStopTimes.add(stopTime); } else { _log.error("found stopTime without a stop id for tripEntry=" + tripEntry + "(" + (stopTime.getTrip() == null?"NuLl":stopTime.getTrip().getId()) +")" + "; stop=" + stopTime.getStopHeadsign() + ":" + stopTime.getArrivalTime() + ":" + stopTime.getDepartureTime() + ":" + stopTime.getRouteShortName() + "; route=" + (tripEntry.getRoute() == null?"NuLl":tripEntry.getRoute().getId()) + "; blockId=" + (tripEntry.getBlock() == null?"NuLl":tripEntry.getBlock().getId()) + "; stop=" + (stopTime.getStop() == null?"NuLl":stopTime.getId() + ":" + stopTime.getRouteShortName()));
stopTimePosition++; 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.getDepartureTime() + " stop=" + stopTime.getArrivalTime() + " deviation=" + deviation + " for stopTime " + stopTime + " of trip" + trip + " at " + stopTimePosition + "/" + stopTimes.size()); stopTime.setArrivalTime(prev.getDepartureTime()); if (stopTime.getDepartureTime() < stopTime.getArrivalTime()) stopTime.setDepartureTime(stopTime.getArrivalTime());
boolean hasDeparture = stopTime.isDepartureTimeSet(); boolean hasArrival = stopTime.isArrivalTimeSet(); int departureTime = stopTime.getDepartureTime(); int arrivalTime = stopTime.getArrivalTime(); Stop prevStop = prevStopTime.getStop(); Stop stop = stopTime.getStop(); + prevStopTime.getId() + " stopTimeB=" + stopTime.getId()); arrivalTimes[i] = departureTimes[i - 1]; if (departureTimes[i] < arrivalTimes[i]) for (int x = 0; x < stopTimes.size(); x++) { StopTime st = stopTimes.get(x); System.err.println(x + " " + st.getId() + " " + arrivalTimes[x] + " " + departureTimes[x]);
if (lastUnmodifiedStopTime.isArrivalTimeSet() && stopTime.isArrivalTimeSet()) { if (stopTime.getArrivalTime() == lastUnmodifiedStopTime.getArrivalTime()) { stopTime.clearArrivalTime(); stopTimeWasModified = true; if (lastUnmodifiedStopTime.isDepartureTimeSet() && stopTime.isDepartureTimeSet()) { if (stopTime.getDepartureTime() == lastUnmodifiedStopTime.getDepartureTime()) { stopTime.clearDepartureTime(); stopTimeWasModified = true;
public Stop getStartStop() { return start.getStop(); }
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(); } }
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 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; }
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; }