use of org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry 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.transit_data_federation.services.transit_graph.RouteCollectionEntry 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_federation.services.transit_graph.RouteCollectionEntry in project onebusaway-application-modules by camsys.
the class GtfsController method getRoutesByAgency.
// Get list of routes by agency
@RequestMapping(value = "/routes/{agencyId}")
@ResponseBody
public List<String> getRoutesByAgency(@PathVariable String agencyId) {
AgencyEntry agency = _transitGraphDao.getAgencyForId(agencyId);
List<RouteCollectionEntry> collections = agency.getRouteCollections();
List<String> routes = new ArrayList<String>();
for (RouteCollectionEntry entry : collections) {
for (RouteEntry route : entry.getChildren()) {
String id = route.getId().getId();
routes.add(id);
}
}
return routes;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry in project onebusaway-application-modules by camsys.
the class AgencyServiceImpl method getAgencyIdsAndCoverageAreas.
@Cacheable
public Map<String, CoordinateBounds> getAgencyIdsAndCoverageAreas() {
Map<String, CoordinateBounds> boundsByAgencyId = new HashMap<String, CoordinateBounds>();
for (AgencyEntry agency : _graph.getAllAgencies()) {
CoordinateBounds bounds = new CoordinateBounds();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
for (RouteEntry route : routeCollection.getChildren()) {
for (TripEntry trip : route.getTrips()) {
for (StopTimeEntry stopTime : trip.getStopTimes()) {
StopEntry stop = stopTime.getStop();
bounds.addPoint(stop.getStopLat(), stop.getStopLon());
}
}
}
}
boundsByAgencyId.put(agency.getId(), bounds);
}
return boundsByAgencyId;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry in project onebusaway-application-modules by camsys.
the class RouteServiceImpl method getStopsForRouteCollection.
@Override
@Cacheable
public Collection<AgencyAndId> getStopsForRouteCollection(AgencyAndId id) {
Set<AgencyAndId> stopIds = new HashSet<AgencyAndId>();
RouteCollectionEntry routeCollectionEntry = _transitGraphDao.getRouteCollectionForId(id);
for (RouteEntry route : routeCollectionEntry.getChildren()) {
List<TripEntry> trips = route.getTrips();
for (TripEntry trip : trips) {
List<StopTimeEntry> stopTimes = trip.getStopTimes();
for (StopTimeEntry stopTime : stopTimes) stopIds.add(stopTime.getStop().getId());
}
}
return new ArrayList<AgencyAndId>(stopIds);
}
Aggregations