use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method getBestLayoverList.
private List<BlockTripEntry> getBestLayoverList(List<List<BlockTripEntry>> lists, BlockTripEntry trip) {
for (List<BlockTripEntry> list : lists) {
if (list.isEmpty())
return list;
BlockTripEntry prev = list.get(list.size() - 1);
boolean allGood = areLayoverTimesAlwaysIncreasingOrEqual(prev, trip);
if (allGood)
return list;
}
return null;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method areBlockTripsContinuous.
private boolean areBlockTripsContinuous(BlockTripEntry prevBlockTrip, BlockTripEntry nextBlockTrip) {
List<BlockStopTimeEntry> prevStopTimes = prevBlockTrip.getStopTimes();
List<BlockStopTimeEntry> nextStopTimes = nextBlockTrip.getStopTimes();
BlockStopTimeEntry from = prevStopTimes.get(prevStopTimes.size() - 1);
BlockStopTimeEntry to = nextStopTimes.get(0);
int slack = to.getAccumulatedSlackTime() - (from.getAccumulatedSlackTime() + from.getStopTime().getSlackTime());
int schedTime = to.getStopTime().getArrivalTime() - from.getStopTime().getDepartureTime();
/**
* If the slack time is too much, the trips are not continuous
*/
if (slack >= _maxSlackBetweenConsecutiveTrips)
return false;
/**
* If the sched time is too much, the trips are not continuous
*/
if (schedTime >= _maxScheduledTimeBetweenConsecutiveTrips)
return false;
TripEntry prevTrip = prevBlockTrip.getTrip();
TripEntry nextTrip = nextBlockTrip.getTrip();
AgencyAndId lineIdA = prevTrip.getRouteCollection().getId();
AgencyAndId lineIdB = nextTrip.getRouteCollection().getId();
String directionA = prevTrip.getDirectionId();
String directionB = nextTrip.getDirectionId();
/**
* If the route has not changed, but the direction has, the trips are not
* continuous
*/
if (lineIdA.equals(lineIdB) && (directionA == null || !directionA.equals(directionB)))
return false;
double prevOrientation = computeDirectionOfTravel(prevStopTimes);
double nextOrientation = computeDirectionOfTravel(nextStopTimes);
double delta = GeometryLibrary.getAngleDifference(prevOrientation, nextOrientation);
return true;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createTripData.
/**
**
*
***
*/
public List<BlockTripIndexData> createTripData(Iterable<BlockEntry> blocks) {
List<BlockTripIndex> indices = createTripIndices(blocks);
List<BlockTripIndexData> allData = new ArrayList<BlockTripIndexData>();
for (BlockTripIndex index : indices) {
List<BlockTripReference> references = new ArrayList<BlockTripReference>();
for (BlockTripEntry trip : index.getTrips()) {
BlockTripReference ref = ReferencesLibrary.getTripAsReference(trip);
references.add(ref);
}
ServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
BlockTripIndexData data = new BlockTripIndexData(references, serviceIntervalBlock);
allData.add(data);
}
return allData;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createLayoverData.
public List<BlockLayoverIndexData> createLayoverData(Iterable<BlockEntry> blocks) {
List<BlockLayoverIndex> indices = createLayoverIndices(blocks);
List<BlockLayoverIndexData> allData = new ArrayList<BlockLayoverIndexData>();
for (BlockLayoverIndex index : indices) {
List<BlockTripReference> references = new ArrayList<BlockTripReference>();
for (BlockTripEntry trip : index.getTrips()) {
BlockTripReference ref = ReferencesLibrary.getTripAsReference(trip);
references.add(ref);
}
LayoverIntervalBlock layoverIntervalBlock = index.getLayoverIntervalBlock();
BlockLayoverIndexData data = new BlockLayoverIndexData(references, layoverIntervalBlock);
allData.add(data);
}
return allData;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method createFrequencyTripData.
public List<FrequencyBlockTripIndexData> createFrequencyTripData(Iterable<BlockEntry> blocks) {
List<FrequencyBlockTripIndex> indices = createFrequencyTripIndices(blocks);
List<FrequencyBlockTripIndexData> allData = new ArrayList<FrequencyBlockTripIndexData>();
for (FrequencyBlockTripIndex index : indices) {
List<BlockTripReference> tripReferences = new ArrayList<BlockTripReference>();
for (BlockTripEntry entry : index.getTrips()) {
BlockTripReference reference = ReferencesLibrary.getTripAsReference(entry);
tripReferences.add(reference);
}
FrequencyServiceIntervalBlock serviceIntervalBlock = index.getServiceIntervalBlock();
FrequencyBlockTripIndexData data = new FrequencyBlockTripIndexData(tripReferences, index.getFrequencies(), serviceIntervalBlock);
allData.add(data);
}
return allData;
}
Aggregations