use of org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry in project onebusaway-application-modules by camsys.
the class AgencyServiceImpl method getAgencyIdsAndCenterPoints.
@Cacheable
public Map<String, CoordinatePoint> getAgencyIdsAndCenterPoints() {
Map<String, CoordinatePoint> centersByAgencyId = new HashMap<String, CoordinatePoint>();
for (AgencyEntry agency : _graph.getAllAgencies()) {
StopsCenterOfMass centerOfMass = new StopsCenterOfMass();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
for (RouteEntry route : routeCollection.getChildren()) {
for (TripEntry trip : route.getTrips()) {
for (StopTimeEntry stopTime : trip.getStopTimes()) {
StopEntry stop = stopTime.getStop();
centerOfMass.lats += stop.getStopLat();
centerOfMass.lons += stop.getStopLon();
centerOfMass.count++;
}
}
}
}
if (centerOfMass.count == 0) {
_log.warn("Agency has no service: " + agency);
} else {
double lat = centerOfMass.lats / centerOfMass.count;
double lon = centerOfMass.lons / centerOfMass.count;
centersByAgencyId.put(agency.getId(), new CoordinatePoint(lat, lon));
}
}
return centersByAgencyId;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry in project onebusaway-application-modules by camsys.
the class StopsBeanServiceImpl method getStopsIdsForAgencyId.
@Override
public ListBean<String> getStopsIdsForAgencyId(String agencyId) {
AgencyEntry agency = _transitGraphDao.getAgencyForId(agencyId);
if (agency == null)
throw new NoSuchAgencyServiceException(agencyId);
List<String> ids = new ArrayList<String>();
for (StopEntry stop : agency.getStops()) {
AgencyAndId id = stop.getId();
ids.add(AgencyAndIdLibrary.convertToString(id));
}
return new ListBean<String>(ids, false);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry in project onebusaway-application-modules by camsys.
the class RoutesBeanServiceImpl method getRouteIdsForAgencyId.
@Cacheable
@Override
public ListBean<String> getRouteIdsForAgencyId(String agencyId) {
AgencyEntry agency = _graphDao.getAgencyForId(agencyId);
if (agency == null)
throw new NoSuchAgencyServiceException(agencyId);
List<String> ids = new ArrayList<String>();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
AgencyAndId id = routeCollection.getId();
ids.add(AgencyAndIdLibrary.convertToString(id));
}
return new ListBean<String>(ids, false);
}
Aggregations