use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockConfigurationEntryImpl method getStopTimeForIndex.
/**
***
* Private Methods
***
*/
private StopTimeEntry getStopTimeForIndex(int index) {
int tripIndex = tripIndices[index];
BlockTripEntry blockTrip = trips.get(tripIndex);
TripEntry trip = blockTrip.getTrip();
List<StopTimeEntry> stopTimes = trip.getStopTimes();
int stopTimeIndex = index - accumulatedStopTimeIndices[tripIndex];
StopTimeEntry stopTime = stopTimes.get(stopTimeIndex);
return stopTime;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class RealTimeHistoryServiceImpl method getScheduleDeviationHistogramForArrivalAndDepartureInstance.
@Override
public ScheduleDeviationHistogram getScheduleDeviationHistogramForArrivalAndDepartureInstance(ArrivalAndDepartureInstance instance, int stepSizeInSeconds) {
BlockTripEntry blockTrip = instance.getBlockTrip();
TripEntry trip = blockTrip.getTrip();
AgencyAndId tripId = trip.getId();
ScheduleDeviationHistory history = _scheduleDeviationHistoryDao.getScheduleDeviationHistoryForTripId(tripId);
if (history == null)
return null;
BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
StopTimeEntry stopTime = blockStopTime.getStopTime();
double[] values = getScheduleDeviationsForScheduleTime(history, stopTime.getDepartureTime());
return createHistogramFromValues(values, stepSizeInSeconds);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class RealTimeHistoryServiceImpl method sampleScheduleDeviationsForVehicle.
@Override
public ScheduleDeviationSamples sampleScheduleDeviationsForVehicle(BlockInstance instance, VehicleLocationRecord record, ScheduledBlockLocation scheduledBlockLocation) {
if (scheduledBlockLocation == null)
return null;
BlockTripEntry blockTrip = scheduledBlockLocation.getActiveTrip();
TripEntry trip = blockTrip.getTrip();
ScheduleDeviationHistory history = _scheduleDeviationHistoryDao.getScheduleDeviationHistoryForTripId(trip.getId());
if (history == null)
return null;
ScheduleDeviationHistory resampledHistory = resampleHistory(history, scheduledBlockLocation.getScheduledTime(), record.getScheduleDeviation());
DoubleArrayList scheduleTimes = new DoubleArrayList();
DoubleArrayList mus = new DoubleArrayList();
DoubleArrayList sigmas = new DoubleArrayList();
for (int t = 0; t <= _predictionLookahead; t += 5 * 60) {
int scheduleTime = scheduledBlockLocation.getScheduledTime() + t;
double[] deviations = getScheduleDeviationsForScheduleTime(resampledHistory, scheduleTime);
deviations = noNans(deviations);
DoubleArrayList values = new DoubleArrayList(deviations);
double mu = Descriptive.mean(values);
double var = Descriptive.sampleVariance(values, mu);
double sigma = Descriptive.sampleStandardDeviation(values.size(), var);
scheduleTimes.add(scheduleTime);
mus.add(mu);
sigmas.add(sigma);
}
scheduleTimes.trimToSize();
mus.trimToSize();
sigmas.trimToSize();
return new ScheduleDeviationSamples(scheduleTimes.elements(), mus.elements(), sigmas.elements());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImplTest method before.
@Before
public void before() {
_service = new ScheduledBlockLocationServiceImpl();
_shapePointService = Mockito.mock(ShapePointService.class);
_service.setShapePointService(_shapePointService);
TripEntryImpl tripA = trip("A", "serviceId", 1000.0);
TripEntryImpl tripB = trip("B", "serviceId", 1000.0);
tripA.setShapeId(aid("shapeA"));
tripB.setShapeId(aid("shapeB"));
ShapePointsFactory m = new ShapePointsFactory();
m.setShapeId(aid("shapeA"));
m.addPoint(47.670170374084805, -122.3875880241394);
m.addPoint(47.66871094987642, -122.38756656646729);
m.addPoint(47.66862425012441, -122.38610744476318);
m.addPoint(47.66869649992775, -122.38439083099365);
m.addPoint(47.664852671516094, -122.3800778388977);
m.addPoint(47.664467962697906, -122.37945087847474);
Mockito.when(_shapePointService.getShapePointsForShapeId(aid("shapeA"))).thenReturn(m.create());
m = new ShapePointsFactory();
m.setShapeId(aid("shapeB"));
m.addPoint(47.664467962697906, -122.37945087847474);
m.addPoint(47.663667674849385, -122.37814664840698);
m.addPoint(47.663667674849385, -122.37355470657349);
Mockito.when(_shapePointService.getShapePointsForShapeId(aid("shapeB"))).thenReturn(m.create());
_stopA = stop("stopA", 47.66868114116101, -122.3870648978625);
_stopB = stop("stopB", 47.66583195331816, -122.38117664826683);
_stopC = stop("stopC", 47.663667674849385, -122.37724035677341);
stopTime(1, _stopA, tripA, time(10, 00), time(10, 00), 200, 1);
stopTime(2, _stopB, tripA, time(10, 10), time(10, 15), 800, 3);
stopTime(3, _stopC, tripB, time(10, 20), time(10, 20), 200, 1);
_blockConfig = linkBlockTrips("blockA", tripA, tripB);
List<BlockTripEntry> trips = _blockConfig.getTrips();
_tripA = trips.get(0);
_tripB = trips.get(1);
List<BlockStopTimeEntry> stopTimes = _blockConfig.getStopTimes();
_stopTimeA = stopTimes.get(0);
_stopTimeB = stopTimes.get(1);
_stopTimeC = stopTimes.get(2);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockLayoverIndexData method createIndex.
public BlockLayoverIndex createIndex(TransitGraphDao dao) {
List<BlockTripEntry> trips = new ArrayList<BlockTripEntry>();
for (BlockTripReference blockTripReference : _blockTripReferences) {
BlockTripEntry trip = ReferencesLibrary.getReferenceAsTrip(blockTripReference, dao);
trips.add(trip);
}
return new BlockLayoverIndex(trips, _layoverIntervalBlock);
}
Aggregations