Package org.onebusaway.transit_data_federation.services.transit_graph

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


     * had
     */
    if (sequence == 0)
      return 0;

    BlockConfigurationEntry blockConfig = nextStop.getTrip().getBlockConfiguration();
    BlockStopTimeEntry previousStop = blockConfig.getStopTimes().get(
        sequence - 1);

    int slack = nextStop.getAccumulatedSlackTime()
        - previousStop.getAccumulatedSlackTime();
    slack -= previousStop.getStopTime().getSlackTime();
View Full Code Here


    if (blockLocation == null)
      return null;

    BlockInstance instance = blockLocation.getBlockInstance();
    BlockConfigurationEntry block = instance.getBlock();
    long serviceDate = instance.getServiceDate();

    BlockStatusBean bean = new BlockStatusBean();

    bean.setBlock(_blockBeanService.getBlockForId(block.getBlock().getId()));

    bean.setStatus("default");
    bean.setServiceDate(serviceDate);
    bean.setTotalDistanceAlongBlock(block.getTotalBlockDistance());

    bean.setInService(blockLocation.isInService());

    CoordinatePoint location = blockLocation.getLocation();
    bean.setLocation(location);
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<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

    Builder builder = BlockConfigurationEntryImpl.builder();
    builder.setBlock(block);
    builder.setTrips(trips);
    builder.setServiceIds(serviceIds);
    builder.setTripGapDistances(new double[] {10.0, 20.0, 0.0});
    BlockConfigurationEntry entry = builder.create();

    assertSame(block, entry.getBlock());
    assertSame(serviceIds, entry.getServiceIds());

    assertEquals(4530.0, entry.getTotalBlockDistance(), 0.0);

    /****
     * Trips
     ****/

    List<BlockTripEntry> blockTrips = entry.getTrips();
    assertEquals(3, blockTrips.size());

    BlockTripEntry blockTrip = blockTrips.get(0);
    assertEquals(0, blockTrip.getSequence());
    assertEquals(0, blockTrip.getAccumulatedStopTimeIndex());
    assertEquals(0, blockTrip.getAccumulatedSlackTime());
    assertEquals(0.0, blockTrip.getDistanceAlongBlock(), 0.0);
    assertSame(blockTrips.get(1), blockTrip.getNextTrip());
    assertNull(blockTrip.getPreviousTrip());

    blockTrip = blockTrips.get(1);
    assertEquals(1, blockTrip.getSequence());
    assertEquals(2, blockTrip.getAccumulatedStopTimeIndex());
    assertEquals(15 * 60, blockTrip.getAccumulatedSlackTime());
    assertEquals(1010.0, blockTrip.getDistanceAlongBlock(), 0.0);
    assertSame(blockTrips.get(2), blockTrip.getNextTrip());
    assertSame(blockTrips.get(0), blockTrip.getPreviousTrip());

    blockTrip = blockTrips.get(2);
    assertEquals(2, blockTrip.getSequence());
    assertEquals(4, blockTrip.getAccumulatedStopTimeIndex());
    assertEquals(35 * 60, blockTrip.getAccumulatedSlackTime());
    assertEquals(3030.0, blockTrip.getDistanceAlongBlock(), 0.0);
    assertNull(blockTrip.getNextTrip());
    assertSame(blockTrips.get(1), blockTrip.getPreviousTrip());

    /****
     * Stop Times
     ****/

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

    BlockStopTimeEntry bst = stopTimes.get(0);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
View Full Code Here

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

      for (int i = indexFrom; i < indexTo; i++) {

        BlockSequence sequence = sequences.get(i);
        BlockConfigurationEntry blockConfig = sequence.getBlockConfig();
        BlockInstance instance = new BlockInstance(blockConfig, state);
        instances.add(instance);
      }
    }
    return instances;
View Full Code Here

    TripEntryImpl tripEntryA = trip("trip").setRoute(_routeEntry).setServiceId(
        _lsid).setBlock(block).setDirectionId("0");
    _graph.putTripEntry(tripEntryA);
    addStopTime(tripEntryA, stopTime().setStop(_stopA).setTime(time(7, 00)));

    BlockConfigurationEntry blockConfig = blockConfiguration(block,
        serviceIds("serviceId"), tripEntryA);

    Trip trip = new Trip();
    trip.setId(tripEntryA.getId());

    Frequency freqA = new Frequency();
    freqA.setTrip(trip);
    freqA.setStartTime(time(8, 00));
    freqA.setEndTime(time(10, 00));
    freqA.setHeadwaySecs(10 * 60);

    Frequency freqB = new Frequency();
    freqB.setTrip(trip);
    freqB.setStartTime(time(10, 00));
    freqB.setEndTime(time(12, 00));
    freqB.setHeadwaySecs(10 * 60);

    Mockito.when(_dao.getAllFrequencies()).thenReturn(
        Arrays.asList(freqA, freqB));

    _graph.initialize();

    _factory.processFrequencies(_graph);

    blockConfig = block.getConfigurations().get(0);

    List<FrequencyEntry> frequencies = blockConfig.getFrequencies();
    assertEquals(2, frequencies.size());
    FrequencyEntry frequency = frequencies.get(0);
    assertEquals(freqA.getStartTime(), frequency.getStartTime());
    assertEquals(freqA.getEndTime(), frequency.getEndTime());
    assertEquals(freqA.getHeadwaySecs(), frequency.getHeadwaySecs());
View Full Code Here

    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

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

    for (int in = indexFrom; in < indexTo; in++) {
      BlockTripEntry trip = trips.get(in);
      BlockConfigurationEntry block = trip.getBlockConfiguration();
      BlockInstance instance = new BlockInstance(block, state);
      instances.add(instance);
    }
  }
View Full Code Here

    /****
     * Configuration A & B
     ****/

    BlockConfigurationEntry entry = configurations.get(0);
    assertSame(block, entry.getBlock());
    assertEquals(serviceIds(lsids("sA", "sB"), lsids()), entry.getServiceIds());
    assertEquals(1200.0, entry.getTotalBlockDistance(), 0.0);
    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);
    assertEquals(0, bst.getAccumulatedSlackTime());
    assertEquals(0, bst.getBlockSequence());
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.