use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.
the class TripBeanServiceImpl method getTripForId.
@Cacheable
public TripBean getTripForId(AgencyAndId tripId) {
TripEntry tripEntry = _graph.getTripEntryForId(tripId);
if (tripEntry == null)
return null;
AgencyAndId routeId = tripEntry.getRouteCollection().getId();
RouteBean routeBean = _routeBeanService.getRouteForId(routeId);
TripNarrative tripNarrative = _narrativeService.getTripForId(tripId);
TripBean tripBean = new TripBean();
tripBean.setId(ApplicationBeanLibrary.getId(tripId));
tripBean.setTripShortName(tripNarrative.getTripShortName());
tripBean.setTripHeadsign(tripNarrative.getTripHeadsign());
tripBean.setRoute(routeBean);
tripBean.setRouteShortName(tripNarrative.getRouteShortName());
tripBean.setServiceId(ApplicationBeanLibrary.getId(tripEntry.getServiceId().getId()));
AgencyAndId shapeId = tripEntry.getShapeId();
if (shapeId != null && shapeId.hasValues())
tripBean.setShapeId(ApplicationBeanLibrary.getId(shapeId));
tripBean.setDirectionId(tripEntry.getDirectionId());
tripBean.setTotalTripDistance(tripEntry.getTotalTripDistance());
BlockEntry block = tripEntry.getBlock();
tripBean.setBlockId(ApplicationBeanLibrary.getId(block.getId()));
return tripBean;
}
use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.
the class NearbyStopsBeanServiceImpl method getNearbyStops.
@Cacheable
public List<AgencyAndId> getNearbyStops(@CacheableArgument(keyProperty = "id") StopBean stopBean, double radius) {
CoordinateBounds bounds = SphericalGeometryLibrary.bounds(stopBean.getLat(), stopBean.getLon(), radius);
List<AgencyAndId> ids = _geospatialBeanService.getStopsByBounds(bounds);
List<AgencyAndId> excludingSource = new ArrayList<AgencyAndId>();
for (AgencyAndId id : ids) {
if (!ApplicationBeanLibrary.getId(id).equals(stopBean.getId()))
excludingSource.add(id);
}
return excludingSource;
}
use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.
the class RouteBeanServiceImpl method getStopsForRoute.
@Cacheable
public StopsForRouteBean getStopsForRoute(AgencyAndId routeId) {
RouteCollectionEntry routeCollectionEntry = _transitGraphDao.getRouteCollectionForId(routeId);
RouteCollectionNarrative narrative = _narrativeService.getRouteCollectionForId(routeId);
if (routeCollectionEntry == null || narrative == null)
return null;
return getStopsForRouteCollectionAndNarrative(routeCollectionEntry, narrative);
}
use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.
the class RoutesBeanServiceImpl method getRoutesForAgencyId.
@Cacheable
@Override
public ListBean<RouteBean> getRoutesForAgencyId(String agencyId) {
AgencyEntry agency = _graphDao.getAgencyForId(agencyId);
if (agency == null)
throw new NoSuchAgencyServiceException(agencyId);
List<RouteBean> routes = new ArrayList<RouteBean>();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
AgencyAndId routeId = routeCollection.getId();
RouteBean route = _routeBeanService.getRouteForId(routeId);
routes.add(route);
}
return new ListBean<RouteBean>(routes, false);
}
use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.
the class ShapeBeanServiceImpl method getMergedPolylinesForShapeIds.
@Cacheable
public List<EncodedPolylineBean> getMergedPolylinesForShapeIds(Collection<AgencyAndId> shapeIds) {
List<EncodedPolylineBean> polylines = new ArrayList<EncodedPolylineBean>();
if (shapeIds.isEmpty())
return polylines;
List<CoordinatePoint> currentLine = new ArrayList<CoordinatePoint>();
Set<Edge> edges = new HashSet<Edge>();
for (AgencyAndId shapeId : shapeIds) {
ShapePoints shapePoints = _shapePointService.getShapePointsForShapeId(shapeId);
if (shapePoints == null) {
_log.warn("no shape points for shapeId=" + shapeId);
continue;
}
double[] lats = shapePoints.getLats();
double[] lons = shapePoints.getLons();
CoordinatePoint prev = null;
for (int i = 0; i < shapePoints.getSize(); i++) {
CoordinatePoint loc = new CoordinatePoint(lats[i], lons[i]);
if (prev != null && !prev.equals(loc)) {
Edge edge = new Edge(prev, loc);
if (!edges.add(edge)) {
if (currentLine.size() > 1)
polylines.add(PolylineEncoder.createEncodings(currentLine));
currentLine.clear();
}
}
if (prev == null || !prev.equals(loc))
currentLine.add(loc);
prev = loc;
}
if (currentLine.size() > 1)
polylines.add(PolylineEncoder.createEncodings(currentLine));
currentLine.clear();
}
return polylines;
}
Aggregations