use of org.onebusaway.transit_data.model.RouteBean 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.transit_data.model.RouteBean 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.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class RoutesBeanServiceImpl method getRoutesWithRouteNameQuery.
private RoutesBean getRoutesWithRouteNameQuery(SearchQueryBean query) throws ServiceException {
SearchResult<AgencyAndId> result = searchForRoutes(query);
List<RouteBean> routeBeans = new ArrayList<RouteBean>();
CoordinateBounds bounds = query.getBounds();
for (AgencyAndId id : result.getResults()) {
STRtree tree = _stopTreesByRouteId.get(id);
if (tree == null) {
_log.warn("stop tree not found for routeId=" + id);
continue;
}
Envelope env = new Envelope(bounds.getMinLon(), bounds.getMaxLon(), bounds.getMinLat(), bounds.getMaxLat());
HasItemsVisitor v = new HasItemsVisitor();
tree.query(env, v);
if (v.hasItems()) {
RouteBean routeBean = _routeBeanService.getRouteForId(id);
routeBeans.add(routeBean);
}
}
boolean limitExceeded = BeanServiceSupport.checkLimitExceeded(routeBeans, query.getMaxCount());
return constructResult(routeBeans, limitExceeded);
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class StopBeanServiceImpl method fillRoutesForStopBean.
private void fillRoutesForStopBean(StopEntry stop, StopBean sb) {
Set<AgencyAndId> routeCollectionIds = _routeService.getRouteCollectionIdsForStop(stop.getId());
List<RouteBean> routeBeans = new ArrayList<RouteBean>(routeCollectionIds.size());
for (AgencyAndId routeCollectionId : routeCollectionIds) {
RouteBean bean = _routeBeanService.getRouteForId(routeCollectionId);
routeBeans.add(bean);
}
Collections.sort(routeBeans, _routeBeanComparator);
sb.setRoutes(routeBeans);
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class BundleSearchServiceImpl method init.
@PostConstruct
@Refreshable(dependsOn = { RefreshableResources.ROUTE_COLLECTIONS_DATA, RefreshableResources.TRANSIT_GRAPH })
public void init() {
Runnable initThread = new Runnable() {
@Override
public void run() {
while (!_initialized) {
try {
Thread.sleep(1 * 1000);
} catch (InterruptedException e) {
return;
}
}
_log.info("building cache");
Map<String, List<String>> tmpSuggestions = Collections.synchronizedMap(new HashMap<String, List<String>>());
Map<String, List<CoordinateBounds>> agencies = _transitDataService.getAgencyIdsWithCoverageArea();
for (String agency : agencies.keySet()) {
ListBean<RouteBean> routes = _transitDataService.getRoutesForAgencyId(agency);
for (RouteBean route : routes.getList()) {
String shortName = route.getShortName();
generateInputsForString(tmpSuggestions, shortName, "\\s+");
}
ListBean<String> stopIds = _transitDataService.getStopIdsForAgencyId(agency);
for (String stopId : stopIds.getList()) {
if (_transitDataService.stopHasRevenueService(agency, stopId)) {
AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(stopId);
generateInputsForString(tmpSuggestions, agencyAndId.getId(), null);
}
}
}
suggestions = tmpSuggestions;
_log.info("complete");
}
};
new Thread(initThread).start();
}
Aggregations