use of com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent in project onebusaway-application-modules by camsys.
the class GtfsRealtimeTripLibrary method getTimeForStopTimeUpdate.
private int getTimeForStopTimeUpdate(StopTimeUpdate stopTimeUpdate, long serviceDate) {
long t = currentTime();
if (stopTimeUpdate.hasArrival()) {
StopTimeEvent arrival = stopTimeUpdate.getArrival();
// note that we prefer time over delay if both are present
if (arrival.hasTime()) {
return (int) (arrival.getTime() - serviceDate / 1000);
}
if (arrival.hasDelay()) {
return (int) ((t - serviceDate) / 1000 - arrival.getDelay());
}
}
if (stopTimeUpdate.hasDeparture()) {
StopTimeEvent departure = stopTimeUpdate.getDeparture();
// again we prefer time over delay if both are present
if (departure.hasTime())
return (int) (departure.getTime() - serviceDate / 1000);
if (departure.hasDelay()) {
return (int) ((t - serviceDate) / 1000 - departure.getDelay());
}
}
// instead of illegal state exception we return -1 to not corrupt the read
_log.debug("expected at least an arrival or departure time or delay for update: " + stopTimeUpdate);
return -1;
}
Aggregations