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);
}
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;
}
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();
}
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();
}
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);
}
Aggregations