Package com.google.transit.realtime.GtfsRealtime.TripUpdate

Examples of com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent


                            delay = 0;
                        } else {
                            long today = updateServiceDate.getAsDate(timeZone).getTime() / 1000;

                            if (update.hasArrival()) {
                                StopTimeEvent arrival = update.getArrival();
                                if (arrival.hasDelay()) {
                                    delay = arrival.getDelay();
                                    if (arrival.hasTime()) {
                                        newTimes.updateArrivalTime(i,
                                                (int) (arrival.getTime() - today));
                                    } else {
                                        newTimes.updateArrivalDelay(i, delay);
                                    }
                                } else if (arrival.hasTime()) {
                                    newTimes.updateArrivalTime(i,
                                            (int) (arrival.getTime() - today));
                                    delay = newTimes.getArrivalDelay(i);
                                } else {
                                    LOG.error("Arrival time at index {} is erroneous.", i);
                                    return false;
                                }
                            } else {
                                if (delay == null) {
                                    newTimes.updateArrivalTime(i, TripTimes.UNAVAILABLE);
                                } else {
                                    newTimes.updateArrivalDelay(i, delay);
                                }
                            }

                            if (update.hasDeparture()) {
                                StopTimeEvent departure = update.getDeparture();
                                if (departure.hasDelay()) {
                                    delay = departure.getDelay();
                                    if (departure.hasTime()) {
                                        newTimes.updateDepartureTime(i,
                                                (int) (departure.getTime() - today));
                                    } else {
                                        newTimes.updateDepartureDelay(i, delay);
                                    }
                                } else if (departure.hasTime()) {
                                    newTimes.updateDepartureTime(i,
                                            (int) (departure.getTime() - today));
                                    delay = newTimes.getDepartureDelay(i);
                                } else {
                                    LOG.error("Departure time at index {} is erroneous.", i);
                                    return false;
                                }
View Full Code Here


    if (!(stopTimeUpdate.hasArrival() || stopTimeUpdate.hasDeparture()))
      return false;

    boolean hasDelay = false;
    if (stopTimeUpdate.hasDeparture()) {
      StopTimeEvent departure = stopTimeUpdate.getDeparture();
      hasDelay |= departure.hasDelay();
      hasDelay |= departure.hasTime();
    }
    if (stopTimeUpdate.hasArrival()) {
      StopTimeEvent arrival = stopTimeUpdate.getArrival();
      hasDelay |= arrival.hasDelay();
      hasDelay |= arrival.hasTime();
    }
    return hasDelay;
  }
View Full Code Here

  private int getTimeForStopTimeUpdate(StopTimeUpdate stopTimeUpdate,
      long serviceDate) {
    long t = currentTime();
    if (stopTimeUpdate.hasArrival()) {
      StopTimeEvent arrival = stopTimeUpdate.getArrival();
      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();
      if (departure.hasTime()) {
        return (int) (departure.getTime() - serviceDate / 1000);
      }
      if (departure.hasDelay()) {
        return (int) ((t - serviceDate) / 1000 - departure.getDelay());
      }
    }
    throw new IllegalStateException(
        "expected at least an arrival or departure time or delay for update: "
            + stopTimeUpdate);
View Full Code Here

  private int computeArrivalTime(StopTimeEntry stopTime,
      StopTimeUpdate stopTimeUpdate, long serviceDate) {
    if (!stopTimeUpdate.hasArrival())
      return -1;
    StopTimeEvent arrival = stopTimeUpdate.getArrival();
    if (arrival.hasDelay())
      return stopTime.getArrivalTime() + arrival.getDelay();
    if (arrival.hasTime())
      return (int) (arrival.getTime() - serviceDate / 1000);
    throw new IllegalStateException(
        "expected arrival delay or time for stopTimeUpdate " + stopTimeUpdate);
  }
View Full Code Here

  private int computeDepartureTime(StopTimeEntry stopTime,
      StopTimeUpdate stopTimeUpdate, long serviceDate) {
    if (!stopTimeUpdate.hasDeparture())
      return -1;
    StopTimeEvent departure = stopTimeUpdate.getDeparture();
    if (departure.hasDelay())
      return stopTime.getDepartureTime() + departure.getDelay();
    if (departure.hasTime())
      return (int) (departure.getTime() - serviceDate / 1000);
    throw new IllegalStateException(
        "expected departure delay or time for stopTimeUpdate " + stopTimeUpdate);
  }
View Full Code Here

TOP

Related Classes of com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.