Package org.onebusaway.transit_data_federation.services.blocks

Examples of org.onebusaway.transit_data_federation.services.blocks.BlockStopSequenceIndex$ListImpl


    List<Pair<BlockStopSequenceIndex>> results = new ArrayList<Pair<BlockStopSequenceIndex>>();

    for (Map.Entry<BlockSequenceIndex, BlockStopSequenceIndex> entry : fromIndicesBySequence.entrySet()) {
      BlockSequenceIndex index = entry.getKey();
      BlockStopSequenceIndex fromStopIndex = entry.getValue();
      BlockStopSequenceIndex toStopIndex = toIndicesBySequence.get(index);

      /**
       * If the stops aren't in the requested order, then we don't include the
       * sequence indices in the results
       */
      if (fromStopIndex.getOffset() > toStopIndex.getOffset())
        continue;

      Pair<BlockStopSequenceIndex> pair = Tuples.pair(fromStopIndex,
          toStopIndex);
      results.add(pair);
View Full Code Here


      for (BlockStopTimeEntry bst : sequence.getStopTimes()) {

        StopTimeEntry stopTime = bst.getStopTime();
        StopEntryImpl stop = (StopEntryImpl) stopTime.getStop();

        BlockStopSequenceIndex blockStopTripIndex = new BlockStopSequenceIndex(
            index, offset);

        stop.addBlockStopTripIndex(blockStopTripIndex);
        offset++;
      }
View Full Code Here

    long slack = (runningLateSlack + runningEarlySlack) * 1000;

    for (Pair<BlockStopSequenceIndex> pair : indexPairs) {

      BlockStopSequenceIndex sourceStopIndex = findDepartures ? pair.getFirst()
          : pair.getSecond();
      BlockStopSequenceIndex destStopIndex = findDepartures ? pair.getSecond()
          : pair.getFirst();

      if (!includePrivateService
          && sourceStopIndex.getIndex().isPrivateService())
        continue;

      List<BlockStopTimeEntry> destStopTimes = destStopIndex.getStopTimes();

      List<Date> serviceDates = _calendarService.getServiceDatesForInterval(
          sourceStopIndex.getServiceIds(),
          sourceStopIndex.getServiceInterval(), slackAdjustedTime,
          findDepartures);

      for (Date serviceDate : serviceDates) {

        ServiceInterval destServiceInterval = destStopIndex.getServiceInterval();

        if (serviceDateIsBeyondRangeOfQueue(nBestQueue, serviceDate,
            destServiceInterval, resultCount, findDepartures, slack)) {

          /**
           * The service date is beyond our worst departure-arrival, so we break
           */
          break;
        }

        int relativeTime = effectiveTime(serviceDate.getTime(),
            slackAdjustedTime);

        IndexAdapter<HasIndexedBlockStopTimes> adapter = findDepartures
            ? IndexAdapters.BLOCK_STOP_TIME_DEPARTURE_INSTANCE
            : IndexAdapters.BLOCK_STOP_TIME_ARRIVAL_INSTANCE;

        int sourceStopIndexSize = sourceStopIndex.size();

        int sourceIndex = GenericBinarySearch.search(sourceStopIndex,
            sourceStopIndexSize, relativeTime, adapter);

        /**
         * When searching for arrival times, the index is an upper bound, so we
         * have to decrement to find the first good stop index
         */
        if (!findDepartures)
          sourceIndex--;

        InstanceState state = new InstanceState(serviceDate.getTime());

        while (0 <= sourceIndex && sourceIndex < sourceStopIndexSize) {

          BlockStopTimeEntry stopTimeSource = sourceStopIndex.getBlockStopTimeForIndex(sourceIndex);
          StopTimeInstance stiSource = new StopTimeInstance(stopTimeSource,
              state);
          stiSource.setBlockSequence(sourceStopIndex.getBlockSequenceForIndex(sourceIndex));

          BlockStopTimeEntry stopTimeDest = destStopTimes.get(sourceIndex);
          StopTimeInstance stiDest = new StopTimeInstance(stopTimeDest, state);
          stiDest.setBlockSequence(destStopIndex.getBlockSequenceForIndex(sourceIndex));

          if (stopTimeIsBeyondRangeOfQueue(nBestQueue, stiDest, resultCount,
              findDepartures, slack)) {
            break;
          }
View Full Code Here

    BlockConfigurationEntry b1B = linkBlockTrips("b1B", trip1B);
    BlockConfigurationEntry b1C = linkBlockTrips("b1C", trip1C);
    BlockConfigurationEntry b1D = linkBlockTrips("b1D", trip1D);

    BlockSequenceIndex index1 = createBlockSequenceIndex(b1A, b1B, b1C, b1D);
    BlockStopSequenceIndex fromIndex1 = new BlockStopSequenceIndex(index1, 0);
    BlockStopSequenceIndex toIndex1 = new BlockStopSequenceIndex(index1, 1);

    Pair<BlockStopSequenceIndex> indexPair1 = Tuples.pair(fromIndex1, toIndex1);

    TripEntryImpl trip2A = trip("2A", "sA");
    TripEntryImpl trip2B = trip("2B", "sA");
    TripEntryImpl trip2C = trip("2C", "sA");
    TripEntryImpl trip2D = trip("2D", "sA");

    stopTime(0, fromStop, trip2A, time(10, 07), time(10, 07), 0.0);
    stopTime(1, fromStop, trip2B, time(10, 17), time(10, 17), 0.0);
    stopTime(2, fromStop, trip2C, time(10, 27), time(10, 27), 0.0);
    stopTime(3, fromStop, trip2D, time(10, 37), time(10, 37), 0.0);

    stopTime(4, toStop, trip2A, time(10, 17), time(10, 17), 0.0);
    stopTime(5, toStop, trip2B, time(10, 27), time(10, 27), 0.0);
    stopTime(6, toStop, trip2C, time(10, 37), time(10, 37), 0.0);
    stopTime(7, toStop, trip2D, time(10, 47), time(10, 47), 0.0);

    BlockConfigurationEntry b2A = linkBlockTrips("bA", trip2A);
    BlockConfigurationEntry b2B = linkBlockTrips("bB", trip2B);
    BlockConfigurationEntry b2C = linkBlockTrips("bC", trip2C);
    BlockConfigurationEntry b2D = linkBlockTrips("bD", trip2D);

    BlockSequenceIndex index2 = createBlockSequenceIndex(b2A, b2B, b2C, b2D);
    BlockStopSequenceIndex fromIndex2 = new BlockStopSequenceIndex(index2, 0);
    BlockStopSequenceIndex toIndex2 = new BlockStopSequenceIndex(index2, 1);

    Pair<BlockStopSequenceIndex> indexPair2 = Tuples.pair(fromIndex2, toIndex2);

    List<Pair<BlockStopSequenceIndex>> indices = new ArrayList<Pair<BlockStopSequenceIndex>>();
    indices.add(indexPair1);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.blocks.BlockStopSequenceIndex$ListImpl

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.