use of org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImplTest method test06.
@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);
}
use of org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImplTest method test07.
@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());
}
use of org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImplTest method testHint00.
@Test
public void testHint00() {
ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime(_blockConfig, time(9, 55));
ScheduledBlockLocation next = _service.getScheduledBlockLocationFromScheduledTime(position, time(9, 55));
assertEquals(time(9, 55), next.getScheduledTime());
assertEquals(0, next.getDistanceAlongBlock(), 0.0);
assertEquals(0, next.getStopTimeIndex());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(9, 58));
assertEquals(time(9, 58), next.getScheduledTime());
assertEquals(80, next.getDistanceAlongBlock(), 0.0);
assertEquals(0, next.getStopTimeIndex());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 00));
assertEquals(time(10, 00), next.getScheduledTime());
assertEquals(200, next.getDistanceAlongBlock(), 0.0);
assertEquals(0, next.getStopTimeIndex());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 05));
assertEquals(time(10, 05), next.getScheduledTime());
assertEquals(500, next.getDistanceAlongBlock(), 0.0);
assertEquals(1, next.getStopTimeIndex());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 10));
assertEquals(time(10, 10), 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());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 20));
assertEquals(time(10, 20), next.getScheduledTime());
assertEquals(1200, next.getDistanceAlongBlock(), 0.0);
assertEquals(2, next.getStopTimeIndex());
next = _service.getScheduledBlockLocationFromScheduledTime(position, time(10, 25));
assertNull(next);
/**
**
*
***
*/
position = _service.getScheduledBlockLocationFromDistanceAlongBlock(_blockConfig, -100);
assertNull(position);
}
use of org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImplTest method test02.
@Test
public void test02() {
ScheduledBlockLocation position = _service.getScheduledBlockLocationFromScheduledTime(_blockConfig, time(10, 02));
assertEquals(_tripA, position.getActiveTrip());
assertEquals(_stopTimeA, position.getClosestStop());
assertEquals(-120, position.getClosestStopTimeOffset());
assertEquals(_stopTimeA, position.getPreviousStop());
assertEquals(_stopTimeB, position.getNextStop());
assertEquals(480, position.getNextStopTimeOffset());
assertEquals(320.0, position.getDistanceAlongBlock(), 0.0);
assertEquals(47.668651, position.getLocation().getLat(), 1e-6);
assertEquals(-122.385467, position.getLocation().getLon(), 1e-6);
assertEquals(2.4, position.getOrientation(), 0.1);
assertEquals(time(10, 02), position.getScheduledTime());
assertTrue(position.isInService());
assertEquals(1, position.getStopTimeIndex());
position = _service.getScheduledBlockLocationFromDistanceAlongBlock(_blockConfig, 320.0);
assertEquals(_tripA, position.getActiveTrip());
assertEquals(_stopTimeA, position.getClosestStop());
assertEquals(-120, position.getClosestStopTimeOffset());
assertEquals(_stopTimeA, position.getPreviousStop());
assertEquals(_stopTimeB, position.getNextStop());
assertEquals(480, position.getNextStopTimeOffset());
assertEquals(320.0, position.getDistanceAlongBlock(), 0.0);
assertEquals(47.668651, position.getLocation().getLat(), 1e-6);
assertEquals(-122.385467, position.getLocation().getLon(), 1e-6);
assertEquals(2.4, position.getOrientation(), 0.1);
assertEquals(time(10, 02), position.getScheduledTime());
assertTrue(position.isInService());
assertEquals(1, position.getStopTimeIndex());
}
use of org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation in project onebusaway-application-modules by camsys.
the class BlockLocationServiceImplTest method testWithShapeInfo.
@Test
public void testWithShapeInfo() {
StopEntryImpl stopA = stop("a", 47.5, -122.5);
StopEntryImpl stopB = stop("b", 47.6, -122.4);
StopEntryImpl stopC = stop("c", 47.5, -122.3);
BlockEntryImpl block = block("block");
TripEntryImpl tripA = trip("tripA", "serviceId");
TripEntryImpl tripB = trip("tripB", "serviceId");
stopTime(0, stopA, tripA, 30, 90, 0);
stopTime(1, stopB, tripA, 120, 120, 100);
stopTime(2, stopC, tripA, 180, 210, 200);
stopTime(3, stopC, tripB, 240, 240, 300);
stopTime(4, stopB, tripB, 270, 270, 400);
stopTime(5, stopA, tripB, 300, 300, 500);
BlockConfigurationEntry blockConfig = linkBlockTrips(block, tripA, tripB);
long serviceDate = 1000 * 1000;
double epsilon = 0.001;
TargetTime target = new TargetTime(t(serviceDate, 0, 0), System.currentTimeMillis());
BlockInstance blockInstance = new BlockInstance(blockConfig, serviceDate);
BlockLocation location = _service.getLocationForBlockInstance(blockInstance, target);
assertNull(location);
ScheduledBlockLocation p = new ScheduledBlockLocation();
p.setActiveTrip(blockConfig.getTrips().get(0));
p.setClosestStop(blockConfig.getStopTimes().get(0));
p.setClosestStopTimeOffset(0);
p.setDistanceAlongBlock(0);
p.setLocation(new CoordinatePoint(stopA.getStopLat(), stopA.getStopLon()));
p.setInService(true);
Mockito.when(_blockLocationService.getScheduledBlockLocationFromScheduledTime(blockConfig, 1800)).thenReturn(p);
target = new TargetTime(t(serviceDate, 0, 30), System.currentTimeMillis());
location = _service.getLocationForBlockInstance(blockInstance, target);
assertTrue(location.isInService());
assertEquals(blockConfig.getStopTimes().get(0), location.getClosestStop());
assertEquals(0, location.getClosestStopTimeOffset());
assertEquals(stopA.getStopLocation(), location.getLocation());
assertFalse(location.isScheduleDeviationSet());
assertTrue(Double.isNaN(location.getScheduleDeviation()));
assertFalse(location.isDistanceAlongBlockSet());
assertTrue(Double.isNaN(location.getDistanceAlongBlock()));
assertEquals(blockInstance, location.getBlockInstance());
assertEquals(0, location.getLastUpdateTime());
assertEquals(blockConfig.getTrips().get(0), location.getActiveTrip());
assertNull(location.getVehicleId());
assertEquals(47.5, location.getLocation().getLat(), epsilon);
assertEquals(-122.5, location.getLocation().getLon(), epsilon);
assertEquals(blockConfig.getStopTimes().get(0), location.getClosestStop());
assertEquals(0, location.getClosestStopTimeOffset());
}
Aggregations