Search in sources :

Example 1 with BlockLayoverIndexData

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;
}
Also used : BlockTripReference(org.onebusaway.transit_data_federation.services.blocks.BlockTripReference) LayoverIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.LayoverIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) BlockLayoverIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData) BlockLayoverIndex(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex)

Example 2 with BlockLayoverIndexData

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);
    }
}
Also used : BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) BlockStopTimeIndicesFactory(org.onebusaway.transit_data_federation.impl.blocks.BlockStopTimeIndicesFactory) BlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData) FrequencyBlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData) BlockLayoverIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData) FrequencyBlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData)

Example 3 with BlockLayoverIndexData

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();
    }
}
Also used : File(java.io.File) BlockLayoverIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData) BlockLayoverIndex(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex)

Aggregations

BlockLayoverIndexData (org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData)3 BlockLayoverIndex (org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 BlockStopTimeIndicesFactory (org.onebusaway.transit_data_federation.impl.blocks.BlockStopTimeIndicesFactory)1 BlockTripIndexData (org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData)1 BlockTripReference (org.onebusaway.transit_data_federation.services.blocks.BlockTripReference)1 FrequencyBlockTripIndexData (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData)1 LayoverIntervalBlock (org.onebusaway.transit_data_federation.services.blocks.LayoverIntervalBlock)1 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)1 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)1