Search in sources :

Example 11 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class RouteServiceImpl method getRouteCollectionIdsForStop.

@Override
@Cacheable
public Set<AgencyAndId> getRouteCollectionIdsForStop(AgencyAndId stopId) {
    StopEntry stopEntry = _transitGraphDao.getStopEntryForId(stopId);
    if (stopEntry == null)
        throw new InternalErrorServiceException("no such stop: id=" + stopId);
    Set<AgencyAndId> routeCollectionIds = new HashSet<AgencyAndId>();
    List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stopEntry);
    for (BlockStopTimeIndex blockStopTimeIndex : indices) {
        for (BlockTripEntry blockTrip : blockStopTimeIndex.getTrips()) {
            TripEntry trip = blockTrip.getTrip();
            routeCollectionIds.add(trip.getRouteCollection().getId());
        }
    }
    List<FrequencyBlockStopTimeIndex> frequencyIndices = _blockIndexService.getFrequencyStopTimeIndicesForStop(stopEntry);
    for (FrequencyBlockStopTimeIndex blockStopTimeIndex : frequencyIndices) {
        for (BlockTripEntry blockTrip : blockStopTimeIndex.getTrips()) {
            TripEntry trip = blockTrip.getTrip();
            routeCollectionIds.add(trip.getRouteCollection().getId());
        }
    }
    return routeCollectionIds;
}
Also used : InternalErrorServiceException(org.onebusaway.exceptions.InternalErrorServiceException) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 12 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class ProjectedShapePointServiceImpl method getProjectedShapePoints.

@Cacheable
@Override
public T2<List<XYPoint>, double[]> getProjectedShapePoints(List<AgencyAndId> shapeIds, int utmZoneId) {
    ShapePoints shapePoints = _shapePointService.getShapePointsForShapeIds(shapeIds);
    if (shapePoints == null || shapePoints.isEmpty())
        return null;
    UTMProjection projection = new UTMProjection(utmZoneId);
    List<XYPoint> projected = _shapePointsLibrary.getProjectedShapePoints(shapePoints, projection);
    return Tuples.tuple(projected, shapePoints.getDistTraveled());
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) XYPoint(org.onebusaway.geospatial.model.XYPoint) UTMProjection(org.onebusaway.geospatial.services.UTMProjection) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 13 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class ShapePointServiceImpl method getShapePointsForShapeIds.

@Cacheable
@Override
public ShapePoints getShapePointsForShapeIds(List<AgencyAndId> shapeIds) {
    ShapePointsFactory factory = new ShapePointsFactory();
    for (AgencyAndId shapeId : shapeIds) {
        ShapePoints shapePoints = getShapePointsForShapeId(shapeId);
        factory.addPoints(shapePoints);
    }
    return factory.create();
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) ShapePointsFactory(org.onebusaway.transit_data_federation.model.ShapePointsFactory) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 14 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class ExtendedCalendarServiceImpl method getDatesForServiceIds.

@Cacheable
@Override
public Set<Date> getDatesForServiceIds(ServiceIdActivation serviceIds) {
    Set<Date> serviceDates = null;
    List<LocalizedServiceId> activeServiceIds = serviceIds.getActiveServiceIds();
    List<LocalizedServiceId> inactiveServiceIds = serviceIds.getInactiveServiceIds();
    for (LocalizedServiceId activeServiceId : activeServiceIds) {
        List<Date> dates = _calendarService.getDatesForLocalizedServiceId(activeServiceId);
        if (dates.isEmpty())
            return Collections.emptySet();
        if (serviceDates == null)
            serviceDates = new HashSet<Date>(dates);
        else
            serviceDates.retainAll(dates);
        if (serviceDates.isEmpty())
            return Collections.emptySet();
    }
    for (LocalizedServiceId inactiveServiceId : inactiveServiceIds) {
        List<Date> dates = _calendarService.getDatesForLocalizedServiceId(inactiveServiceId);
        serviceDates.removeAll(dates);
    }
    return serviceDates;
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 15 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class ExtendedCalendarServiceImpl method getServiceDatesForServiceIds.

@Cacheable
@Override
public Set<ServiceDate> getServiceDatesForServiceIds(ServiceIdActivation serviceIds) {
    Set<ServiceDate> serviceDates = null;
    List<LocalizedServiceId> activeServiceIds = serviceIds.getActiveServiceIds();
    List<LocalizedServiceId> inactiveServiceIds = serviceIds.getInactiveServiceIds();
    for (LocalizedServiceId activeServiceId : activeServiceIds) {
        Set<ServiceDate> dates = _calendarService.getServiceDatesForServiceId(activeServiceId.getId());
        if (dates.isEmpty())
            return Collections.emptySet();
        if (serviceDates == null)
            serviceDates = new HashSet<ServiceDate>(dates);
        else
            serviceDates.retainAll(dates);
        if (serviceDates.isEmpty())
            return Collections.emptySet();
    }
    for (LocalizedServiceId inactiveServiceId : inactiveServiceIds) {
        Set<ServiceDate> dates = _calendarService.getServiceDatesForServiceId(inactiveServiceId.getId());
        serviceDates.removeAll(dates);
    }
    return serviceDates;
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Aggregations

Cacheable (org.onebusaway.container.cache.Cacheable)23 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)10 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)7 RouteCollectionEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry)6 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)6 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)6 HashMap (java.util.HashMap)4 AgencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry)4 Date (java.util.Date)3 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)3 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)3 RouteBean (org.onebusaway.transit_data.model.RouteBean)3 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)3 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)3 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)3 FactoryMap (org.onebusaway.collections.FactoryMap)2 NoSuchAgencyServiceException (org.onebusaway.exceptions.NoSuchAgencyServiceException)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)2