Package org.onebusaway.transit_data_federation.services.realtime

Examples of org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance


      /**
       * For now, we skip real-time arrival that might have been included that
       * are beyond our range (ex. vehicle running late)
       */
      ArrivalAndDepartureInstance arrival = pair.getSecond();
      if (arrival.getBestArrivalTime() > s0.getTime())
        break;

      Vertex fromV = new TPBlockArrivalVertex(_context, _pathState,
          pair.getFirst(), pair.getSecond());

      EdgeNarrative narrative = narrative(s0, fromV, toV);

      OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);

      int dwellTime = computeWaitTime(s0, pair);
      edit.incrementTimeInSeconds(-dwellTime);

      double w = ItineraryWeightingLibrary.computeWeightForWait(s0, dwellTime);
      edit.incrementWeight(w);

      if (arrival.getBlockSequence() != null)
        edit.appendTripSequence(arrival.getBlockSequence());
      else
        edit.appendTripSequence(arrival.getBlockTrip());

      State s1 = edit.makeState();
      results = s1.addToExistingResultChain(results);
    }

View Full Code Here


    State results = null;

    for (Pair<ArrivalAndDepartureInstance> pair : instances) {

      ArrivalAndDepartureInstance departure = pair.getFirst();
      if (departure.getBestDepartureTime() < s0.getTime()
          - query.getLookaheadTime() * 1000)
        continue;

      Vertex toV = new TPBlockDepartureVertex(_context, _pathState, departure,
          pair.getSecond());

      int dwellTime = computeWaitTime(s0, pair);

      double w = ItineraryWeightingLibrary.computeWeightForWait(s0, dwellTime);

      EdgeNarrative narrative = narrative(s0, fromV, toV);
      OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);
      edit.setTime(departure.getBestDepartureTime());
      edit.incrementWeight(w);

      /**
       * If the departure time is less than the starting state time, it must
       * mean the departure was included as determined by the lookahead
       * parameter. Thus, we indicate that we have a lookahead itinerary.
       */
      if (departure.getBestDepartureTime() < s0.getTime())
        edit.setLookaheadItinerary();

      if (departure.getBlockSequence() != null)
        edit.appendTripSequence(departure.getBlockSequence());
      else
        edit.appendTripSequence(departure.getBlockTrip());

      State s1 = edit.makeState();
      results = s1.addToExistingResultChain(results);
    }

View Full Code Here

    for (StopTimeInstance sti : stis) {

      BlockInstance blockInstance = sti.getBlockInstance();

      ArrivalAndDepartureInstance instance = createArrivalAndDepartureForStopTimeInstance(
          sti, prevFrequencyTime);

      if (sti.getFrequency() == null) {

        /**
 
View Full Code Here

        stop, time, includePrivateService);

    List<ArrivalAndDepartureInstance> instances = new ArrayList<ArrivalAndDepartureInstance>();

    for (StopTimeInstance sti : stopTimes) {
      ArrivalAndDepartureInstance instance = createArrivalAndDepartureForStopTimeInstance(
          sti, time);
      instances.add(instance);
    }

    return instances;
View Full Code Here

    BlockInstance blockInstance = entry.getKey();
    List<BlockLocation> locations = entry.getValue();

    int timeOfServiceDate = (int) ((time - serviceDate) / 1000);

    ArrivalAndDepartureInstance instance = createArrivalAndDeparture(
        blockInstance, trip.getId(), stop.getId(), stopSequence, serviceDate,
        timeOfServiceDate, time);

    if (!locations.isEmpty()) {
View Full Code Here

      scheduledTime.setDepartureTime(scheduledDepartureTime);
    }

    StopTimeInstance prevStopTimeInstance = new StopTimeInstance(prevStopTime,
        state);
    ArrivalAndDepartureInstance prevInstance = new ArrivalAndDepartureInstance(
        prevStopTimeInstance, scheduledTime);

    if (instance.isPredictedArrivalTimeSet()) {

      int scheduledDeviation = (int) ((instance.getPredictedArrivalTime() - instance.getScheduledArrivalTime()) / 1000);

      int departureDeviation = propagateScheduleDeviationBackwardBetweenStops(
          prevStopTime, stopTime, scheduledDeviation);
      int arrivalDeviation = propagateScheduleDeviationBackwardAcrossStop(
          prevStopTime, departureDeviation);

      setPredictedArrivalTimeForInstance(prevInstance,
          prevInstance.getScheduledArrivalTime() + arrivalDeviation * 1000);
      setPredictedDepartureTimeForInstance(prevInstance,
          prevInstance.getScheduledDepartureTime() + departureDeviation * 1000);
    }

    return prevInstance;
  }
View Full Code Here

      scheduledTime.setDepartureTime(scheduledDepartureTime);
    }

    StopTimeInstance nextStopTimeInstance = new StopTimeInstance(stopTime,
        state);
    ArrivalAndDepartureInstance nextInstance = new ArrivalAndDepartureInstance(
        nextStopTimeInstance, scheduledTime);

    if (instance.isPredictedDepartureTimeSet()) {

      int scheduledDeviation = (int) ((instance.getPredictedDepartureTime() - instance.getScheduledDepartureTime()) / 1000);

      int arrivalDeviation = propagateScheduleDeviationForwardBetweenStops(
          stopTime, nextStopTime, scheduledDeviation);
      int departureDeviation = propagateScheduleDeviationForwardAcrossStop(
          nextStopTime, arrivalDeviation);

      setPredictedArrivalTimeForInstance(nextInstance,
          nextInstance.getScheduledArrivalTime() + arrivalDeviation * 1000);
      setPredictedDepartureTimeForInstance(nextInstance,
          nextInstance.getScheduledDepartureTime() + departureDeviation * 1000);
    }

    return nextInstance;
  }
View Full Code Here

        StopTimeInstance nextStopTimeInstance = new StopTimeInstance(
            nextBlockStopTime, state);
        ArrivalAndDepartureTime nextScheduledTime = ArrivalAndDepartureTime.getScheduledTime(
            state, nextBlockStopTime);

        ArrivalAndDepartureInstance nextInstance = new ArrivalAndDepartureInstance(
            nextStopTimeInstance, nextScheduledTime);

        if (state.getFrequency() != null) {

          int betweenStopDelta = nextStopTime.getArrivalTime()
              - blockStopTime.getStopTime().getDepartureTime();
          int atStopDelta = nextStopTime.getDepartureTime()
              - nextStopTime.getArrivalTime();

          long scheduledArrivalTime = instance.getScheduledDepartureTime()
              + betweenStopDelta * 1000;
          long scheduledDepartureTime = scheduledArrivalTime + atStopDelta
              * 1000;

          nextInstance.setScheduledArrivalTime(scheduledArrivalTime);
          nextInstance.setScheduledDepartureTime(scheduledDepartureTime);
        }

        return nextInstance;
      }

View Full Code Here

      long frequencyOffsetTime, BlockInstance blockInstance,
      List<BlockLocation> locations, List<ArrivalAndDepartureInstance> results) {

    for (BlockLocation location : locations) {

      ArrivalAndDepartureInstance instance = createArrivalAndDepartureForStopTimeInstance(
          sti, frequencyOffsetTime);
      applyBlockLocationToInstance(instance, location,
          targetTime.getTargetTime());

      if (isArrivalAndDepartureBeanInRange(instance, fromTime, toTime))
        results.add(instance);
    }

    if (locations.isEmpty()) {

      ArrivalAndDepartureInstance instance = createArrivalAndDepartureForStopTimeInstance(
          sti, frequencyOffsetTime);

      if (sti.getFrequency() == null) {

        /**
 
View Full Code Here

      List<Pair<ArrivalAndDepartureInstance>> results, boolean findDepartures,
      boolean fillBlockLocations) {

    if (CollectionsLibrary.isEmpty(locations)) {

      ArrivalAndDepartureInstance instanceFrom = createArrivalAndDepartureForStopTimeInstance(
          stiFrom, frequencyOffsetTime);
      ArrivalAndDepartureInstance instanceTo = createArrivalAndDepartureForStopTimeInstance(
          stiTo, frequencyOffsetTime);

      /**
       * We don't need to get the scheduled location of a vehicle unless its in
       * our arrival window
       */
      if (isArrivalAndDeparturePairInRange(instanceFrom, instanceTo, fromTime,
          toTime, findDepartures)) {

        if (fillBlockLocations) {
          BlockLocation scheduledLocation = _blockLocationService.getScheduledLocationForBlockInstance(
              blockInstance, targetTime.getTargetTime());

          if (scheduledLocation != null) {
            applyBlockLocationToInstance(instanceFrom, scheduledLocation,
                targetTime.getTargetTime());
            applyBlockLocationToInstance(instanceTo, scheduledLocation,
                targetTime.getTargetTime());
          }
        }

        results.add(Tuples.pair(instanceFrom, instanceTo));
      }

    } else {

      for (BlockLocation location : locations) {

        ArrivalAndDepartureInstance instanceFrom = createArrivalAndDepartureForStopTimeInstance(
            stiFrom, frequencyOffsetTime);
        ArrivalAndDepartureInstance instanceTo = createArrivalAndDepartureForStopTimeInstance(
            stiTo, frequencyOffsetTime);

        applyBlockLocationToInstance(instanceFrom, location,
            targetTime.getTargetTime());
        applyBlockLocationToInstance(instanceTo, location,
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance

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.