Package org.onebusaway.transit_data_federation.services.transit_graph

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


    int stopIndex = _stopIndices[index];
    return blockConfig.getDepartureTimeForIndex(stopIndex);
  }

  public double getDistanceAlongBlockForIndex(int index) {
    BlockConfigurationEntry blockConfig = _blockConfigs.get(index);
    int stopIndex = _stopIndices[index];
    return blockConfig.getDistanceAlongBlockForIndex(stopIndex);
  }
View Full Code Here


    Mockito.when(_entitySource.getTrip("tripD")).thenReturn(tripD);

    BlockEntryImpl blockA = block("blockA");
    BlockEntryImpl blockB = block("blockB");

    BlockConfigurationEntry blockConfigA = blockConfiguration(blockA,
        serviceIds("s1"), tripA, tripB);
    BlockConfigurationEntry blockConfigB = blockConfiguration(blockB,
        serviceIds("s1"), tripC, tripD);

    BlockInstance blockInstanceA = new BlockInstance(blockConfigA, 0L);
    BlockInstance blockInstanceB = new BlockInstance(blockConfigB, 0L);
View Full Code Here

    int configurationIndex = block.getConfigurations().indexOf(blockConfig);
    return new BlockConfigurationReference(block.getId(), configurationIndex);
  }

  public static BlockTripReference getTripAsReference(BlockTripEntry trip) {
    BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
    BlockConfigurationReference blockConfigRef = getBlockAsReference(blockConfig);
    int tripIndex = blockConfig.getTrips().indexOf(trip);
    return new BlockTripReference(blockConfigRef, tripIndex);
  }
View Full Code Here

  }

  public static BlockTripEntry getReferenceAsTrip(BlockTripReference reference,
      TransitGraphDao dao) {

    BlockConfigurationEntry blockConfig = getReferenceAsBlockConfiguration(
        reference.getBlockConfigurationReference(), dao);

    List<BlockTripEntry> trips = blockConfig.getTrips();
    int tripIndex = reference.getTripIndex();

    return trips.get(tripIndex);
  }
View Full Code Here

    stopTime(0, stopA, tripA, time(16, 30), time(16, 35), 1000);
    StopTimeEntryImpl stopTimeAB = stopTime(1, stopB, tripA, time(16, 40),
        time(16, 45), 2000);

    BlockConfigurationEntry blockConfigA = blockConfiguration(blockA,
        serviceIds(lsids("sA"), lsids()), tripA);
    BlockStopTimeEntry bstAA = blockConfigA.getStopTimes().get(0);
    BlockStopTimeEntry bstAB = blockConfigA.getStopTimes().get(1);

    /****
     * Block B
     ****/

    BlockEntryImpl blockB = block("blockB");
    TripEntryImpl tripB = trip("tripB", "sA", 3000);

    stopTime(2, stopA, tripB, time(16, 40), time(16, 45), 1000);
    StopTimeEntryImpl stopTimeBB = stopTime(3, stopB, tripB, time(16, 50),
        time(16, 55), 2000);

    BlockConfigurationEntry blockConfigB = blockConfiguration(blockB,
        serviceIds(lsids("sA"), lsids()), tripB);
    BlockStopTimeEntry bstBA = blockConfigB.getStopTimes().get(0);
    BlockStopTimeEntry bstBB = blockConfigB.getStopTimes().get(1);

    /****
     *
     ****/

 
View Full Code Here

    stopTime(0, stopC, tripA2, 30, 30, 0);
    stopTime(0, stopA, tripA2, 40, 40, 0);
    stopTime(0, stopA, tripA3, 50, 50, 0);
    stopTime(0, stopB, tripA3, 60, 70, 0);

    BlockConfigurationEntry bcA = linkBlockTrips(blockA, tripA1, tripA2, tripA3);

    /****
     * Block B - Same trip/stop sequence as A
     ****/

    BlockEntryImpl blockB = block("b");

    TripEntryImpl tripB1 = trip("b1", "s1");
    TripEntryImpl tripB2 = trip("b2", "s1");
    TripEntryImpl tripB3 = trip("b3", "s1");

    stopTime(0, stopA, tripB1, 20, 30, 0);
    stopTime(0, stopB, tripB1, 50, 50, 0);
    stopTime(0, stopC, tripB2, 60, 60, 0);
    stopTime(0, stopA, tripB2, 70, 70, 0);
    stopTime(0, stopA, tripB3, 80, 80, 0);
    stopTime(0, stopB, tripB3, 90, 100, 0);

    BlockConfigurationEntry bcB = linkBlockTrips(blockB, tripB1, tripB2, tripB3);

    /****
     * Block C - Same stop sequence, but runs a little bit faster
     ****/

    BlockEntryImpl blockC = block("c");

    TripEntryImpl tripC1 = trip("c1", "s1");
    TripEntryImpl tripC2 = trip("c2", "s1");
    TripEntryImpl tripC3 = trip("c3", "s1");

    stopTime(0, stopA, tripC1, 40, 50, 0);
    stopTime(0, stopB, tripC1, 60, 60, 0);
    stopTime(0, stopC, tripC2, 70, 70, 0);
    stopTime(0, stopA, tripC2, 80, 80, 0);
    stopTime(0, stopA, tripC3, 85, 85, 0);
    stopTime(0, stopB, tripC3, 90, 95, 0);

    BlockConfigurationEntry bcC = linkBlockTrips(blockC, tripC1, tripC2, tripC3);

    /****
     * Block D - Same stop sequence, but with different service id
     ****/

    BlockEntryImpl blockD = block("d");

    TripEntryImpl tripD1 = trip("d1", "s1");
    TripEntryImpl tripD2 = trip("d2", "s1");
    TripEntryImpl tripD3 = trip("d3", "s2");

    stopTime(0, stopA, tripD1, 40, 50, 0);
    stopTime(0, stopB, tripD1, 70, 70, 0);
    stopTime(0, stopC, tripD2, 80, 80, 0);
    stopTime(0, stopA, tripD2, 90, 90, 0);
    stopTime(0, stopA, tripD3, 100, 100, 0);
    stopTime(0, stopB, tripD3, 110, 120, 0);

    BlockConfigurationEntry bcD = linkBlockTrips(blockD, tripD1, tripD2, tripD3);

    /****
     * Block E - One less stop
     ****/

    BlockEntryImpl blockE = block("e");

    TripEntryImpl tripE1 = trip("e1", "s1");
    TripEntryImpl tripE2 = trip("e2", "s1");
    TripEntryImpl tripE3 = trip("e3", "s1");

    stopTime(0, stopA, tripE1, 50, 60, 0);
    stopTime(0, stopB, tripE1, 80, 80, 0);
    stopTime(0, stopC, tripE2, 90, 90, 0);
    stopTime(0, stopA, tripE2, 100, 100, 0);
    stopTime(0, stopA, tripE3, 110, 110, 0);

    BlockConfigurationEntry bcE = linkBlockTrips(blockE, tripE1, tripE2, tripE3);

    /****
     * Block F - Another to group with E, but earlier
     ****/

    BlockEntryImpl blockF = block("f");

    TripEntryImpl tripF1 = trip("f1", "s1");
    TripEntryImpl tripF2 = trip("f2", "s1");
    TripEntryImpl tripF3 = trip("f3", "s1");

    stopTime(0, stopA, tripF1, 40, 50, 0);
    stopTime(0, stopB, tripF1, 70, 70, 0);
    stopTime(0, stopC, tripF2, 80, 80, 0);
    stopTime(0, stopA, tripF2, 90, 90, 0);
    stopTime(0, stopA, tripF3, 100, 100, 0);

    BlockConfigurationEntry bcF = linkBlockTrips(blockF, tripF1, tripF2, tripF3);

    BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();

    List<BlockStopTimeIndex> allIndices = factory.createIndices(Arrays.asList(
        (BlockEntry) blockF, blockE, blockD, blockC, blockB, blockA));

    assertEquals(6, allIndices.size());

    List<BlockStopTimeIndex> indices = grep(allIndices, aid("a"),
        serviceIds(lsids("s1"), lsids()));
    assertEquals(1, indices.size());
    BlockStopTimeIndex index = indices.get(0);
    assertEquals(15, index.getStopTimes().size());
    assertEquals(bcA.getStopTimes().get(0), index.getStopTimes().get(0));
    assertEquals(bcB.getStopTimes().get(0), index.getStopTimes().get(1));
    assertEquals(bcA.getStopTimes().get(3), index.getStopTimes().get(2));
    assertEquals(bcF.getStopTimes().get(0), index.getStopTimes().get(3));
    assertEquals(bcC.getStopTimes().get(0), index.getStopTimes().get(4));
    assertEquals(bcA.getStopTimes().get(4), index.getStopTimes().get(5));
    assertEquals(bcE.getStopTimes().get(0), index.getStopTimes().get(6));
    assertEquals(bcB.getStopTimes().get(3), index.getStopTimes().get(7));
    assertEquals(bcC.getStopTimes().get(3), index.getStopTimes().get(8));
    assertEquals(bcB.getStopTimes().get(4), index.getStopTimes().get(9));
    assertEquals(bcC.getStopTimes().get(4), index.getStopTimes().get(10));
    assertEquals(bcF.getStopTimes().get(3), index.getStopTimes().get(11));
    assertEquals(bcF.getStopTimes().get(4), index.getStopTimes().get(12));
    assertEquals(bcE.getStopTimes().get(3), index.getStopTimes().get(13));
    assertEquals(bcE.getStopTimes().get(4), index.getStopTimes().get(14));

    indices = grep(allIndices, aid("a"), serviceIds(lsids("s1", "s2"), lsids()));
    assertEquals(1, indices.size());
    index = indices.get(0);
    assertEquals(3, index.getStopTimes().size());
    assertEquals(bcD.getStopTimes().get(0), index.getStopTimes().get(0));
    assertEquals(bcD.getStopTimes().get(3), index.getStopTimes().get(1));
    assertEquals(bcD.getStopTimes().get(4), index.getStopTimes().get(2));

    indices = grep(allIndices, aid("b"), serviceIds(lsids("s1"), lsids()));
    assertEquals(1, indices.size());
    index = indices.get(0);
    assertEquals(8, index.getStopTimes().size());
    assertEquals(bcA.getStopTimes().get(1), index.getStopTimes().get(0));
    assertEquals(bcB.getStopTimes().get(1), index.getStopTimes().get(1));
    assertEquals(bcC.getStopTimes().get(1), index.getStopTimes().get(2));
    assertEquals(bcA.getStopTimes().get(5), index.getStopTimes().get(3));
    assertEquals(bcF.getStopTimes().get(1), index.getStopTimes().get(4));
    assertEquals(bcE.getStopTimes().get(1), index.getStopTimes().get(5));
    assertEquals(bcC.getStopTimes().get(5), index.getStopTimes().get(6));
    assertEquals(bcB.getStopTimes().get(5), index.getStopTimes().get(7));

    indices = grep(allIndices, aid("b"), serviceIds(lsids("s1", "s2"), lsids()));
    assertEquals(1, indices.size());
    index = indices.get(0);
    assertEquals(2, index.getStopTimes().size());
    assertEquals(bcD.getStopTimes().get(1), index.getStopTimes().get(0));
    assertEquals(bcD.getStopTimes().get(5), index.getStopTimes().get(1));

    indices = grep(allIndices, aid("c"), serviceIds(lsids("s1"), lsids()));
    assertEquals(1, indices.size());
    index = indices.get(0);
    assertEquals(5, index.getStopTimes().size());
    assertEquals(bcA.getStopTimes().get(2), index.getStopTimes().get(0));
    assertEquals(bcB.getStopTimes().get(2), index.getStopTimes().get(1));
    assertEquals(bcC.getStopTimes().get(2), index.getStopTimes().get(2));
    assertEquals(bcF.getStopTimes().get(2), index.getStopTimes().get(3));
    assertEquals(bcE.getStopTimes().get(2), index.getStopTimes().get(4));

    indices = grep(allIndices, aid("c"), serviceIds(lsids("s1", "s2"), lsids()));
    assertEquals(1, indices.size());
    index = indices.get(0);
View Full Code Here

    FrequencyEntry freqA1 = frequency(time(6, 00), time(9, 00), 10);
    FrequencyEntry freqA2 = frequency(time(15, 00), time(18, 00), 10);
    List<FrequencyEntry> freqsA = Arrays.asList(freqA1, freqA2);

    BlockConfigurationEntry bcA = linkBlockTrips(blockA, freqsA, tripA);

    /****
     * Block B
     ****/

    BlockEntryImpl blockB = block("b");

    TripEntryImpl tripB = trip("b", "s1");

    stopTime(0, stopA, tripB, 20, 30, 0);
    stopTime(0, stopB, tripB, 50, 50, 0);

    FrequencyEntry freqB1 = frequency(time(9, 00), time(15, 00), 20);
    FrequencyEntry freqB2 = frequency(time(18, 00), time(21, 00), 20);
    List<FrequencyEntry> freqsB = Arrays.asList(freqB1, freqB2);

    BlockConfigurationEntry bcB = linkBlockTrips(blockB, freqsB, tripB);

    BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();

    List<FrequencyBlockStopTimeIndex> allIndices = factory.createFrequencyIndices(Arrays.asList(
        (BlockEntry) blockB, blockA));
View Full Code Here

        new ArrayList<LocalizedServiceId>()));
    builder.setTrips(tripEntries);
    builder.setFrequencies(frequencies);
    builder.setTripGapDistances(new double[tripEntries.size()]);

    BlockConfigurationEntry configuration = builder.create();

    List<BlockConfigurationEntry> configurations = block.getConfigurations();
    if (configurations == null) {
      configurations = new ArrayList<BlockConfigurationEntry>();
      block.setConfigurations(configurations);
View Full Code Here

    Builder builder = BlockConfigurationEntryImpl.builder();
    builder.setBlock(block);
    builder.setServiceIds(serviceIds);
    builder.setTrips(Arrays.asList(trips));
    builder.setTripGapDistances(new double[trips.length]);
    BlockConfigurationEntry blockConfig = builder.create();

    BlockEntryImpl blockImpl = (BlockEntryImpl) block;
    List<BlockConfigurationEntry> configs = block.getConfigurations();
    if (configs == null) {
      configs = new ArrayList<BlockConfigurationEntry>();
View Full Code Here

  public void test01() {

    BlockEntryImpl block = block("blockA");
    TripEntryImpl trip = trip("tripA", "serviceId");
    stopTime(0, null, trip, time(9, 00), 0);
    BlockConfigurationEntry blockConfig = linkBlockTrips(block, trip);
    BlockInstance blockInstance = new BlockInstance(blockConfig,
        System.currentTimeMillis());

    SortedMap<Long, BlockLocationRecord> records = new TreeMap<Long, BlockLocationRecord>();
View Full Code Here

TOP

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

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.