use of org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createLayoverData.
public List<BlockLayoverIndexData> createLayoverData(Iterable<BlockEntry> blocks) {
List<BlockLayoverIndex> indices = createLayoverIndices(blocks);
List<BlockLayoverIndexData> allData = new ArrayList<BlockLayoverIndexData>();
for (BlockLayoverIndex index : indices) {
List<BlockTripReference> references = new ArrayList<BlockTripReference>();
for (BlockTripEntry trip : index.getTrips()) {
BlockTripReference ref = ReferencesLibrary.getTripAsReference(trip);
references.add(ref);
}
LayoverIntervalBlock layoverIntervalBlock = index.getLayoverIntervalBlock();
BlockLayoverIndexData data = new BlockLayoverIndexData(references, layoverIntervalBlock);
allData.add(data);
}
return allData;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData in project onebusaway-application-modules by camsys.
the class BlockIndicesTask method run.
@Override
public void run() {
try {
Iterable<BlockEntry> blocks = _transitGraphDao.getAllBlocks();
List<BlockTripIndexData> tripData = _blockIndexFactoryService.createTripData(blocks);
List<BlockLayoverIndexData> layoverData = _blockIndexFactoryService.createLayoverData(blocks);
List<FrequencyBlockTripIndexData> frequencyTripData = _blockIndexFactoryService.createFrequencyTripData(blocks);
ObjectSerializationLibrary.writeObject(_bundle.getBlockTripIndicesPath(), tripData);
ObjectSerializationLibrary.writeObject(_bundle.getBlockLayoverIndicesPath(), layoverData);
ObjectSerializationLibrary.writeObject(_bundle.getFrequencyBlockTripIndicesPath(), frequencyTripData);
BlockStopTimeIndicesFactory stopFactory = new BlockStopTimeIndicesFactory();
stopFactory.createIndices(blocks);
_refreshService.refresh(RefreshableResources.BLOCK_INDEX_DATA);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexServiceImpl method loadBlockLayoverIndices.
private void loadBlockLayoverIndices() throws IOException, ClassNotFoundException {
File path = _bundle.getBlockLayoverIndicesPath();
if (path.exists()) {
_log.info("loading block layover indices data");
List<BlockLayoverIndexData> datas = ObjectSerializationLibrary.readObject(path);
_blockLayoverIndices = new ArrayList<BlockLayoverIndex>(datas.size());
for (BlockLayoverIndexData data : datas) _blockLayoverIndices.add(data.createIndex(_graphDao));
_blockLayoverIndicesByAgencyId = getBlockTripIndicesByAgencyId(_blockLayoverIndices);
_blockLayoverIndicesByRouteId = getBlockTripsByRouteId(_blockLayoverIndices);
_log.info("block layover indices data loaded");
} else {
_blockLayoverIndices = Collections.emptyList();
_blockLayoverIndicesByAgencyId = Collections.emptyMap();
_blockLayoverIndicesByRouteId = Collections.emptyMap();
}
}
Aggregations