Search in sources :

Example 6 with BlockLayoverIndex

use of org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex 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)

Example 7 with BlockLayoverIndex

use of org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex in project onebusaway-application-modules by camsys.

the class BlockIndexServiceImpl method loadBlockTripIndicesByBlockId.

/**
 **
 *
 ***
 */
private void loadBlockTripIndicesByBlockId() {
    _log.info("calculating block trip indices by blockId...");
    long t1 = SystemTime.currentTimeMillis();
    _blockTripIndicesByBlockId = new HashMap<AgencyAndId, List<BlockTripIndex>>();
    _blockLayoverIndicesByBlockId = new HashMap<AgencyAndId, List<BlockLayoverIndex>>();
    _frequencyBlockTripIndicesByBlockId = new HashMap<AgencyAndId, List<FrequencyBlockTripIndex>>();
    for (BlockEntry block : _graphDao.getAllBlocks()) {
        List<BlockEntry> list = Arrays.asList(block);
        List<BlockTripIndex> indices = _factory.createTripIndices(list);
        List<BlockLayoverIndex> layoverIndices = _factory.createLayoverIndices(list);
        List<FrequencyBlockTripIndex> frequencyIndices = _factory.createFrequencyTripIndices(list);
        if (!indices.isEmpty())
            _blockTripIndicesByBlockId.put(block.getId(), indices);
        if (!layoverIndices.isEmpty())
            _blockLayoverIndicesByBlockId.put(block.getId(), layoverIndices);
        if (!frequencyIndices.isEmpty())
            _frequencyBlockTripIndicesByBlockId.put(block.getId(), frequencyIndices);
    }
    long t2 = SystemTime.currentTimeMillis();
    _log.info("completed calculating block trip indices by blockId: t=" + (t2 - t1));
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockLayoverIndex(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) ArrayList(java.util.ArrayList) List(java.util.List) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex)

Aggregations

BlockLayoverIndex (org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex)7 ArrayList (java.util.ArrayList)4 BlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex)4 FrequencyBlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex)4 List (java.util.List)3 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)3 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)3 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)3 Test (org.junit.Test)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)2 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)2 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)2 BlockLayoverIndexData (org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData)2 LayoverIntervalBlock (org.onebusaway.transit_data_federation.services.blocks.LayoverIntervalBlock)2 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)2 File (java.io.File)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 FactoryMap (org.onebusaway.collections.FactoryMap)1