Search in sources :

Example 1 with FrequencyBlockTripIndexData

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

Example 2 with FrequencyBlockTripIndexData

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

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

Aggregations

FrequencyBlockTripIndexData (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData)3 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 BlockTripIndexData (org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData)1 BlockTripReference (org.onebusaway.transit_data_federation.services.blocks.BlockTripReference)1 FrequencyServiceIntervalBlock (org.onebusaway.transit_data_federation.services.blocks.FrequencyServiceIntervalBlock)1 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)1 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)1