Search in sources :

Example 51 with TripEntry

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

the class PreCacheTask method run.

@Override
public void run() {
    // Clear all existing cache elements
    for (String cacheName : _cacheManager.getCacheNames()) {
        Cache cache = _cacheManager.getCache(cacheName);
        cache.removeAll();
    }
    try {
        List<AgencyWithCoverageBean> agenciesWithCoverage = _service.getAgenciesWithCoverage();
        for (AgencyWithCoverageBean agencyWithCoverage : agenciesWithCoverage) {
            AgencyBean agency = agencyWithCoverage.getAgency();
            System.out.println("agency=" + agency.getId());
            ListBean<String> stopIds = _service.getStopIdsForAgencyId(agency.getId());
            for (String stopId : stopIds.getList()) {
                System.out.println("  stop=" + stopId);
                _service.getStop(stopId);
            }
            ListBean<String> routeIds = _service.getRouteIdsForAgencyId(agency.getId());
            for (String routeId : routeIds.getList()) {
                System.out.println("  route=" + routeId);
                _service.getStopsForRoute(routeId);
            }
        }
        Set<AgencyAndId> shapeIds = new HashSet<AgencyAndId>();
        for (TripEntry trip : _transitGraphDao.getAllTrips()) {
            AgencyAndId shapeId = trip.getShapeId();
            if (shapeId != null && shapeId.hasValues())
                shapeIds.add(shapeId);
        }
        for (AgencyAndId shapeId : shapeIds) {
            System.out.println("shape=" + shapeId);
            _service.getShapeForId(AgencyAndIdLibrary.convertToString(shapeId));
        }
    } catch (ServiceException ex) {
        _log.error("service exception", ex);
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ServiceException(org.onebusaway.exceptions.ServiceException) AgencyWithCoverageBean(org.onebusaway.transit_data.model.AgencyWithCoverageBean) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) Cache(net.sf.ehcache.Cache) AgencyBean(org.onebusaway.transit_data.model.AgencyBean) HashSet(java.util.HashSet)

Example 52 with TripEntry

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

the class UnitTestingSupport method blockConfiguration.

public static BlockConfigurationEntry blockConfiguration(BlockEntry block, ServiceIdActivation serviceIds, TripEntry... trips) {
    Builder builder = BlockConfigurationEntryImpl.builder();
    builder.setBlock(block);
    builder.setServiceIds(serviceIds);
    builder.setTrips(Arrays.asList(trips));
    builder.setTripGapDistances(new double[trips.length]);
    BlockConfigurationEntry blockConfig = builder.create();
    BlockEntryImpl blockImpl = (BlockEntryImpl) block;
    List<BlockConfigurationEntry> configs = block.getConfigurations();
    if (configs == null) {
        configs = new ArrayList<BlockConfigurationEntry>();
        blockImpl.setConfigurations(configs);
    }
    configs.add(blockConfig);
    for (TripEntry trip : trips) {
        if (trip.getBlock() == null)
            ((TripEntryImpl) trip).setBlock((BlockEntryImpl) block);
    }
    return blockConfig;
}
Also used : Builder(org.onebusaway.transit_data_federation.impl.transit_graph.BlockConfigurationEntryImpl.Builder) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 53 with TripEntry

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

the class UnitTestingSupport method linkBlockTrips.

public static BlockConfigurationEntry linkBlockTrips(BlockEntryImpl block, List<FrequencyEntry> frequencies, TripEntryImpl... trips) {
    List<TripEntry> tripEntries = new ArrayList<TripEntry>();
    Set<LocalizedServiceId> serviceIds = new TreeSet<LocalizedServiceId>();
    for (int i = 0; i < trips.length; i++) {
        TripEntryImpl trip = trips[i];
        trip.setBlock(block);
        tripEntries.add(trip);
        if (trip.getServiceId() != null)
            serviceIds.add(trip.getServiceId());
    }
    Builder builder = BlockConfigurationEntryImpl.builder();
    builder.setBlock(block);
    builder.setServiceIds(new ServiceIdActivation(new ArrayList<LocalizedServiceId>(serviceIds), new ArrayList<LocalizedServiceId>()));
    builder.setTrips(tripEntries);
    builder.setFrequencies(frequencies);
    builder.setTripGapDistances(new double[tripEntries.size()]);
    BlockConfigurationEntry configuration = builder.create();
    List<BlockConfigurationEntry> configurations = block.getConfigurations();
    if (configurations == null) {
        configurations = new ArrayList<BlockConfigurationEntry>();
        block.setConfigurations(configurations);
    }
    configurations.add(configuration);
    return configuration;
}
Also used : Builder(org.onebusaway.transit_data_federation.impl.transit_graph.BlockConfigurationEntryImpl.Builder) ArrayList(java.util.ArrayList) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) BlockTripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockTripEntryImpl) LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) TreeSet(java.util.TreeSet) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Example 54 with TripEntry

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

the class GtfsController method getStops.

@RequestMapping(value = "/stops/{agencyId}/{id}")
@ResponseBody
public List<CoordinatePoint> getStops(@PathVariable String agencyId, @PathVariable String id) {
    AgencyAndId routeId = new AgencyAndId(agencyId, id);
    RouteEntry route = _transitGraphDao.getRouteForId(routeId);
    TripEntry trip = routeToTrip(route);
    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
    for (StopTimeEntry entry : stopTimes) {
        StopEntry stop = entry.getStop();
        points.add(stop.getStopLocation());
    }
    return points;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) ArrayList(java.util.ArrayList) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 55 with TripEntry

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

the class GtfsRealtimeEntitySource method getTripId.

public Id getTripId(String tripId) {
    TripEntry trip = getTrip(tripId);
    if (trip != null)
        return ServiceAlertLibrary.id(trip.getId());
    _log.debug("trip not found with id \"{}\"", tripId);
    AgencyAndId id = new AgencyAndId(_agencyIds.get(0), tripId);
    return ServiceAlertLibrary.id(id);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)

Aggregations

TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)73 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)46 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)39 ArrayList (java.util.ArrayList)20 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)18 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)15 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)14 HashSet (java.util.HashSet)13 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)10 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)10 List (java.util.List)9 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)9 Date (java.util.Date)7 Test (org.junit.Test)7 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)7 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)7 Cacheable (org.onebusaway.container.cache.Cacheable)6 RouteEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry)6 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)6