ScheduledBlockLocationServiceImpl implements
    ScheduledBlockLocationService { @Override public ScheduledBlockLocation getScheduledBlockLocationFromScheduledTime( BlockConfigurationEntry blockConfig, int scheduleTime) { List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes(); int n = stopTimes.size(); int index = GenericBinarySearch.search(blockConfig, n, scheduleTime, IndexAdapters.BLOCK_STOP_TIME_DEPARTURE_INSTANCE); return getScheduledBlockLocationFromScheduleTimeAndStopTimeIndex(stopTimes, scheduleTime, index); }  @Autowired void setShapePointService(ShapePointService shapePointService); @Override ScheduledBlockLocation getScheduledBlockLocationFromDistanceAlongBlock(
      BlockConfigurationEntry blockConfig, double distanceAlongBlock); @Override ScheduledBlockLocation getScheduledBlockLocationFromDistanceAlongBlock(
      ScheduledBlockLocation previousLocation, double distanceAlongBlock); @Override ScheduledBlockLocation getScheduledBlockLocationFromScheduledTime(
      BlockConfigurationEntry blockConfig, int scheduleTime); @Override ScheduledBlockLocation getScheduledBlockLocationFromScheduledTime(
      ScheduledBlockLocation previousLocation, int scheduleTime);  }
@Test public void test04() { ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime( _blockConfig, time(10, 12)); assertEquals(_tripA, position.getActiveTrip()); assertEquals(_stopTimeB, position.getClosestStop()); assertEquals(0, position.getClosestStopTimeOffset()); assertEquals(_stopTimeA, position.getPreviousStop()); assertEquals(_stopTimeB, position.getNextStop()); assertEquals(0, position.getNextStopTimeOffset()); assertEquals(800, position.getDistanceAlongBlock(), 0.0); assertEquals(_stopB.getStopLat(), position.getLocation().getLat(), 1e-6); assertEquals(_stopB.getStopLon(), position.getLocation().getLon(), 1e-6); assertEquals(318.3, position.getOrientation(), 0.1); assertEquals(time(10, 12), position.getScheduledTime()); assertTrue(position.isInService()); }
@Test public void test05() { ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime( _blockConfig, time(10, 17)); assertEquals(_tripA, position.getActiveTrip()); assertEquals(_stopTimeB, position.getClosestStop()); assertEquals(-120, position.getClosestStopTimeOffset()); assertEquals(_stopTimeB, position.getPreviousStop()); assertEquals(_stopTimeC, position.getNextStop()); assertEquals(180, position.getNextStopTimeOffset()); assertEquals(960, position.getDistanceAlongBlock(), 0.0); assertEquals(47.66471023595962, position.getLocation().getLat(), 1e-6); assertEquals(-122.37984571150027, position.getLocation().getLon(), 1e-6); assertEquals(328.5, position.getOrientation(), 0.1); assertTrue(position.isInService()); assertEquals(2, position.getStopTimeIndex()); }
@Test public void test06() { ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime( _blockConfig, time(10, 18)); assertEquals(_tripB, position.getActiveTrip()); assertEquals(_stopTimeC, position.getClosestStop()); assertEquals(120, position.getClosestStopTimeOffset()); assertEquals(_stopTimeB, position.getPreviousStop()); assertEquals(_stopTimeC, position.getNextStop()); assertEquals(120, position.getNextStopTimeOffset()); assertEquals(1040, position.getDistanceAlongBlock(), 0.0); assertEquals(47.6642256894362, position.getLocation().getLat(), 1e-6); assertEquals(-122.3790560454492, position.getLocation().getLon(), 1e-6); assertEquals(328.5, position.getOrientation(), 0.1); }
@Test public void test07() { ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime( _blockConfig, time(10, 20)); assertEquals(_tripB, position.getActiveTrip()); assertEquals(_stopTimeC, position.getClosestStop()); assertEquals(0, position.getClosestStopTimeOffset()); assertEquals(_stopTimeB, position.getPreviousStop()); assertEquals(_stopTimeC, position.getNextStop()); assertEquals(0, position.getNextStopTimeOffset()); assertEquals(1200, position.getDistanceAlongBlock(), 0.0); assertEquals(_stopC.getStopLat(), position.getLocation().getLat(), 1e-6); assertEquals(_stopC.getStopLon(), position.getLocation().getLon(), 1e-6); assertEquals(0.0, position.getOrientation(), 0.1); assertTrue(position.isInService()); assertEquals(2, position.getStopTimeIndex()); }
@Test public void testHint02() { ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime( _blockConfig, time(10, 12)); ScheduledBlockLocation next = _service.getScheduledBlockLocationFromScheduledTime( position, time(10, 12)); assertEquals(time(10, 12), next.getScheduledTime()); assertEquals(800, next.getDistanceAlongBlock(), 0.0); assertEquals(1, next.getStopTimeIndex()); next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 17)); assertEquals(time(10, 17), next.getScheduledTime()); assertEquals(960, next.getDistanceAlongBlock(), 0.0); assertEquals(2, next.getStopTimeIndex()); }