Package org.onebusaway.transit_data_federation.services.realtime

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


  private boolean isArrivalAndDeparturePairInRange(
      ArrivalAndDepartureInstance instanceFrom,
      ArrivalAndDepartureInstance instanceTo, Date timeFrom, Date timeTo,
      boolean findDepartures) {

    ArrivalAndDepartureInstance instance = findDepartures ? instanceFrom
        : instanceTo;

    if (timeFrom != null) {
      boolean schedInRange = instance.getScheduledDepartureTime() >= timeFrom.getTime();
      boolean realTimeInRange = true;
      if (instance.isPredictedDepartureTimeSet())
        realTimeInRange = instance.getPredictedDepartureTime() >= timeFrom.getTime();
      if (!(schedInRange || realTimeInRange))
        return false;
    }

    if (timeTo != null) {
      boolean schedInRange = instance.getScheduledArrivalTime() <= timeTo.getTime();
      boolean realTimeInRange = true;
      if (instance.isPredictedArrivalTimeSet())
        realTimeInRange = instance.getPredictedArrivalTime() <= timeTo.getTime();
      if (!(schedInRange || realTimeInRange))
        return false;
    }

    return true;
View Full Code Here


  }

  private ArrivalAndDepartureInstance createArrivalAndDepartureForStopTimeInstance(
      StopTimeInstance sti, long prevFrequencyTime) {

    ArrivalAndDepartureInstance instance = createArrivalAndDeparture(sti,
        prevFrequencyTime, sti.getFrequencyOffset());

    instance.setBlockSequence(sti.getBlockSequence());

    return instance;
  }
View Full Code Here

      int frequencyOffset) {

    ArrivalAndDepartureTime scheduledTime = getScheduledTime(stopTimeInstance,
        prevFrequencyTime, frequencyOffset);

    return new ArrivalAndDepartureInstance(stopTimeInstance, scheduledTime);
  }
View Full Code Here

        query.setTrip(trip);
        query.setServiceDate(record.getServiceDate());
        query.setVehicleId(vehicleId);
        query.setTime(record.getTime());

        ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);

        if (instance != null) {
          StopTimeInstance sti = instance.getStopTimeInstance();
          StopTimeInstanceBean stopTimeBean = _stopTimeBeanService.getStopTimeInstanceAsBean(sti);
          bean.setStopTime(stopTimeBean);
        }
      }
    }
View Full Code Here

    long stopTimeFrom = t - minutesBefore * 60 * 1000;
    long stopTimeTo = t + minutesAfter * 60 * 1000;

    StopTimeInstance sti1 = new StopTimeInstance(bstAB,blockInstanceA.getState());
    ArrivalAndDepartureInstance in1 = new ArrivalAndDepartureInstance(sti1);
    in1.setBlockLocation(blockLocationA);
    in1.setPredictedArrivalTime((long) (in1.getScheduledArrivalTime() + 5 * 60 * 1000));
    in1.setPredictedDepartureTime((long) (in1.getScheduledDepartureTime()));

    StopTimeInstance sti2 = new StopTimeInstance(bstBB, blockInstanceB.getState());
    ArrivalAndDepartureInstance in2 = new ArrivalAndDepartureInstance(sti2);
    in2.setBlockLocation(blockLocationB);

    TargetTime target = new TargetTime(t, t);

    Mockito.when(
        _arrivalAndDepartureService.getArrivalsAndDeparturesForStopInTimeRange(
View Full Code Here

  @Override
  public AgencyAndId registerAlarmForArrivalAndDepartureAtStop(
      ArrivalAndDepartureQuery query, RegisterAlarmQueryBean alarmBean) {

    ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);

    if (instance == null)
      throw new ServiceException("no arrival-departure found");

    /**
     * We group alarms by block instance
     */
    BlockInstance blockInstance = instance.getBlockInstance();

    /**
     * Retrieve the alarms for the block instance
     */
    AlarmsForBlockInstance alarms = getAlarmsForBlockInstance(blockInstance);
View Full Code Here

        long duration = Math.abs(state.getTime() - time) - initialWaitTime;
        if (!results.containsKey(stop) || results.get(stop) > duration)
          results.put(stop, duration);
      } else if (v instanceof AbstractBlockVertex) {
        AbstractBlockVertex blockVertex = (AbstractBlockVertex) v;
        ArrivalAndDepartureInstance instance = blockVertex.getInstance();
        StopEntry stop = instance.getStop();
        long initialWaitTime = obaState.getInitialWaitTime();
        long duration = Math.abs(state.getTime() - time) - initialWaitTime;
        if (!results.containsKey(stop) || results.get(stop) > duration)
          results.put(stop, duration);
      }
View Full Code Here

          ArrivalVertex fromStopVertex = (ArrivalVertex) vFrom;
          StopEntry fromStop = fromStopVertex.getStop();

          BlockDepartureVertex toStopVertex = (BlockDepartureVertex) vTo;
          ArrivalAndDepartureInstance departureInstance = toStopVertex.getInstance();
          StopEntry toStop = departureInstance.getStop();

          addTransferLegIfNeeded(state, fromStop, toStop, options, legs);
        }
      } else if (edge instanceof TPTransferEdge) {
View Full Code Here

  private TransitLegBuilder extendTransitLegWithDepartureAndArrival(
      List<LegBean> legs, TransitLegBuilder builder,
      BlockDepartureVertex vFrom, BlockArrivalVertex vTo) {

    ArrivalAndDepartureInstance from = vFrom.getInstance();
    ArrivalAndDepartureInstance to = vTo.getInstance();

    return extendTransitLegWithDepartureAndArrival(legs, builder, from, to);
  }
View Full Code Here

  private TransitLegBuilder extendTransitLegWithTPDepartureAndArrival(
      List<LegBean> legs, TransitLegBuilder builder,
      TPBlockDepartureVertex vFrom, TPBlockArrivalVertex vTo) {

    ArrivalAndDepartureInstance from = vFrom.getDeparture();
    ArrivalAndDepartureInstance to = vFrom.getArrival();

    builder = extendTransitLegWithDepartureAndArrival(legs, builder, from, to);

    return getTransitLegBuilderAsLeg(builder, legs);
  }
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.