Search in sources :

Example 16 with BlockStopTimeIndex

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

the class BlockGeospatialServiceImpl method getActiveScheduledBlocksPassingThroughBounds.

@Override
public List<BlockInstance> getActiveScheduledBlocksPassingThroughBounds(CoordinateBounds bounds, long timeFrom, long timeTo) {
    List<StopEntry> stops = _transitGraphDao.getStopsByLocation(bounds);
    Set<AgencyAndId> blockIds = new HashSet<AgencyAndId>();
    for (StopEntry stop : stops) {
        List<BlockStopTimeIndex> stopTimeIndices = _blockIndexService.getStopTimeIndicesForStop(stop);
        Set<BlockConfigurationEntry> blockConfigs = new HashSet<BlockConfigurationEntry>();
        List<List<BlockConfigurationEntry>> blockConfigsList = MappingLibrary.map(stopTimeIndices, "blockConfigs");
        for (List<BlockConfigurationEntry> l : blockConfigsList) {
            blockConfigs.addAll(l);
        }
        List<AgencyAndId> stopBlockIds = MappingLibrary.map(blockConfigs, "block.id");
        blockIds.addAll(stopBlockIds);
    }
    Set<BlockTripIndex> blockIndices = new HashSet<BlockTripIndex>();
    for (AgencyAndId blockId : blockIds) {
        blockIndices.addAll(_blockIndexService.getBlockTripIndicesForBlock(blockId));
    }
    List<BlockLayoverIndex> layoverIndices = Collections.emptyList();
    List<FrequencyBlockTripIndex> frequencyIndices = Collections.emptyList();
    return _blockCalendarService.getActiveBlocksInTimeRange(blockIndices, layoverIndices, frequencyIndices, timeFrom, timeTo);
}
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) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) List(java.util.List) ArrayList(java.util.ArrayList) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) HashSet(java.util.HashSet)

Example 17 with BlockStopTimeIndex

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

the class BlockIndexServiceImpl method loadStopTimeIndices.

private void loadStopTimeIndices() {
    // Clear any existing indices
    for (StopEntry stop : _graphDao.getAllStops()) {
        StopEntryImpl stopImpl = (StopEntryImpl) stop;
        stopImpl.getStopTimeIndices().clear();
        stopImpl.getFrequencyStopTimeIndices().clear();
    }
    BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();
    factory.setVerbose(true);
    List<BlockStopTimeIndex> indices = factory.createIndices(_graphDao.getAllBlocks());
    for (BlockStopTimeIndex index : indices) {
        StopEntryImpl stop = (StopEntryImpl) index.getStop();
        stop.addStopTimeIndex(index);
    }
    List<FrequencyBlockStopTimeIndex> frequencyIndices = factory.createFrequencyIndices(_graphDao.getAllBlocks());
    for (FrequencyBlockStopTimeIndex index : frequencyIndices) {
        StopEntryImpl stop = (StopEntryImpl) index.getStop();
        stop.addFrequencyStopTimeIndex(index);
    }
}
Also used : FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)

Example 18 with BlockStopTimeIndex

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

the class BlockStopTimeIndicesFactory method createIndicesFromGroups.

/**
 **
 *
 ***
 */
private List<BlockStopTimeIndex> createIndicesFromGroups(Map<BlockStopTimeKey, List<BlockStopTimeEntry>> stopTimesByKey) {
    List<BlockStopTimeIndex> allIndices = new ArrayList<BlockStopTimeIndex>();
    int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(allIndices.size()) * 10;
    int count = 0;
    for (List<BlockStopTimeEntry> stopTimes : stopTimesByKey.values()) {
        if (_verbose && count % logInterval == 0)
            _log.info("groups processed: " + count + "/" + stopTimesByKey.size());
        count++;
        List<List<BlockStopTimeEntry>> groupedStopTimes = BlockLibrary.createStrictlyOrderedGroups(stopTimes, _blockStopTimeLooseComparator, _blockStopTimeStrictComparator);
        for (List<BlockStopTimeEntry> group : groupedStopTimes) {
            BlockStopTimeIndex index = createBlockStopTimeIndexForGroup(group);
            allIndices.add(index);
        }
    }
    return allIndices;
}
Also used : FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) FrequencyBlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry)

Aggregations

BlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex)18 FrequencyBlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex)10 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)10 ArrayList (java.util.ArrayList)7 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)7 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)7 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 Stop (org.onebusaway.gtfs.model.Stop)4 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)4 StopNarrative (org.onebusaway.transit_data_federation.model.narrative.StopNarrative)4 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)4 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)4 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)4 Date (java.util.Date)3 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)3 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)3 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)3 AbstractBlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.AbstractBlockStopTimeIndex)3 FrequencyBlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry)3