Search in sources :

Example 1 with BlockTripIndexData

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;
}
Also used : BlockTripReference(org.onebusaway.transit_data_federation.services.blocks.BlockTripReference) ServiceIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.ServiceIntervalBlock) FrequencyServiceIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.FrequencyServiceIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) FrequencyBlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData) BlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData)

Example 2 with BlockTripIndexData

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);
    }
}
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 BlockTripIndexData

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

Aggregations

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