use of org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createTripData.
/**
**
*
***
*/
public List<BlockTripIndexData> createTripData(Iterable<BlockEntry> blocks) {
List<BlockTripIndex> indices = createTripIndices(blocks);
List<BlockTripIndexData> allData = new ArrayList<BlockTripIndexData>();
for (BlockTripIndex index : indices) {
List<BlockTripReference> references = new ArrayList<BlockTripReference>();
for (BlockTripEntry trip : index.getTrips()) {
BlockTripReference ref = ReferencesLibrary.getTripAsReference(trip);
references.add(ref);
}
ServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
BlockTripIndexData data = new BlockTripIndexData(references, serviceIntervalBlock);
allData.add(data);
}
return allData;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData 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.BlockTripIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexServiceImpl method loadBlockTripIndices.
/**
**
*
***
*/
private void loadBlockTripIndices() throws IOException, ClassNotFoundException {
File path = _bundle.getBlockTripIndicesPath();
if (path.exists()) {
_log.info("loading block trip indices data");
List<BlockTripIndexData> datas = ObjectSerializationLibrary.readObject(path);
_blockTripIndices = new ArrayList<BlockTripIndex>(datas.size());
for (BlockTripIndexData data : datas) _blockTripIndices.add(data.createIndex(_graphDao));
_blockTripIndicesByAgencyId = getBlockTripIndicesByAgencyId(_blockTripIndices);
_blockTripIndicesByRouteId = getBlockTripsByRouteId(_blockTripIndices);
_log.info("block indices data loaded");
} else {
_blockTripIndices = Collections.emptyList();
_blockTripIndicesByAgencyId = Collections.emptyMap();
_blockTripIndicesByRouteId = Collections.emptyMap();
}
}
Aggregations