Package org.onebusaway.transit_data_federation.services.transit_graph

Examples of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry


  @Override
  public ArrivalAndDepartureInstance getPreviousStopArrivalAndDeparture(
      ArrivalAndDepartureInstance instance) {

    BlockStopTimeEntry stopTime = instance.getBlockStopTime();
    BlockTripEntry trip = stopTime.getTrip();
    BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
    List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();

    int index = stopTime.getBlockSequence() - 1;
    if (index < 0)
      return null;
View Full Code Here


  @Override
  public ArrivalAndDepartureInstance getNextStopArrivalAndDeparture(
      ArrivalAndDepartureInstance instance) {

    BlockStopTimeEntry stopTime = instance.getBlockStopTime();
    BlockTripEntry trip = stopTime.getTrip();
    BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
    List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();

    int index = stopTime.getBlockSequence() + 1;
    if (index >= stopTimes.size())
      return null;
View Full Code Here

  public static BlockTripInstance getBlockTripInstance(
      BlockInstance blockInstance, AgencyAndId tripId) {
    BlockConfigurationEntry blockConfig = blockInstance.getBlock();
    List<BlockTripEntry> blockTrips = blockConfig.getTrips();
    for (int i = 0; i < blockTrips.size(); ++i) {
      BlockTripEntry blockTrip = blockTrips.get(i);
      if (blockTrip.getTrip().getId().equals(tripId)) {
        return new BlockTripInstance(blockTrip, blockInstance.getState());
      }
    }
    return null;
  }
View Full Code Here

  @Override
  public ArrivalAndDepartureInstance getNextTransferStopArrivalAndDeparture(
      ArrivalAndDepartureInstance instance) {

    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    BlockTripEntry trip = blockStopTime.getTrip();
    BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
    List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();

    int index = blockStopTime.getBlockSequence() + 1;

    while (true) {
View Full Code Here

    Map<BlockInstance, List<StopTimeInstance>> r = new FactoryMap<BlockInstance, List<StopTimeInstance>>(
        new ArrayList<StopTimeInstance>());

    for (StopTimeInstance stopTime : stopTimes) {
      BlockStopTimeEntry blockStopTime = stopTime.getStopTime();
      BlockTripEntry blockTrip = blockStopTime.getTrip();
      BlockConfigurationEntry blockConfiguration = blockTrip.getBlockConfiguration();
      long serviceDate = stopTime.getServiceDate();
      BlockInstance blockInstance = new BlockInstance(blockConfiguration,
          serviceDate, stopTime.getFrequency());
      r.get(blockInstance).add(stopTime);
    }
View Full Code Here

    /**
     * We don't iterate over block stop times directly because there is
     * performance penalty with instantiating each. Also note that this will
     * currently miss the case where a stop is visited twice in the same trip.
     */
    BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
    TripEntry trip = blockTrip.getTrip();
    List<StopTimeEntry> stopTimes = trip.getStopTimes();

    if (stopSequence > -1) {

      /**
       * If a stop sequence has been specified, we start our search at the
       * specified index, expanding our search until we find the target stop. We
       * allow this flexibility in the case of a bookmarked arrival-departure
       * where the stop sequence has changed slightly due to the addition or
       * subtraction of a previous stop.
       */
      int offset = 0;
      while (true) {
        int before = stopSequence - offset;
        if (isMatch(stopTimes, stopId, before)) {
          return blockTrip.getStopTimes().get(before);
        }
        int after = stopSequence + offset;
        if (isMatch(stopTimes, stopId, after)) {
          return blockTrip.getStopTimes().get(after);
        }

        if (before < 0 && after >= stopTimes.size())
          return null;

        offset++;

      }
    } else {

      Min<BlockStopTimeEntry> m = new Min<BlockStopTimeEntry>();
      int index = 0;

      for (StopTimeEntry stopTime : stopTimes) {
        if (stopTime.getStop().getId().equals(stopId)) {
          int a = Math.abs(timeOfServiceDate - stopTime.getArrivalTime());
          int b = Math.abs(timeOfServiceDate - stopTime.getDepartureTime());
          int delta = Math.min(a, b);
          m.add(delta, blockTrip.getStopTimes().get(index));
        }
        index++;
      }

      if (m.isEmpty())
View Full Code Here

    ArrayList<BlockTripEntry> trips = new ArrayList<BlockTripEntry>();

    for (int i = 0; i < _trips.size(); i++) {

      BlockTripReference tripReference = _trips.get(i);
      BlockTripEntry blockTrip = ReferencesLibrary.getReferenceAsTrip(tripReference, dao);
      trips.add(blockTrip);
    }

    trips.trimToSize();
View Full Code Here

    bean.setScheduleDeviation(blockLocation.getScheduleDeviation());

    BlockTripInstance activeTripInstance = blockLocation.getActiveTripInstance();

    if (activeTripInstance != null) {
      BlockTripEntry activeBlockTrip = activeTripInstance.getBlockTrip();
      bean.setScheduledDistanceAlongTrip(blockLocation.getScheduledDistanceAlongBlock()
          - activeBlockTrip.getDistanceAlongBlock());
      bean.setDistanceAlongTrip(blockLocation.getDistanceAlongBlock()
          - activeBlockTrip.getDistanceAlongBlock());
      TripEntry activeTrip = activeBlockTrip.getTrip();
      bean.setTotalDistanceAlongTrip(activeTrip.getTotalTripDistance());

      TripBean activeTripBean = _tripBeanService.getTripForId(activeTrip.getId());
      bean.setActiveTrip(activeTripBean);
      bean.setBlockTripSequence(activeBlockTrip.getSequence());

      if (blockLocation.isLastKnownDistanceAlongBlockSet()) {
        bean.setLastKnownDistanceAlongTrip(blockLocation.getLastKnownDistanceAlongBlock()
            - activeBlockTrip.getDistanceAlongBlock());
      }

      FrequencyEntry frequencyLabel = activeTripInstance.getFrequencyLabel();

      if (frequencyLabel != null) {
View Full Code Here

    if (frequencyLabel != null) {
      frequency = FrequencyBeanLibrary.getBeanForFrequency(serviceDate,
          frequencyLabel);
    }

    BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
    TripEntry tripEntry = blockTrip.getTrip();

    if (inclusion.isIncludeTripBean()) {
      trip = _tripBeanService.getTripForId(tripEntry.getId());
      if (trip == null)
        missing = true;
View Full Code Here

  public BlockLayoverIndex createIndex(TransitGraphDao dao) {

    List<BlockTripEntry> trips = new ArrayList<BlockTripEntry>();

    for (BlockTripReference blockTripReference : _blockTripReferences) {
      BlockTripEntry trip = ReferencesLibrary.getReferenceAsTrip(
          blockTripReference, dao);
      trips.add(trip);
    }

    return new BlockLayoverIndex(trips, _layoverIntervalBlock);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry

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.