Package org.onebusaway.transit_data_federation.services.transit_graph

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


    if (activeTrip != null) {
      BlockTripBean activeTripBean = _blockBeanService.getBlockTripAsBean(activeTrip);
      bean.setActiveTrip(activeTripBean);
    }

    BlockStopTimeEntry stop = blockLocation.getClosestStop();
    if (stop != null) {
      StopBean stopBean = _stopBeanService.getStopForId(stop.getStopTime().getStop().getId());
      bean.setClosestStop(stopBean);
      bean.setClosestStopTimeOffset(blockLocation.getClosestStopTimeOffset());
    }

    bean.setPredicted(blockLocation.isPredicted());
View Full Code Here


    int[] stopIndices = new int[n];

    ServiceInterval interval = null;

    for (int i = 0; i < n; i++) {
      BlockStopTimeEntry blockStopTime = group.get(i);
      StopTimeEntry stopTime = blockStopTime.getStopTime();
      blockConfigs.add(blockStopTime.getTrip().getBlockConfiguration());
      stopIndices[i] = blockStopTime.getBlockSequence();
      interval = ServiceInterval.extend(interval, stopTime.getArrivalTime(),
          stopTime.getDepartureTime());
    }

    return new BlockStopTimeIndex(blockConfigs, stopIndices, interval);
View Full Code Here

     ****/

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

    BlockStopTimeEntry bst = stopTimes.get(0);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
    assertEquals(200, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st1, bst.getStopTime());
    assertSame(blockTrips.get(0), bst.getTrip());

    bst = stopTimes.get(1);
    assertEquals(300, bst.getAccumulatedSlackTime());
    assertEquals(1, bst.getBlockSequence());
    assertEquals(800, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st2, bst.getStopTime());
    assertSame(blockTrips.get(0), bst.getTrip());

    bst = stopTimes.get(2);
    assertEquals(15 * 60, bst.getAccumulatedSlackTime());
    assertEquals(2, bst.getBlockSequence());
    assertEquals(1410, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st3, bst.getStopTime());
    assertSame(blockTrips.get(1), bst.getTrip());

    bst = stopTimes.get(3);
    assertEquals(20 * 60, bst.getAccumulatedSlackTime());
    assertEquals(3, bst.getBlockSequence());
    assertEquals(2610, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st4, bst.getStopTime());
    assertSame(blockTrips.get(1), bst.getTrip());

    bst = stopTimes.get(4);
    assertEquals(35 * 60, bst.getAccumulatedSlackTime());
    assertEquals(4, bst.getBlockSequence());
    assertEquals(3330, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st5, bst.getStopTime());
    assertSame(blockTrips.get(2), bst.getTrip());

    bst = stopTimes.get(5);
    assertEquals(40 * 60, bst.getAccumulatedSlackTime());
    assertEquals(5, bst.getBlockSequence());
    assertEquals(4230, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st6, bst.getStopTime());
    assertSame(blockTrips.get(2), bst.getTrip());
  }
View Full Code Here

    for (int i = 0; i < n; i++) {
      FrequencyBlockStopTimeEntry frequencyBlockStopTime = group.get(i);
      FrequencyEntry frequency = frequencyBlockStopTime.getFrequency();
      frequencies.add(frequency);
      BlockStopTimeEntry blockStopTime = frequencyBlockStopTime.getStopTime();
      blockConfigs.add(blockStopTime.getTrip().getBlockConfiguration());
      stopIndices[i] = blockStopTime.getBlockSequence();
      interval = ServiceInterval.extend(interval, frequency.getStartTime(),
          frequency.getStartTime());
      interval = ServiceInterval.extend(interval, frequency.getEndTime(),
          frequency.getEndTime());
    }
View Full Code Here

    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

    return stopTime.getDepartureTime();
  }
 
  public static int getLayoverEndTimeForTrip(BlockTripEntry blockTrip) {
    List<BlockStopTimeEntry> stopTimes = blockTrip.getStopTimes();
    BlockStopTimeEntry blockStopTime = stopTimes.get(0);
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    return stopTime.getArrivalTime();
  }
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);
    pab.setRouteShortName(stopTimeNarrative.getRouteShortName());
    pab.setTripHeadsign(stopTimeNarrative.getStopHeadsign());
View Full Code Here

      bean.setPredictedDepartureTime(instance.getPredictedDepartureTime());
      if (hasFrequency)
        bean.setScheduledDepartureTime(bean.getPredictedDepartureTime());
    }

    BlockStopTimeEntry stopTime = instance.getBlockStopTime();
    BlockLocation blockLocation = instance.getBlockLocation();

    if (blockLocation == null)
      return;

    bean.setPredicted(blockLocation.isPredicted());

    // Distance from stop
    if (blockLocation.isDistanceAlongBlockSet()) {
      double distanceFromStop = stopTime.getDistanceAlongBlock()
          - blockLocation.getDistanceAlongBlock();
      bean.setDistanceFromStop(distanceFromStop);
    } else {
      double distanceFromStop = stopTime.getDistanceAlongBlock()
          - blockLocation.getScheduledDistanceAlongBlock();
      bean.setDistanceFromStop(distanceFromStop);
    }

    // Number of stops away
    if (blockLocation.getNextStop() != null) {
      BlockStopTimeEntry nextStopTime = blockLocation.getNextStop();
      bean.setNumberOfStopsAway(stopTime.getBlockSequence()
          - nextStopTime.getBlockSequence());
    }

    if (blockLocation.getLastUpdateTime() > 0)
      bean.setLastUpdateTime(blockLocation.getLastUpdateTime());
View Full Code Here

    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);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
    assertEquals(100.0, bst.getDistanceAlongBlock(), 0.0);
    assertSame(st4, 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(st5, 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(st6, 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(st7, bst.getStopTime());
    assertSame(trips.get(1), bst.getTrip());
  }
View Full Code Here

    AgencyAndId nextLineId = nextTrip.getTrip().getRouteCollection().getId();
    if (prevLineId.equals(nextLineId))
      return null;

    List<BlockStopTimeEntry> stopTimes = blockTrip.getStopTimes();
    BlockStopTimeEntry prevStopTime = stopTimes.get(stopTimes.size() - 1);

    List<BlockStopTimeEntry> nextStopTimes = nextTrip.getStopTimes();
    BlockStopTimeEntry nextStopTime = nextStopTimes.get(0);

    int prevTime = prevStopTime.getStopTime().getDepartureTime();
    int nextTime = nextStopTime.getStopTime().getArrivalTime();

    if (nextTime - prevTime > _continuesAsThreshold)
      return null;

    return nextLineId;
View Full Code Here

TOP

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

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.