use of org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method ensureFrequencyTripGroups.
private List<FrequencyTripGroup> ensureFrequencyTripGroups(List<BlockTripEntry> tripsWithSameSequence) {
List<BlockTripWithFrequency> btwfs = new ArrayList<BlockTripWithFrequency>();
for (BlockTripEntry trip : tripsWithSameSequence) {
BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
for (FrequencyEntry frequency : blockConfig.getFrequencies()) btwfs.add(new BlockTripWithFrequency(trip, frequency));
}
Collections.sort(btwfs);
List<FrequencyTripGroup> lists = new ArrayList<FrequencyTripGroup>();
for (BlockTripWithFrequency btwf : btwfs) {
FrequencyTripGroup group = getBestFrequencyTripGroup(lists, btwf);
if (group == null) {
group = new FrequencyTripGroup();
lists.add(group);
}
group.addEntry(btwf);
}
return lists;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method getBlockTripsAsFrequencyBlockInterval.
private FrequencyServiceIntervalBlock getBlockTripsAsFrequencyBlockInterval(List<BlockTripEntry> trips, List<FrequencyEntry> frequencies) {
int n = trips.size();
int[] startTimes = new int[n];
int[] endTimes = new int[n];
for (int index = 0; index < n; index++) {
FrequencyEntry freq = frequencies.get(index);
startTimes[index] = freq.getStartTime();
endTimes[index] = freq.getEndTime();
}
return new FrequencyServiceIntervalBlock(startTimes, endTimes);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry in project onebusaway-application-modules by camsys.
the class BlockStatusServiceImpl method getBlockInstances.
/**
**
* Private Methods
***
*/
private List<BlockInstance> getBlockInstances(AgencyAndId blockId, long serviceDate, long time) {
if (serviceDate != 0) {
BlockInstance blockInstance = _blockCalendarService.getBlockInstance(blockId, serviceDate);
if (blockInstance == null)
return Collections.emptyList();
BlockConfigurationEntry blockConfig = blockInstance.getBlock();
if (blockConfig.getFrequencies() == null)
return Arrays.asList(blockInstance);
List<BlockInstance> instances = new ArrayList<BlockInstance>();
for (FrequencyEntry frequency : blockConfig.getFrequencies()) instances.add(new BlockInstance(blockConfig, blockInstance.getServiceDate(), frequency));
return instances;
} else {
List<BlockInstance> instances = _blockCalendarService.getActiveBlocks(blockId, time, time);
if (instances.isEmpty()) {
instances = _blockCalendarService.getClosestActiveBlocks(blockId, time);
}
return instances;
}
}
use of org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry in project onebusaway-application-modules by camsys.
the class BlockStopTimeIndicesFactory method createFrequencyBlockStopTimeIndexForGroup.
private FrequencyBlockStopTimeIndex createFrequencyBlockStopTimeIndexForGroup(List<FrequencyBlockStopTimeEntry> group) {
int n = group.size();
List<FrequencyEntry> frequencies = new ArrayList<FrequencyEntry>(n);
List<BlockConfigurationEntry> blockConfigs = new ArrayList<BlockConfigurationEntry>(n);
int[] stopIndices = new int[n];
ServiceInterval interval = null;
for (int i = 0; i < n; i++) {
FrequencyBlockStopTimeEntry frequencyBlockStopTime = group.get(i);
FrequencyEntry frequency = frequencyBlockStopTime.getFrequency();
frequencies.add(frequency);
BlockStopTimeEntry blockStopTime = frequencyBlockStopTime.getStopTime();
blockConfigs.add(blockStopTime.getTrip().getBlockConfiguration());
stopIndices[i] = blockStopTime.getBlockSequence();
interval = ServiceInterval.extend(interval, frequency.getStartTime(), frequency.getStartTime());
interval = ServiceInterval.extend(interval, frequency.getEndTime(), frequency.getEndTime());
}
return new FrequencyBlockStopTimeIndex(frequencies, blockConfigs, stopIndices, interval);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry in project onebusaway-application-modules by camsys.
the class FrequencyBlockStopTimeComparator method compare.
@Override
public int compare(FrequencyBlockStopTimeEntry o1, FrequencyBlockStopTimeEntry o2) {
FrequencyEntry f1 = o1.getFrequency();
FrequencyEntry f2 = o2.getFrequency();
int c = f1.getStartTime() - f2.getStartTime();
if (c != 0)
return c;
return f1.getEndTime() - f2.getEndTime();
}
Aggregations