Search in sources :

Example 31 with BlockEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl in project onebusaway-application-modules by camsys.

the class BlockStopTimeIndicesFactoryTest method testFrequencies.

@Test
public void testFrequencies() {
    StopEntryImpl stopA = stop("a", 47.0, -122.0);
    StopEntryImpl stopB = stop("b", 47.1, -122.1);
    /**
     **
     * Block A
     ***
     */
    BlockEntryImpl blockA = block("a");
    TripEntryImpl tripA = trip("a", "s1");
    stopTime(0, stopA, tripA, 0, 10, 0);
    stopTime(0, stopB, tripA, 20, 20, 0);
    FrequencyEntry freqA1 = frequency(time(6, 00), time(9, 00), 10, 0);
    FrequencyEntry freqA2 = frequency(time(15, 00), time(18, 00), 10, 0);
    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, 0);
    FrequencyEntry freqB2 = frequency(time(18, 00), time(21, 00), 20, 0);
    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));
    assertEquals(2, allIndices.size());
    List<FrequencyBlockStopTimeIndex> indices = grep(allIndices, aid("a"), serviceIds(lsids("s1"), lsids()));
    assertEquals(1, indices.size());
    FrequencyBlockStopTimeIndex index = indices.get(0);
    assertEquals(freqA1, index.getFrequencies().get(0));
    assertEquals(freqB1, index.getFrequencies().get(1));
    assertEquals(freqA2, index.getFrequencies().get(2));
    assertEquals(freqB2, index.getFrequencies().get(3));
    assertEquals(bcA, index.getBlockConfigs().get(0));
    assertEquals(bcB, index.getBlockConfigs().get(1));
    assertEquals(bcA, index.getBlockConfigs().get(2));
    assertEquals(bcB, index.getBlockConfigs().get(3));
}
Also used : BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl) Test(org.junit.Test)

Example 32 with BlockEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl in project onebusaway-application-modules by camsys.

the class BlockLocationRecordCollectionTest method test01.

@Test
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>();
    CoordinatePoint p1 = new CoordinatePoint(47.0, -122.0);
    CoordinatePoint p2 = new CoordinatePoint(47.1, -122.1);
    CoordinatePoint p3 = new CoordinatePoint(47.2, -122.2);
    EVehiclePhase inProgress = EVehiclePhase.IN_PROGRESS;
    EVehiclePhase layover = EVehiclePhase.LAYOVER_DURING;
    addRecord(records, record(t(4, 10), 10.0, 100.0, p1, 0.0, inProgress, "ok"));
    addRecord(records, record(t(8, 20), 18.0, 200.0, p2, 90.0, layover, "not ok"));
    addRecord(records, record(t(12, 30), 15.0, 300.0, p3, 45.0, inProgress, "ok"));
    BlockLocationRecordCollection entry = new BlockLocationRecordCollection(t(3, 20), t(13, 20), records);
    assertEquals(t(3, 20), entry.getFromTime());
    assertEquals(t(13, 20), entry.getToTime());
    assertEquals(10, entry.getScheduleDeviationForTargetTime(t(3, 20)), 0.0);
    assertEquals(10, entry.getScheduleDeviationForTargetTime(t(4, 10)), 0.0);
    assertEquals(12, entry.getScheduleDeviationForTargetTime(t(5, 12)), 0.0);
    assertEquals(14, entry.getScheduleDeviationForTargetTime(t(6, 15)), 0.0);
    assertEquals(16, entry.getScheduleDeviationForTargetTime(t(7, 18)), 0.0);
    assertEquals(18, entry.getScheduleDeviationForTargetTime(t(8, 20)), 0.0);
    assertEquals(17, entry.getScheduleDeviationForTargetTime(t(10, 0)), 0.0);
    assertEquals(15, entry.getScheduleDeviationForTargetTime(t(12, 30)), 0.0);
    assertEquals(15, entry.getScheduleDeviationForTargetTime(t(13, 20)), 0.0);
    assertEquals(80, entry.getDistanceAlongBlockForTargetTime(t(3, 20)), 0.0);
    assertEquals(100, entry.getDistanceAlongBlockForTargetTime(t(4, 10)), 0.0);
    assertEquals(124.8, entry.getDistanceAlongBlockForTargetTime(t(5, 12)), 0.0);
    assertEquals(150, entry.getDistanceAlongBlockForTargetTime(t(6, 15)), 0.0);
    assertEquals(175.2, entry.getDistanceAlongBlockForTargetTime(t(7, 18)), 0.0);
    assertEquals(200, entry.getDistanceAlongBlockForTargetTime(t(8, 20)), 0.0);
    assertEquals(240, entry.getDistanceAlongBlockForTargetTime(t(10, 0)), 0.0);
    assertEquals(300, entry.getDistanceAlongBlockForTargetTime(t(12, 30)), 0.0);
    assertEquals(320, entry.getDistanceAlongBlockForTargetTime(t(13, 20)), 0.0);
    assertNull(entry.getLastLocationForTargetTime(t(3, 20)));
    assertNull(entry.getLastLocationForTargetTime(t(4, 9)));
    assertEquals(p1, entry.getLastLocationForTargetTime(t(4, 10)));
    assertEquals(p1, entry.getLastLocationForTargetTime(t(5, 12)));
    assertEquals(p1, entry.getLastLocationForTargetTime(t(8, 19)));
    assertEquals(p2, entry.getLastLocationForTargetTime(t(8, 20)));
    assertEquals(p2, entry.getLastLocationForTargetTime(t(10, 0)));
    assertEquals(p2, entry.getLastLocationForTargetTime(t(12, 29)));
    assertEquals(p3, entry.getLastLocationForTargetTime(t(12, 30)));
    assertEquals(p3, entry.getLastLocationForTargetTime(t(16, 40)));
    assertTrue(Double.isNaN(entry.getLastOrientationForTargetTime(t(3, 20))));
    assertTrue(Double.isNaN(entry.getLastOrientationForTargetTime(t(4, 9))));
    assertEquals(0.0, entry.getLastOrientationForTargetTime(t(4, 10)), 0.0);
    assertEquals(0.0, entry.getLastOrientationForTargetTime(t(5, 12)), 0.0);
    assertEquals(0.0, entry.getLastOrientationForTargetTime(t(8, 19)), 0.0);
    assertEquals(90.0, entry.getLastOrientationForTargetTime(t(8, 20)), 0.0);
    assertEquals(90.0, entry.getLastOrientationForTargetTime(t(10, 0)), 0.0);
    assertEquals(90.0, entry.getLastOrientationForTargetTime(t(12, 29)), 0.0);
    assertEquals(45.0, entry.getLastOrientationForTargetTime(t(12, 30)), 0.0);
    assertEquals(45.0, entry.getLastOrientationForTargetTime(t(16, 40)), 0.0);
    assertNull(entry.getPhaseForTargetTime(t(3, 20)));
    assertNull(entry.getPhaseForTargetTime(t(4, 9)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(4, 10)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(5, 12)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(8, 19)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(8, 20)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(10, 0)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(12, 29)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(12, 30)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(16, 40)));
    assertNull(entry.getStatusForTargetTime(t(3, 20)));
    assertNull(entry.getStatusForTargetTime(t(4, 9)));
    assertEquals("ok", entry.getStatusForTargetTime(t(4, 10)));
    assertEquals("ok", entry.getStatusForTargetTime(t(5, 12)));
    assertEquals("ok", entry.getStatusForTargetTime(t(8, 19)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(8, 20)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(10, 0)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(12, 29)));
    assertEquals("ok", entry.getStatusForTargetTime(t(12, 30)));
    assertEquals("ok", entry.getStatusForTargetTime(t(16, 40)));
    CoordinatePoint p4 = new CoordinatePoint(47.15, -122.15);
    entry = entry.addRecord(blockInstance, record(t(10, 0), 20, 220, p4, 270.0, layover, "not ok"), t(5, 0));
    assertEquals(t(6, 40), entry.getFromTime());
    assertEquals(t(11, 40), entry.getToTime());
    assertEquals(18, entry.getScheduleDeviationForTargetTime(t(6, 40)), 0.0);
    assertEquals(18, entry.getScheduleDeviationForTargetTime(t(8, 20)), 0.0);
    assertEquals(19, entry.getScheduleDeviationForTargetTime(t(9, 10)), 0.0);
    assertEquals(20, entry.getScheduleDeviationForTargetTime(t(10, 00)), 0.0);
    assertEquals(20, entry.getScheduleDeviationForTargetTime(t(10, 50)), 0.0);
    assertEquals(20, entry.getScheduleDeviationForTargetTime(t(11, 40)), 0.0);
    assertEquals(180, entry.getDistanceAlongBlockForTargetTime(t(6, 40)), 0.0);
    assertEquals(200, entry.getDistanceAlongBlockForTargetTime(t(8, 20)), 0.0);
    assertEquals(210, entry.getDistanceAlongBlockForTargetTime(t(9, 10)), 0.0);
    assertEquals(220, entry.getDistanceAlongBlockForTargetTime(t(10, 00)), 0.0);
    assertEquals(230, entry.getDistanceAlongBlockForTargetTime(t(10, 50)), 0.0);
    assertEquals(240, entry.getDistanceAlongBlockForTargetTime(t(11, 40)), 0.0);
    assertNull(entry.getLastLocationForTargetTime(t(6, 40)));
    assertEquals(p2, entry.getLastLocationForTargetTime(t(8, 20)));
    assertEquals(p2, entry.getLastLocationForTargetTime(t(9, 10)));
    assertEquals(p4, entry.getLastLocationForTargetTime(t(10, 00)));
    assertEquals(p4, entry.getLastLocationForTargetTime(t(10, 50)));
    assertTrue(Double.isNaN(entry.getLastOrientationForTargetTime(t(6, 40))));
    assertEquals(90.0, entry.getLastOrientationForTargetTime(t(8, 20)), 0.0);
    assertEquals(90.0, entry.getLastOrientationForTargetTime(t(9, 10)), 0.0);
    assertEquals(270.0, entry.getLastOrientationForTargetTime(t(10, 00)), 0.0);
    assertEquals(270.0, entry.getLastOrientationForTargetTime(t(10, 50)), 0.0);
    assertNull(entry.getPhaseForTargetTime(t(6, 40)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(8, 20)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(9, 10)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(10, 00)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(10, 50)));
    assertNull(entry.getStatusForTargetTime(t(6, 40)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(8, 20)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(9, 10)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(10, 00)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(10, 50)));
    CoordinatePoint p5 = new CoordinatePoint(47.4, -122.4);
    entry = entry.addRecord(blockInstance, record(t(16, 40), 14, 500, p5, 180.0, inProgress, "ok"), t(6, 40));
    assertEquals(t(10, 00), entry.getFromTime());
    assertEquals(t(16, 40), entry.getToTime());
    assertEquals(20, entry.getScheduleDeviationForTargetTime(t(9, 10)), 0.0);
    assertEquals(17, entry.getScheduleDeviationForTargetTime(t(13, 20)), 0.0);
    assertEquals(14, entry.getScheduleDeviationForTargetTime(t(16, 40)), 0.0);
    assertEquals(220, entry.getDistanceAlongBlockForTargetTime(t(10, 00)), 0.0);
    assertEquals(360, entry.getDistanceAlongBlockForTargetTime(t(13, 20)), 0.0);
    assertEquals(500, entry.getDistanceAlongBlockForTargetTime(t(16, 40)), 0.0);
    assertEquals(640, entry.getDistanceAlongBlockForTargetTime(t(20, 00)), 0.0);
    assertNull(entry.getLastLocationForTargetTime(t(6, 40)));
    assertEquals(p4, entry.getLastLocationForTargetTime(t(10, 00)));
    assertEquals(p4, entry.getLastLocationForTargetTime(t(13, 20)));
    assertEquals(p5, entry.getLastLocationForTargetTime(t(16, 40)));
    assertEquals(p5, entry.getLastLocationForTargetTime(t(20, 00)));
    assertTrue(Double.isNaN(entry.getLastOrientationForTargetTime(t(6, 40))));
    assertEquals(270.0, entry.getLastOrientationForTargetTime(t(10, 00)), 0.0);
    assertEquals(270.0, entry.getLastOrientationForTargetTime(t(13, 20)), 0.0);
    assertEquals(180.0, entry.getLastOrientationForTargetTime(t(16, 40)), 0.0);
    assertEquals(180.0, entry.getLastOrientationForTargetTime(t(20, 00)), 0.0);
    assertNull(entry.getPhaseForTargetTime(t(6, 40)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(10, 00)));
    assertEquals(layover, entry.getPhaseForTargetTime(t(13, 20)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(16, 40)));
    assertEquals(inProgress, entry.getPhaseForTargetTime(t(20, 00)));
    assertNull(entry.getStatusForTargetTime(t(6, 40)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(10, 00)));
    assertEquals("not ok", entry.getStatusForTargetTime(t(13, 20)));
    assertEquals("ok", entry.getStatusForTargetTime(t(16, 40)));
    assertEquals("ok", entry.getStatusForTargetTime(t(20, 00)));
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) EVehiclePhase(org.onebusaway.realtime.api.EVehiclePhase) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) TreeMap(java.util.TreeMap) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) Test(org.junit.Test)

Example 33 with BlockEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl in project onebusaway-application-modules by camsys.

the class VehicleLocationRecordCacheImplTest method testClearCache.

@Test
public void testClearCache() throws InterruptedException {
    long serviceDate = System.currentTimeMillis();
    BlockEntryImpl blockA = block("blockA");
    TripEntryImpl tripA = trip("tripA", "serviceId");
    stopTime(0, null, tripA, time(9, 00), 0);
    BlockConfigurationEntry blockConfigA = linkBlockTrips(blockA, tripA);
    BlockInstance instanceA = new BlockInstance(blockConfigA, serviceDate);
    BlockEntryImpl blockB = block("blockB");
    TripEntryImpl tripB = trip("tripB", "serviceId");
    stopTime(0, null, tripB, time(9, 00), 0);
    BlockConfigurationEntry blockConfigB = linkBlockTrips(blockB, tripB);
    BlockInstance instanceB = new BlockInstance(blockConfigB, serviceDate);
    VehicleLocationRecordCacheImpl cache = new VehicleLocationRecordCacheImpl();
    cache.setBlockLocationRecordCacheWindowSize(20);
    cache.addRecord(instanceA, record(20, "blockA", serviceDate, "vehicleA", 10.0), null, null);
    Thread.sleep(100);
    cache.addRecord(instanceB, record(30, "blockB", serviceDate, "vehicleB", 20.0), null, null);
    Thread.sleep(100);
    cache.addRecord(instanceA, record(40, "blockA", serviceDate, "vehicleC", 20.0), null, null);
    Thread.sleep(100);
    cache.addRecord(instanceB, record(50, "blockB", serviceDate, "vehicleD", 20.0), null, null);
    cache.clearStaleRecords(System.currentTimeMillis() - 150);
    VehicleLocationCacheElements cacheRecord = cache.getRecordForVehicleId(aid("vehicleA"));
    assertNull(cacheRecord);
    cacheRecord = cache.getRecordForVehicleId(aid("vehicleB"));
    assertNull(cacheRecord);
    cacheRecord = cache.getRecordForVehicleId(aid("vehicleC"));
    assertEquals(aid("vehicleC"), cacheRecord.getLastElement().getRecord().getVehicleId());
    cacheRecord = cache.getRecordForVehicleId(aid("vehicleD"));
    assertEquals(aid("vehicleD"), cacheRecord.getLastElement().getRecord().getVehicleId());
    List<VehicleLocationCacheElements> records = cache.getRecordsForBlockInstance(instanceA);
    assertEquals(1, records.size());
    records = cache.getRecordsForBlockInstance(instanceB);
    assertEquals(1, records.size());
}
Also used : VehicleLocationCacheElements(org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) Test(org.junit.Test)

Example 34 with BlockEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl in project onebusaway-application-modules by camsys.

the class VehicleLocationRecordCacheImplTest method testConcurrentOperations.

@Test
public void testConcurrentOperations() {
    VehicleLocationRecordCacheImpl cache = new VehicleLocationRecordCacheImpl();
    cache.setBlockLocationRecordCacheWindowSize(2);
    long serviceDate = System.currentTimeMillis();
    int vid = 0;
    for (int i = 0; i < 20; i++) {
        BlockEntryImpl block = block(Integer.toString(i));
        TripEntryImpl trip = trip(Integer.toString(i), "serviceId");
        stopTime(0, null, trip, time(9, 00), 0);
        BlockConfigurationEntry blockConfig = linkBlockTrips(block, trip);
        BlockInstance blockInstance = new BlockInstance(blockConfig, serviceDate);
        for (int j = 0; j < 5; j++) {
            AgencyAndId vehicleId = new AgencyAndId("1", Integer.toString(vid++));
            RecordSource source = new RecordSource(blockInstance, vehicleId, cache);
            Thread thread = new Thread(source);
            thread.run();
        }
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) Test(org.junit.Test)

Example 35 with BlockEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl in project onebusaway-application-modules by camsys.

the class GtfsRealtimeTripLibraryTest method testCreateVehicleLocationRecordForUpdate_FutureDay.

// Ensure that if we get an update for a future day we propagate a prediction for that day.
// (This is equivalent to timestamp on feed being early incorrectly, since currentTime in
// GtfsRealtimeTripLibrary is set via the timestamp.)
@Test
public void testCreateVehicleLocationRecordForUpdate_FutureDay() {
    final long day = TimeUnit.DAYS.toMillis(1);
    StopTimeUpdate.Builder stopTimeUpdate = stopTimeUpdateWithDepartureDelay("stopA", 180);
    TripUpdate.Builder tripUpdate = tripUpdate("tripA", (_library.getCurrentTime() + day) / 1000, 120, stopTimeUpdate);
    TripEntryImpl tripA = trip("tripA");
    stopTime(0, stop("stopA", 0, 0), tripA, time(7, 30), 0.0);
    BlockEntryImpl blockA = block("blockA");
    BlockConfigurationEntry blockConfigA = blockConfiguration(blockA, serviceIds("s1"), tripA);
    BlockInstance blockInstanceA = new BlockInstance(blockConfigA, 0L);
    BlockInstance blockInstanceB = new BlockInstance(blockConfigA, day);
    Mockito.when(_entitySource.getTrip("tripA")).thenReturn(tripA);
    Mockito.when(_blockCalendarService.getActiveBlocks(Mockito.eq(blockA.getId()), Mockito.anyLong(), Mockito.longThat(new ArgumentMatcher<Long>() {

        @Override
        public boolean matches(Object argument) {
            return ((Long) argument) < day;
        }
    }))).thenReturn(Arrays.asList(blockInstanceA));
    Mockito.when(_blockCalendarService.getActiveBlocks(Mockito.eq(blockA.getId()), Mockito.anyLong(), Mockito.longThat(new ArgumentMatcher<Long>() {

        @Override
        public boolean matches(Object argument) {
            return ((Long) argument) >= day;
        }
    }))).thenReturn(Arrays.asList(blockInstanceB));
    FeedMessage.Builder TU = createFeed();
    TU.addEntity(feed(tripUpdate));
    FeedMessage.Builder VP = createFeed();
    List<CombinedTripUpdatesAndVehiclePosition> updates = _library.groupTripUpdatesAndVehiclePositions(TU.build(), VP.build());
    CombinedTripUpdatesAndVehiclePosition update = updates.get(0);
    VehicleLocationRecord record = _library.createVehicleLocationRecordForUpdate(update);
    TimepointPredictionRecord tpr = record.getTimepointPredictions().get(0);
    long departure = tpr.getTimepointPredictedDepartureTime();
    // 7:30 + 3 min delay + on next day
    assertEquals(departure, time(7, 33) * 1000 + day);
}
Also used : TripUpdate(com.google.transit.realtime.GtfsRealtime.TripUpdate) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) FeedMessage(com.google.transit.realtime.GtfsRealtime.FeedMessage) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ArgumentMatcher(org.mockito.ArgumentMatcher) StopTimeUpdate(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate) VehicleLocationRecord(org.onebusaway.realtime.api.VehicleLocationRecord) TimepointPredictionRecord(org.onebusaway.realtime.api.TimepointPredictionRecord) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) Test(org.junit.Test)

Aggregations

BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)43 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)34 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)34 Test (org.junit.Test)33 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)25 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)16 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)15 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)11 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)9 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)8 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)7 TargetTime (org.onebusaway.transit_data_federation.model.TargetTime)7 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)7 Date (java.util.Date)6 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)6 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)6 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)6 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)5 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)5 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)5