Search in sources :

Example 16 with BlockTripEntry

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;
}
Also used : BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)

Example 17 with BlockTripEntry

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;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 18 with BlockTripEntry

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;
}
Also used : BlockTripReference(org.onebusaway.transit_data_federation.services.blocks.BlockTripReference) ServiceIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.ServiceIntervalBlock) FrequencyServiceIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.FrequencyServiceIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) FrequencyBlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData) BlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndexData)

Example 19 with BlockTripEntry

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;
}
Also used : BlockTripReference(org.onebusaway.transit_data_federation.services.blocks.BlockTripReference) LayoverIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.LayoverIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) BlockLayoverIndexData(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndexData) BlockLayoverIndex(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex)

Example 20 with BlockTripEntry

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;
}
Also used : FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) BlockTripReference(org.onebusaway.transit_data_federation.services.blocks.BlockTripReference) FrequencyServiceIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.FrequencyServiceIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) FrequencyBlockTripIndexData(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndexData)

Aggregations

BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)72 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)30 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)27 ArrayList (java.util.ArrayList)26 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)25 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)23 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)15 List (java.util.List)11 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)10 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)10 FactoryMap (org.onebusaway.collections.FactoryMap)9 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)8 HashSet (java.util.HashSet)7 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)7 InstanceState (org.onebusaway.transit_data_federation.services.blocks.InstanceState)7 Date (java.util.Date)6 FrequencyBlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex)6 ServiceInterval (org.onebusaway.gtfs.model.calendar.ServiceInterval)5 StopSequence (org.onebusaway.transit_data_federation.model.StopSequence)5