use of org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createFrequencyTripData.
public List<FrequencyBlockTripIndexData> createFrequencyTripData(Iterable<BlockEntry> blocks) {
List<FrequencyBlockTripIndex> indices = createFrequencyTripIndices(blocks);
List<FrequencyBlockTripIndexData> allData = new ArrayList<FrequencyBlockTripIndexData>();
for (FrequencyBlockTripIndex index : indices) {
List<BlockTripReference> tripReferences = new ArrayList<BlockTripReference>();
for (BlockTripEntry entry : index.getTrips()) {
BlockTripReference reference = ReferencesLibrary.getTripAsReference(entry);
tripReferences.add(reference);
}
FrequencyServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
FrequencyBlockTripIndexData data = new FrequencyBlockTripIndexData(tripReferences, index.getFrequencies(), serviceIntervalBlock);
allData.add(data);
}
return allData;
}
use of org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData 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.FrequencyBlockTripIndexData in project onebusaway-application-modules by camsys.
the class BlockIndexServiceImpl method loadFrequencyBlockTripIndices.
private void loadFrequencyBlockTripIndices() throws IOException, ClassNotFoundException {
File path = _bundle.getFrequencyBlockTripIndicesPath();
if (path.exists()) {
_log.info("loading frequency block trip indices data");
List<FrequencyBlockTripIndexData> datas = ObjectSerializationLibrary.readObject(path);
_frequencyBlockTripIndices = new ArrayList<FrequencyBlockTripIndex>(datas.size());
for (FrequencyBlockTripIndexData data : datas) _frequencyBlockTripIndices.add(data.createIndex(_graphDao));
_frequencyBlockTripIndicesByAgencyId = getBlockTripIndicesByAgencyId(_frequencyBlockTripIndices);
_frequencyBlockTripIndicesByRouteId = getBlockTripsByRouteId(_frequencyBlockTripIndices);
_log.info("block frequency trip indices data loaded");
} else {
_frequencyBlockTripIndices = Collections.emptyList();
_frequencyBlockTripIndicesByAgencyId = Collections.emptyMap();
_frequencyBlockTripIndicesByRouteId = Collections.emptyMap();
}
}
Aggregations