use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class BlockGeospatialServiceImpl method getActiveScheduledBlocksPassingThroughBounds.
@Override
public List<BlockInstance> getActiveScheduledBlocksPassingThroughBounds(CoordinateBounds bounds, long timeFrom, long timeTo) {
List<StopEntry> stops = _transitGraphDao.getStopsByLocation(bounds);
Set<AgencyAndId> blockIds = new HashSet<AgencyAndId>();
for (StopEntry stop : stops) {
List<BlockStopTimeIndex> stopTimeIndices = _blockIndexService.getStopTimeIndicesForStop(stop);
Set<BlockConfigurationEntry> blockConfigs = new HashSet<BlockConfigurationEntry>();
List<List<BlockConfigurationEntry>> blockConfigsList = MappingLibrary.map(stopTimeIndices, "blockConfigs");
for (List<BlockConfigurationEntry> l : blockConfigsList) {
blockConfigs.addAll(l);
}
List<AgencyAndId> stopBlockIds = MappingLibrary.map(blockConfigs, "block.id");
blockIds.addAll(stopBlockIds);
}
Set<BlockTripIndex> blockIndices = new HashSet<BlockTripIndex>();
for (AgencyAndId blockId : blockIds) {
blockIndices.addAll(_blockIndexService.getBlockTripIndicesForBlock(blockId));
}
List<BlockLayoverIndex> layoverIndices = Collections.emptyList();
List<FrequencyBlockTripIndex> frequencyIndices = Collections.emptyList();
return _blockCalendarService.getActiveBlocksInTimeRange(blockIndices, layoverIndices, frequencyIndices, timeFrom, timeTo);
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class BlockIndexServiceImpl method loadStopTimeIndices.
private void loadStopTimeIndices() {
// Clear any existing indices
for (StopEntry stop : _graphDao.getAllStops()) {
StopEntryImpl stopImpl = (StopEntryImpl) stop;
stopImpl.getStopTimeIndices().clear();
stopImpl.getFrequencyStopTimeIndices().clear();
}
BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();
factory.setVerbose(true);
List<BlockStopTimeIndex> indices = factory.createIndices(_graphDao.getAllBlocks());
for (BlockStopTimeIndex index : indices) {
StopEntryImpl stop = (StopEntryImpl) index.getStop();
stop.addStopTimeIndex(index);
}
List<FrequencyBlockStopTimeIndex> frequencyIndices = factory.createFrequencyIndices(_graphDao.getAllBlocks());
for (FrequencyBlockStopTimeIndex index : frequencyIndices) {
StopEntryImpl stop = (StopEntryImpl) index.getStop();
stop.addFrequencyStopTimeIndex(index);
}
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex in project onebusaway-application-modules by camsys.
the class BlockStopTimeIndicesFactory method createIndicesFromGroups.
/**
**
*
***
*/
private List<BlockStopTimeIndex> createIndicesFromGroups(Map<BlockStopTimeKey, List<BlockStopTimeEntry>> stopTimesByKey) {
List<BlockStopTimeIndex> allIndices = new ArrayList<BlockStopTimeIndex>();
int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(allIndices.size()) * 10;
int count = 0;
for (List<BlockStopTimeEntry> stopTimes : stopTimesByKey.values()) {
if (_verbose && count % logInterval == 0)
_log.info("groups processed: " + count + "/" + stopTimesByKey.size());
count++;
List<List<BlockStopTimeEntry>> groupedStopTimes = BlockLibrary.createStrictlyOrderedGroups(stopTimes, _blockStopTimeLooseComparator, _blockStopTimeStrictComparator);
for (List<BlockStopTimeEntry> group : groupedStopTimes) {
BlockStopTimeIndex index = createBlockStopTimeIndexForGroup(group);
allIndices.add(index);
}
}
return allIndices;
}
Aggregations