Search in sources :

Example 16 with BlockStopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry in project onebusaway-application-modules by camsys.

the class BlockStopTimeIndicesFactory method createBlockStopTimeIndexForGroup.

private BlockStopTimeIndex createBlockStopTimeIndexForGroup(List<BlockStopTimeEntry> group) {
    int n = group.size();
    List<BlockConfigurationEntry> blockConfigs = new ArrayList<BlockConfigurationEntry>(n);
    int[] stopIndices = new int[n];
    ServiceInterval interval = null;
    for (int i = 0; i < n; i++) {
        BlockStopTimeEntry blockStopTime = group.get(i);
        StopTimeEntry stopTime = blockStopTime.getStopTime();
        blockConfigs.add(blockStopTime.getTrip().getBlockConfiguration());
        stopIndices[i] = blockStopTime.getBlockSequence();
        interval = ServiceInterval.extend(interval, stopTime.getArrivalTime(), stopTime.getDepartureTime());
    }
    return new BlockStopTimeIndex(blockConfigs, stopIndices, interval);
}
Also used : BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) FrequencyBlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) ServiceInterval(org.onebusaway.gtfs.model.calendar.ServiceInterval) ArrayList(java.util.ArrayList) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) FrequencyBlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry)

Example 17 with BlockStopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry in project onebusaway-application-modules by camsys.

the class BlockStopTimeIndicesFactory method groupBlockStopTimes.

/**
 **
 *
 ***
 */
private Map<BlockStopTimeKey, List<BlockStopTimeEntry>> groupBlockStopTimes(Iterable<BlockEntry> blocks, boolean frequencyBased) {
    Map<BlockStopTimeKey, List<BlockStopTimeEntry>> stopTimesByKey = new FactoryMap<BlockStopTimeKey, List<BlockStopTimeEntry>>(new ArrayList<BlockStopTimeEntry>());
    if (_verbose)
        _log.info("grouping block stop times by key");
    int stopTimeCount = 0;
    for (BlockEntry block : blocks) {
        List<BlockConfigurationEntry> configurations = block.getConfigurations();
        if (configurations.isEmpty()) {
            _log.warn("block is not referred to in calendars (no active configurations): " + block.getId());
            continue;
        }
        if (BlockLibrary.isFrequencyBased(block) != frequencyBased)
            continue;
        for (BlockConfigurationEntry blockConfiguration : configurations) {
            List<BlockStopTimeEntry> blockStopTimes = blockConfiguration.getStopTimes();
            for (BlockStopTimeEntry blockStopTime : blockStopTimes) {
                BlockStopTimeKey key = getBlockStopTimeAsKey(blockStopTime);
                List<BlockStopTimeEntry> stopTimesForKey = stopTimesByKey.get(key);
                stopTimesForKey.add(blockStopTime);
                stopTimeCount++;
            }
        }
    }
    if (_verbose)
        _log.info("groups found: " + stopTimesByKey.size() + " out of stopTimes: " + stopTimeCount);
    return stopTimesByKey;
}
Also used : FactoryMap(org.onebusaway.collections.FactoryMap) BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) ArrayList(java.util.ArrayList) List(java.util.List) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) FrequencyBlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry)

Example 18 with BlockStopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry in project onebusaway-application-modules by camsys.

the class BlockStopTimeLooseComparator method compare.

@Override
public int compare(T o1, T o2) {
    List<BlockStopTimeEntry> stopTimes1 = o1.getStopTimes();
    List<BlockStopTimeEntry> stopTimes2 = o2.getStopTimes();
    if (stopTimes1.isEmpty())
        throw new IllegalStateException("block trip has no stop times: " + o1);
    if (stopTimes2.isEmpty())
        throw new IllegalStateException("block trip has no stop times: " + o2);
    BlockStopTimeEntry bst1 = stopTimes1.get(0);
    BlockStopTimeEntry bst2 = stopTimes2.get(0);
    StopTimeEntry st1 = bst1.getStopTime();
    StopTimeEntry st2 = bst2.getStopTime();
    return st1.getDepartureTime() - st2.getDepartureTime();
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 19 with BlockStopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry in project onebusaway-application-modules by camsys.

the class BlockTripLayoverTimeComparator method getLayoverStartTimeForTrip.

public static int getLayoverStartTimeForTrip(BlockTripEntry blockTrip) {
    BlockTripEntry prevTrip = blockTrip.getPreviousTrip();
    if (prevTrip == null)
        throw new IllegalStateException("blockTrip had no incoming trip, thus no layover");
    List<BlockStopTimeEntry> stopTimes = prevTrip.getStopTimes();
    BlockStopTimeEntry blockStopTime = stopTimes.get(stopTimes.size() - 1);
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    return stopTime.getDepartureTime();
}
Also used : BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 20 with BlockStopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry in project onebusaway-application-modules by camsys.

the class ScheduledBlockLocationServiceImpl method getScheduledBlockLocationFromScheduledTime.

@Override
public ScheduledBlockLocation getScheduledBlockLocationFromScheduledTime(BlockConfigurationEntry blockConfig, int scheduleTime) {
    List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();
    int n = stopTimes.size();
    int index = GenericBinarySearch.search(blockConfig, n, scheduleTime, IndexAdapters.BLOCK_STOP_TIME_DEPARTURE_INSTANCE);
    return getScheduledBlockLocationFromScheduleTimeAndStopTimeIndex(stopTimes, scheduleTime, index);
}
Also used : BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint)

Aggregations

BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)71 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)32 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)29 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)23 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)20 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)16 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)15 ArrayList (java.util.ArrayList)14 FrequencyBlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyBlockStopTimeEntry)14 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)11 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)11 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)10 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)9 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)9 Date (java.util.Date)8 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)8 InstanceState (org.onebusaway.transit_data_federation.services.blocks.InstanceState)8 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)8 BlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex)7 FrequencyBlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex)7