Package org.onebusaway.transit_data_federation.services.transit_graph

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


   ****/

  private StopTimeEntry getStopTimeForIndex(int index) {
    int tripIndex = tripIndices[index];

    BlockTripEntry blockTrip = trips.get(tripIndex);
    TripEntry trip = blockTrip.getTrip();

    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    int stopTimeIndex = index - accumulatedStopTimeIndices[tripIndex];
    StopTimeEntry stopTime = stopTimes.get(stopTimeIndex);
    return stopTime;
View Full Code Here


      if (BlockLibrary.isFrequencyBased(block))
        continue;

      for (BlockConfigurationEntry blockConfiguration : block.getConfigurations()) {
        BlockTripEntry prevTrip = null;
        for (BlockTripEntry blockTrip : blockConfiguration.getTrips()) {

          if (prevTrip != null) {
            BlockLayoverSequenceKey key = getBlockTripAsLayoverSequenceKey(blockTrip);
            blockTripsByServiceIds.get(key).add(blockTrip);
View Full Code Here

    for (List<BlockTripEntry> list : lists) {

      if (list.isEmpty())
        return list;

      BlockTripEntry prev = list.get(list.size() - 1);

      boolean allGood = areLayoverTimesAlwaysIncreasingOrEqual(prev, trip);

      if (allGood)
        return list;
View Full Code Here

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

    List<BlockTripEntry> group = new ArrayList<BlockTripEntry>();
    groups.add(group);

    BlockTripEntry prev = null;
    for (BlockTripEntry trip : trips) {
      if (prev != null) {

        if (!areBlockTripsContinuous(prev, trip)) {
          group = new ArrayList<BlockTripEntry>();
          groups.add(group);
        }
      }

      group.add(trip);

      prev = trip;
    }

    List<BlockSequence> sequences = new ArrayList<BlockSequence>();
    for (List<BlockTripEntry> g : groups) {

      BlockTripEntry firstTrip = g.get(0);
      BlockTripEntry lastTrip = g.get(g.size() - 1);

      int from = firstTrip.getAccumulatedStopTimeIndex();
      int to = blockConfig.getStopTimes().size();
      if (lastTrip.getNextTrip() != null) {
        BlockTripEntry next = lastTrip.getNextTrip();
        to = next.getAccumulatedStopTimeIndex();
      }

      BlockSequence sequence = new BlockSequence(blockConfig, from, to);
      sequences.add(sequence);
    }
View Full Code Here

    assertNull(entry.getFrequencies());

    List<BlockTripEntry> trips = entry.getTrips();
    assertEquals(4, trips.size());

    BlockTripEntry trip = trips.get(0);
    assertEquals(0, trip.getAccumulatedStopTimeIndex());
    assertEquals(0, trip.getAccumulatedSlackTime());
    assertEquals(0.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripA, trip.getTrip());
    assertNull(trip.getPreviousTrip());
    assertSame(trips.get(1), trip.getNextTrip());

    trip = trips.get(1);
    assertEquals(2, trip.getAccumulatedStopTimeIndex());
    assertEquals(10 * 60, trip.getAccumulatedSlackTime());
    assertEquals(300.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripB, trip.getTrip());
    assertSame(trips.get(0), trip.getPreviousTrip());
    assertSame(trips.get(2), trip.getNextTrip());

    trip = trips.get(2);
    assertEquals(4, trip.getAccumulatedStopTimeIndex());
    assertEquals(20 * 60, trip.getAccumulatedSlackTime());
    assertEquals(600.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripC, trip.getTrip());
    assertSame(trips.get(1), trip.getPreviousTrip());
    assertSame(trips.get(3), trip.getNextTrip());

    trip = trips.get(3);
    assertEquals(6, trip.getAccumulatedStopTimeIndex());
    assertEquals(30 * 60, trip.getAccumulatedSlackTime());
    assertEquals(900.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripD, trip.getTrip());
    assertSame(trips.get(2), trip.getPreviousTrip());
    assertNull(trip.getNextTrip());

    List<BlockStopTimeEntry> stopTimes = entry.getStopTimes();
    assertEquals(8, stopTimes.size());

    BlockStopTimeEntry bst = stopTimes.get(0);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
    assertEquals(100.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st0, bst.getStopTime());
    assertSame(trips.get(0), bst.getTrip());

    bst = stopTimes.get(1);
    assertEquals(5 * 60, bst.getAccumulatedSlackTime());
    assertEquals(1, bst.getBlockSequence());
    assertEquals(200.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st1, bst.getStopTime());
    assertSame(trips.get(0), bst.getTrip());

    bst = stopTimes.get(2);
    assertEquals(10 * 60, bst.getAccumulatedSlackTime());
    assertEquals(2, bst.getBlockSequence());
    assertEquals(400.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st2, bst.getStopTime());
    assertSame(trips.get(1), bst.getTrip());

    bst = stopTimes.get(3);
    assertEquals(15 * 60, bst.getAccumulatedSlackTime());
    assertEquals(3, bst.getBlockSequence());
    assertEquals(500.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st3, bst.getStopTime());
    assertSame(trips.get(1), bst.getTrip());

    bst = stopTimes.get(4);
    assertEquals(20 * 60, bst.getAccumulatedSlackTime());
    assertEquals(4, bst.getBlockSequence());
    assertEquals(700.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st4, bst.getStopTime());
    assertSame(trips.get(2), bst.getTrip());

    bst = stopTimes.get(5);
    assertEquals(25 * 60, bst.getAccumulatedSlackTime());
    assertEquals(5, bst.getBlockSequence());
    assertEquals(800.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st5, bst.getStopTime());
    assertSame(trips.get(2), bst.getTrip());

    bst = stopTimes.get(6);
    assertEquals(30 * 60, bst.getAccumulatedSlackTime());
    assertEquals(6, bst.getBlockSequence());
    assertEquals(1000.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st6, bst.getStopTime());
    assertSame(trips.get(3), bst.getTrip());

    bst = stopTimes.get(7);
    assertEquals(35 * 60, bst.getAccumulatedSlackTime());
    assertEquals(7, bst.getBlockSequence());
    assertEquals(1100.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st7, bst.getStopTime());
    assertSame(trips.get(3), bst.getTrip());

    /****
     * Configuration A
     ****/

    entry = configurations.get(1);
    assertSame(block, entry.getBlock());
    assertEquals(serviceIds(lsids("sA"), lsids("sB")), entry.getServiceIds());
    assertEquals(600.0, entry.getTotalBlockDistance(), 0.0);
    assertNull(entry.getFrequencies());

    trips = entry.getTrips();
    assertEquals(2, trips.size());

    trip = trips.get(0);
    assertEquals(0, trip.getAccumulatedStopTimeIndex());
    assertEquals(0, trip.getAccumulatedSlackTime());
    assertEquals(0.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripA, trip.getTrip());
    assertNull(trip.getPreviousTrip());
    assertSame(trips.get(1), trip.getNextTrip());

    trip = trips.get(1);
    assertEquals(2, trip.getAccumulatedStopTimeIndex());
    assertEquals(10 * 60, trip.getAccumulatedSlackTime());
    assertEquals(300.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripB, trip.getTrip());
    assertSame(trips.get(0), trip.getPreviousTrip());
    assertNull(trip.getNextTrip());

    stopTimes = entry.getStopTimes();
    assertEquals(4, stopTimes.size());

    bst = stopTimes.get(0);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
    assertEquals(100.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st0, bst.getStopTime());
    assertSame(trips.get(0), bst.getTrip());

    bst = stopTimes.get(1);
    assertEquals(5 * 60, bst.getAccumulatedSlackTime());
    assertEquals(1, bst.getBlockSequence());
    assertEquals(200.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st1, bst.getStopTime());
    assertSame(trips.get(0), bst.getTrip());

    bst = stopTimes.get(2);
    assertEquals(10 * 60, bst.getAccumulatedSlackTime());
    assertEquals(2, bst.getBlockSequence());
    assertEquals(400.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st2, bst.getStopTime());
    assertSame(trips.get(1), bst.getTrip());

    bst = stopTimes.get(3);
    assertEquals(15 * 60, bst.getAccumulatedSlackTime());
    assertEquals(3, bst.getBlockSequence());
    assertEquals(500.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st3, bst.getStopTime());
    assertSame(trips.get(1), bst.getTrip());

    /****
     * Configuration B
     ****/

    entry = configurations.get(2);
    assertSame(block, entry.getBlock());
    assertEquals(serviceIds(lsids("sB"), lsids("sA")), entry.getServiceIds());
    assertEquals(600.0, entry.getTotalBlockDistance(), 0.0);
    assertNull(entry.getFrequencies());

    trips = entry.getTrips();
    assertEquals(2, trips.size());

    trip = trips.get(0);
    assertEquals(0, trip.getAccumulatedStopTimeIndex());
    assertEquals(0, trip.getAccumulatedSlackTime());
    assertEquals(0.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripC, trip.getTrip());
    assertNull(trip.getPreviousTrip());
    assertSame(trips.get(1), trip.getNextTrip());

    trip = trips.get(1);
    assertEquals(2, trip.getAccumulatedStopTimeIndex());
    assertEquals(10 * 60, trip.getAccumulatedSlackTime());
    assertEquals(300.0, trip.getDistanceAlongBlock(), 0.0);
    assertSame(tripD, trip.getTrip());
    assertSame(trips.get(0), trip.getPreviousTrip());
    assertNull(trip.getNextTrip());

    stopTimes = entry.getStopTimes();
    assertEquals(4, stopTimes.size());

    bst = stopTimes.get(0);
View Full Code Here

    bean.setLocation(location);

    bean.setScheduledDistanceAlongBlock(blockLocation.getScheduledDistanceAlongBlock());
    bean.setDistanceAlongBlock(blockLocation.getDistanceAlongBlock());
   
    BlockTripEntry activeTrip = blockLocation.getActiveTrip();
    if (activeTrip != null) {
      BlockTripBean activeTripBean = _blockBeanService.getBlockTripAsBean(activeTrip);
      bean.setActiveTrip(activeTripBean);
    }
View Full Code Here

  }

  private BlockStopTimeKey getBlockStopTimeAsKey(
      BlockStopTimeEntry blockStopTime) {

    BlockTripEntry blockTrip = blockStopTime.getTrip();
    BlockConfigurationEntry blockConfig = blockTrip.getBlockConfiguration();

    StopTimeEntry stopTime = blockStopTime.getStopTime();
    StopEntry stop = stopTime.getStop();

    return new BlockStopTimeKey(blockConfig.getServiceIds(), stop.getId());
View Full Code Here

      List<BlockStopTimeEntry> stopTimes) {

    List<FrequencyBlockStopTimeEntry> frequencyStopTimes = new ArrayList<FrequencyBlockStopTimeEntry>();

    for (BlockStopTimeEntry blockStopTime : stopTimes) {
      BlockTripEntry trip = blockStopTime.getTrip();
      BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
      for (FrequencyEntry frequency : blockConfig.getFrequencies()) {
        FrequencyBlockStopTimeEntry frequencyStopTime = new FrequencyBlockStopTimeEntryImpl(
            blockStopTime, frequency);
        frequencyStopTimes.add(frequencyStopTime);
      }
View Full Code Here

    return t1 - t2;
  }

  public static int getLayoverStartTimeForTrip(BlockTripEntry blockTrip) {
    BlockTripEntry prevTrip = blockTrip.getPreviousTrip();
    if (prevTrip == null)
      throw new IllegalStateException(
          "blockTrip had no incoming trip, thus no layover");
    List<BlockStopTimeEntry> stopTimes = prevTrip.getStopTimes();
    BlockStopTimeEntry blockStopTime = stopTimes.get(stopTimes.size() - 1);
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    return stopTime.getDepartureTime();
  }
View Full Code Here

    ArrivalAndDepartureBean pab = new ArrivalAndDepartureBean();

    pab.setServiceDate(instance.getServiceDate());

    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    BlockTripEntry blockTrip = blockStopTime.getTrip();
    BlockConfigurationEntry blockConfig = blockTrip.getBlockConfiguration();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    StopEntry stop = stopTime.getStop();
    TripEntry trip = stopTime.getTrip();

    TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
    pab.setTrip(tripBean);
    pab.setBlockTripSequence(blockTrip.getSequence());

    pab.setArrivalEnabled(blockStopTime.getBlockSequence() > 0);
    pab.setDepartureEnabled(blockStopTime.getBlockSequence() + 1 < blockConfig.getStopTimes().size());

    StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(stopTime);
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.