Search in sources :

Example 1 with RouteCollectionEntry

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);
}
Also used : RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) RouteCollectionNarrative(org.onebusaway.transit_data_federation.model.narrative.RouteCollectionNarrative) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 2 with RouteCollectionEntry

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);
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoSuchAgencyServiceException(org.onebusaway.exceptions.NoSuchAgencyServiceException) ArrayList(java.util.ArrayList) ListBean(org.onebusaway.transit_data.model.ListBean) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) AgencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 3 with RouteCollectionEntry

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;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) ArrayList(java.util.ArrayList) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) AgencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with RouteCollectionEntry

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;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) HashMap(java.util.HashMap) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) AgencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 5 with RouteCollectionEntry

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);
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) 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) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Aggregations

RouteCollectionEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry)14 RouteEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry)7 ArrayList (java.util.ArrayList)6 Cacheable (org.onebusaway.container.cache.Cacheable)6 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)6 RouteCollectionNarrative (org.onebusaway.transit_data_federation.model.narrative.RouteCollectionNarrative)5 AgencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry)5 Test (org.junit.Test)4 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)4 HashMap (java.util.HashMap)3 Route (org.onebusaway.gtfs.model.Route)3 AgencyEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.AgencyEntryImpl)3 RouteEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.RouteEntryImpl)3 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)3 NoSuchAgencyServiceException (org.onebusaway.exceptions.NoSuchAgencyServiceException)2 GtfsRelationalDao (org.onebusaway.gtfs.services.GtfsRelationalDao)2 ListBean (org.onebusaway.transit_data.model.ListBean)2 UniqueServiceImpl (org.onebusaway.transit_data_federation.bundle.tasks.UniqueServiceImpl)2 RouteCollectionEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.RouteCollectionEntryImpl)2 TransitGraphImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TransitGraphImpl)2