Package org.onebusaway.transit_data_federation.services.blocks

Examples of org.onebusaway.transit_data_federation.services.blocks.ServiceIntervalBlock


    assertEquals(tripE1, trips.get(3));
    assertEquals(tripB3, trips.get(4));
    ServiceIdActivation serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    ServiceIntervalBlock intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {0, 20, 40, 50, 80},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {10, 30, 50, 60, 80},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {20, 50, 70, 80, 90},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {20, 50, 70, 80, 100},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("a2"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(5, trips.size());
    assertEquals(tripA2, trips.get(0));
    assertEquals(tripB2, trips.get(1));
    assertEquals(tripC2, trips.get(2));
    assertEquals(tripF2, trips.get(3));
    assertEquals(tripE2, trips.get(4));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {30, 60, 70, 80, 90},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {30, 60, 70, 80, 90},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {40, 70, 80, 90, 100},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {40, 70, 80, 90, 100},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("c1"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(3, trips.size());
    assertEquals(tripC1, trips.get(0));
    assertEquals(tripA3, trips.get(1));
    assertEquals(tripC3, trips.get(2));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {40, 50, 85},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {50, 50, 85},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {60, 60, 90},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {60, 70, 95},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("d1"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(2, trips.size());
    assertEquals(tripD1, trips.get(0));
    assertEquals(tripD3, trips.get(1));
    serviceIds = index.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {40, 100},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {50, 100},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {70, 110},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {70, 120},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("d2"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(1, trips.size());
    assertEquals(tripD2, trips.get(0));
    serviceIds = index.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {80}, intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {80}, intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {90}, intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {90}, intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("e3"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(2, trips.size());
    assertEquals(tripF3, trips.get(0));
    assertEquals(tripE3, trips.get(1));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMaxDepartures()));

    /****
     * Test Layover Indices
     ****/

 
View Full Code Here


      for (BlockTripEntry trip : index.getTrips()) {
        BlockTripReference ref = ReferencesLibrary.getTripAsReference(trip);
        references.add(ref);
      }

      ServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();

      BlockTripIndexData data = new BlockTripIndexData(references,
          serviceIntervalBlock);
      allData.add(data);
    }
View Full Code Here

   *
   ****/

  public BlockTripIndex createTripIndexForGroupOfBlockTrips(
      List<BlockTripEntry> blocks) {
    ServiceIntervalBlock serviceIntervalBlock = getBlockStopTimesAsBlockInterval(blocks);
    return new BlockTripIndex(blocks, serviceIntervalBlock);
  }
View Full Code Here

    return new FrequencyBlockTripIndex(trips, frequencies, serviceIntervalBlock);
  }

  public BlockSequenceIndex createSequenceIndexForGroupOfBlockSequences(
      List<BlockSequence> sequences) {
    ServiceIntervalBlock serviceIntervalBlock = getBlockStopTimesAsBlockInterval(sequences);
    String agencyId = sequences.get(0).getBlockConfig().getBlock().getId().getAgencyId();
    boolean privateService = _privateAgencyIds.contains(agencyId);
    return new BlockSequenceIndex(sequences, serviceIntervalBlock,
        privateService);
  }
View Full Code Here

      maxDepartures[index] = interval.getMaxDeparture();

      index++;
    }

    return new ServiceIntervalBlock(minArrivals, minDepartures, maxArrivals,
        maxDepartures);
  }
View Full Code Here

  private Collection<BlockInstance> handleBlockIndex(BlockTripIndex index,
      Date timeFrom, Date timeTo, Collection<BlockInstance> instances) {

    List<BlockTripEntry> trips = index.getTrips();

    ServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
    ServiceInterval serviceInterval = serviceIntervalBlock.getRange();

    Collection<Date> serviceDates = _calendarService.getServiceDatesWithinRange(
        index.getServiceIds(), serviceInterval, timeFrom, timeTo);

    for (Date serviceDate : serviceDates) {
View Full Code Here

      BlockSequenceIndex index, List<Date> timestamps) {

    Date tFrom = timestamps.get(0);
    Date tTo = timestamps.get(timestamps.size() - 1);

    ServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
    List<BlockSequence> sequences = index.getSequences();

    Collection<Date> serviceDates = _extendedCalendarService.getServiceDatesWithinRange(
        index.getServiceIds(), serviceIntervalBlock.getRange(), tFrom, tTo);

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

    for (Date serviceDate : serviceDates) {

      int effectiveFromTime = (int) ((tFrom.getTime() - serviceDate.getTime()) / 1000);
      int effectiveToTime = (int) ((tTo.getTime() - serviceDate.getTime()) / 1000);

      int indexFrom = Arrays.binarySearch(
          serviceIntervalBlock.getMaxArrivals(), effectiveFromTime);
      int indexTo = Arrays.binarySearch(
          serviceIntervalBlock.getMinDepartures(), effectiveToTime);

      if (indexFrom < 0)
        indexFrom = -(indexFrom + 1);
      if (indexTo < 0)
        indexTo = -(indexTo + 1);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.blocks.ServiceIntervalBlock

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.