Search in sources :

Example 41 with BlockConfigurationEntry

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

the class ReferencesLibrary method getTripAsReference.

public static BlockTripReference getTripAsReference(BlockTripEntry trip) {
    BlockConfigurationEntry blockConfig = trip.getBlockConfiguration();
    BlockConfigurationReference blockConfigRef = getBlockAsReference(blockConfig);
    int tripIndex = blockConfig.getTrips().indexOf(trip);
    return new BlockTripReference(blockConfigRef, tripIndex);
}
Also used : BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 42 with BlockConfigurationEntry

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

the class ReferencesLibrary method getReferenceAsTrip.

public static BlockTripEntry getReferenceAsTrip(BlockTripReference reference, TransitGraphDao dao) {
    BlockConfigurationEntry blockConfig = getReferenceAsBlockConfiguration(reference.getBlockConfigurationReference(), dao);
    List<BlockTripEntry> trips = blockConfig.getTrips();
    int tripIndex = reference.getTripIndex();
    return trips.get(tripIndex);
}
Also used : BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 43 with BlockConfigurationEntry

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

the class BlockConfigurationEntriesFactory method processBlockConfigurations.

public void processBlockConfigurations(BlockEntryImpl block, List<TripEntryImpl> tripsInBlock) {
    Map<LocalizedServiceId, List<TripEntryImpl>> tripsByServiceId = getTripsByServiceId(block, tripsInBlock);
    List<ServiceIdActivation> combinations = _serviceIdOverlapCache.getOverlappingServiceIdCombinations(tripsByServiceId.keySet());
    ArrayList<BlockConfigurationEntry> configurations = new ArrayList<BlockConfigurationEntry>();
    for (ServiceIdActivation serviceIds : combinations) {
        BlockConfigurationEntryImpl.Builder builder = processTripsForServiceIdConfiguration(block, tripsByServiceId, serviceIds);
        configurations.add(builder.create());
    }
    Collections.sort(configurations, _blockConfigurationComparator);
    configurations.trimToSize();
    if (configurations.isEmpty())
        _log.warn("no active block configurations found for block: " + block.getId());
    block.setConfigurations(configurations);
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ArrayList(java.util.ArrayList) BlockConfigurationEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockConfigurationEntryImpl) ArrayList(java.util.ArrayList) List(java.util.List) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 44 with BlockConfigurationEntry

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

the class FrequencyEntriesFactory method applyFrequenciesToBlockTrips.

private void applyFrequenciesToBlockTrips(List<TripEntryImpl> tripsInBlock, Map<AgencyAndId, List<FrequencyEntry>> frequenciesAlongBlockByTripId) {
    BlockEntryImpl blockEntry = tripsInBlock.get(0).getBlock();
    List<BlockConfigurationEntry> configurations = blockEntry.getConfigurations();
    for (int i = 0; i < configurations.size(); i++) {
        BlockConfigurationEntryImpl blockConfig = (BlockConfigurationEntryImpl) configurations.get(i);
        List<FrequencyEntry> frequencies = computeBlockFrequencies(blockEntry, blockConfig.getTrips(), frequenciesAlongBlockByTripId);
        blockConfig.setFrequencies(frequencies);
    }
}
Also used : BlockConfigurationEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockConfigurationEntryImpl) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 45 with BlockConfigurationEntry

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

the class ArrivalAndDepartureServiceImpl method getStopTimeInstancesByBlockInstance.

private Map<BlockInstance, List<StopTimeInstance>> getStopTimeInstancesByBlockInstance(List<StopTimeInstance> stopTimes) {
    Map<BlockInstance, List<StopTimeInstance>> r = new FactoryMap<BlockInstance, List<StopTimeInstance>>(new ArrayList<StopTimeInstance>());
    for (StopTimeInstance stopTime : stopTimes) {
        BlockStopTimeEntry blockStopTime = stopTime.getStopTime();
        BlockTripEntry blockTrip = blockStopTime.getTrip();
        BlockConfigurationEntry blockConfiguration = blockTrip.getBlockConfiguration();
        long serviceDate = stopTime.getServiceDate();
        BlockInstance blockInstance = new BlockInstance(blockConfiguration, serviceDate, stopTime.getFrequency());
        r.get(blockInstance).add(stopTime);
    }
    return r;
}
Also used : FactoryMap(org.onebusaway.collections.FactoryMap) StopTimeInstance(org.onebusaway.transit_data_federation.model.StopTimeInstance) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ArrayList(java.util.ArrayList) List(java.util.List) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Aggregations

BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)89 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)36 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)34 Test (org.junit.Test)30 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)29 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)27 ArrayList (java.util.ArrayList)23 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)23 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)18 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)17 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)14 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)13 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)13 Date (java.util.Date)12 List (java.util.List)11 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)11 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)10 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)10 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)8 FactoryMap (org.onebusaway.collections.FactoryMap)8