use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method getBlockTripsAsLayoverInterval.
private LayoverIntervalBlock getBlockTripsAsLayoverInterval(List<BlockTripEntry> trips) {
int n = trips.size();
int[] startTimes = new int[n];
int[] endTimes = new int[n];
int index = 0;
for (BlockTripEntry trip : trips) {
startTimes[index] = BlockTripLayoverTimeComparator.getLayoverStartTimeForTrip(trip);
endTimes[index] = BlockTripLayoverTimeComparator.getLayoverEndTimeForTrip(trip);
index++;
}
return new LayoverIntervalBlock(startTimes, endTimes);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockTripLayoverTimeComparator method getLayoverStartTimeForTrip.
public static int getLayoverStartTimeForTrip(BlockTripEntry blockTrip) {
BlockTripEntry prevTrip = blockTrip.getPreviousTrip();
if (prevTrip == null)
throw new IllegalStateException("blockTrip had no incoming trip, thus no layover");
List<BlockStopTimeEntry> stopTimes = prevTrip.getStopTimes();
BlockStopTimeEntry blockStopTime = stopTimes.get(stopTimes.size() - 1);
StopTimeEntry stopTime = blockStopTime.getStopTime();
return stopTime.getDepartureTime();
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockConfigurationEntryImpl method getDistanceAlongBlockForIndex.
@Override
public double getDistanceAlongBlockForIndex(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 blockTrip.getDistanceAlongBlock() + stopTime.getShapeDistTraveled();
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class AbstractBlockStopTimeIndex method computeServiceInterval.
/**
***
* Private Methods
***
*/
protected static ServiceInterval computeServiceInterval(HasBlockTrips blockIndex, int blockSequence) {
ServiceInterval serviceInterval = null;
List<BlockTripEntry> trips = blockIndex.getTrips();
for (BlockTripEntry trip : trips) {
BlockStopTimeEntry blockStopTime = trip.getStopTimes().get(blockSequence);
StopTimeEntry stopTime = blockStopTime.getStopTime();
serviceInterval = ServiceInterval.extend(serviceInterval, stopTime.getArrivalTime(), stopTime.getDepartureTime());
}
return serviceInterval;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class StopTimeServiceImplTest method addFirstStopToBlockIndex.
/**
**
* Private Methods
***
*/
private void addFirstStopToBlockIndex(BlockConfigurationEntry... blocks) {
List<BlockTripEntry> trips = new ArrayList<BlockTripEntry>();
for (BlockConfigurationEntry blockConfig : blocks) {
trips.add(blockConfig.getTrips().get(0));
}
BlockTripIndex blockIndex = _factory.createTripIndexForGroupOfBlockTrips(trips);
BlockStopTimeIndex index = BlockStopTimeIndex.create(blockIndex, 0);
_stop.addStopTimeIndex(index);
Mockito.when(_blockIndexService.getStopTimeIndicesForStop(_stop)).thenReturn(_stop.getStopTimeIndices());
}
Aggregations