use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class StopScheduleBeanServiceImpl method groupStopTimeInstancesByRouteCollectionId.
private void groupStopTimeInstancesByRouteCollectionId(StopEntry stopEntry, ServiceDate date, Map<AgencyAndId, List<StopTimeInstance>> stopTimesByRouteCollectionId, Map<AgencyAndId, List<StopTimeInstance>> frequenciesByRouteCollectionId) {
Map<AgencyAndId, Set<FrequencyEntry>> frequencyLabelsByRouteCollectionId = new FactoryMap<AgencyAndId, Set<FrequencyEntry>>(new HashSet<FrequencyEntry>());
for (BlockStopTimeIndex index : _blockIndexService.getStopTimeIndicesForStop(stopEntry)) {
ServiceIdActivation serviceIds = index.getServiceIds();
Set<ServiceDate> serviceDates = _calendarService.getServiceDatesForServiceIds(serviceIds);
if (!serviceDates.contains(date))
continue;
Date serviceDate = date.getAsDate(serviceIds.getTimeZone());
for (BlockStopTimeEntry stopTime : index.getStopTimes()) {
BlockTripEntry blockTrip = stopTime.getTrip();
TripEntry trip = blockTrip.getTrip();
AgencyAndId routeCollectionId = trip.getRouteCollection().getId();
FrequencyEntry frequencyLabel = trip.getFrequencyLabel();
InstanceState state = new InstanceState(serviceDate.getTime(), frequencyLabel);
StopTimeInstance sti = new StopTimeInstance(stopTime, state);
if (frequencyLabel == null) {
stopTimesByRouteCollectionId.get(routeCollectionId).add(sti);
} else if (frequencyLabelsByRouteCollectionId.get(routeCollectionId).add(frequencyLabel)) {
frequenciesByRouteCollectionId.get(routeCollectionId).add(sti);
}
}
}
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class StopTimeServiceImpl method getStopTimeInstancesInTimeRange.
@Override
public List<StopTimeInstance> getStopTimeInstancesInTimeRange(StopEntry stopEntry, Date from, Date to, EFrequencyStopTimeBehavior frequencyBehavior) {
List<StopTimeInstance> stopTimeInstances = new ArrayList<StopTimeInstance>();
for (BlockStopTimeIndex index : _blockIndexService.getStopTimeIndicesForStop(stopEntry)) {
Collection<Date> serviceDates = _calendarService.getServiceDatesWithinRange(index.getServiceIds(), index.getServiceInterval(), from, to);
for (Date serviceDate : serviceDates) {
getStopTimesForStopAndServiceDateAndTimeRange(index, serviceDate, from, to, stopTimeInstances);
}
}
List<FrequencyStopTripIndex> frequencyStopTripIndices = _blockIndexService.getFrequencyStopTripIndicesForStop(stopEntry);
for (FrequencyStopTripIndex index : frequencyStopTripIndices) {
Collection<Date> serviceDates = _calendarService.getServiceDatesWithinRange(index.getServiceIds(), index.getServiceInterval(), from, to);
for (Date serviceDate : serviceDates) {
getFrequenciesForStopAndServiceIdsAndTimeRange(index, serviceDate, from, to, stopTimeInstances, frequencyBehavior);
}
}
return stopTimeInstances;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class StopTimeServiceImpl method getDepartureForStopAndServiceDate.
@Override
public Range getDepartureForStopAndServiceDate(AgencyAndId stopId, ServiceDate serviceDate) {
StopEntry stop = _graph.getStopEntryForId(stopId, true);
List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stop);
Range interval = new Range();
for (BlockStopTimeIndex index : indices) {
extendIntervalWithIndex(serviceDate, interval, index);
}
List<FrequencyBlockStopTimeIndex> freqIndices = _blockIndexService.getFrequencyStopTimeIndicesForStop(stop);
for (FrequencyBlockStopTimeIndex index : freqIndices) extendIntervalWithIndex(serviceDate, interval, index);
return interval;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class BlockStopTimeIndicesFactory method createBlockStopTimeIndexForGroup.
private BlockStopTimeIndex createBlockStopTimeIndexForGroup(List<BlockStopTimeEntry> group) {
int n = group.size();
List<BlockConfigurationEntry> blockConfigs = new ArrayList<BlockConfigurationEntry>(n);
int[] stopIndices = new int[n];
ServiceInterval interval = null;
for (int i = 0; i < n; i++) {
BlockStopTimeEntry blockStopTime = group.get(i);
StopTimeEntry stopTime = blockStopTime.getStopTime();
blockConfigs.add(blockStopTime.getTrip().getBlockConfiguration());
stopIndices[i] = blockStopTime.getBlockSequence();
interval = ServiceInterval.extend(interval, stopTime.getArrivalTime(), stopTime.getDepartureTime());
}
return new BlockStopTimeIndex(blockConfigs, stopIndices, interval);
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex 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