Search in sources :

Example 21 with BlockTripEntry

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

the class BlockIndexFactoryServiceImpl method getBlockTripsAsLayoverInterval.

private LayoverIntervalBlock getBlockTripsAsLayoverInterval(List<BlockTripEntry> trips) {
    int n = trips.size();
    int[] startTimes = new int[n];
    int[] endTimes = new int[n];
    int index = 0;
    for (BlockTripEntry trip : trips) {
        startTimes[index] = BlockTripLayoverTimeComparator.getLayoverStartTimeForTrip(trip);
        endTimes[index] = BlockTripLayoverTimeComparator.getLayoverEndTimeForTrip(trip);
        index++;
    }
    return new LayoverIntervalBlock(startTimes, endTimes);
}
Also used : LayoverIntervalBlock(org.onebusaway.transit_data_federation.services.blocks.LayoverIntervalBlock) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)

Example 22 with BlockTripEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry 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 23 with BlockTripEntry

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

the class BlockConfigurationEntryImpl method getDistanceAlongBlockForIndex.

@Override
public double getDistanceAlongBlockForIndex(int index) {
    int tripIndex = tripIndices[index];
    BlockTripEntry blockTrip = trips.get(tripIndex);
    TripEntry trip = blockTrip.getTrip();
    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    int stopTimeIndex = index - accumulatedStopTimeIndices[tripIndex];
    StopTimeEntry stopTime = stopTimes.get(stopTimeIndex);
    return blockTrip.getDistanceAlongBlock() + stopTime.getShapeDistTraveled();
}
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) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)

Example 24 with BlockTripEntry

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

the class AbstractBlockStopTimeIndex method computeServiceInterval.

/**
 ***
 * Private Methods
 ***
 */
protected static ServiceInterval computeServiceInterval(HasBlockTrips blockIndex, int blockSequence) {
    ServiceInterval serviceInterval = null;
    List<BlockTripEntry> trips = blockIndex.getTrips();
    for (BlockTripEntry trip : trips) {
        BlockStopTimeEntry blockStopTime = trip.getStopTimes().get(blockSequence);
        StopTimeEntry stopTime = blockStopTime.getStopTime();
        serviceInterval = ServiceInterval.extend(serviceInterval, stopTime.getArrivalTime(), stopTime.getDepartureTime());
    }
    return serviceInterval;
}
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) ServiceInterval(org.onebusaway.gtfs.model.calendar.ServiceInterval) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 25 with BlockTripEntry

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

the class StopTimeServiceImplTest method addFirstStopToBlockIndex.

/**
 **
 * Private Methods
 ***
 */
private void addFirstStopToBlockIndex(BlockConfigurationEntry... blocks) {
    List<BlockTripEntry> trips = new ArrayList<BlockTripEntry>();
    for (BlockConfigurationEntry blockConfig : blocks) {
        trips.add(blockConfig.getTrips().get(0));
    }
    BlockTripIndex blockIndex = _factory.createTripIndexForGroupOfBlockTrips(trips);
    BlockStopTimeIndex index = BlockStopTimeIndex.create(blockIndex, 0);
    _stop.addStopTimeIndex(index);
    Mockito.when(_blockIndexService.getStopTimeIndicesForStop(_stop)).thenReturn(_stop.getStopTimeIndices());
}
Also used : BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) ArrayList(java.util.ArrayList) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex)

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