public List<AgencyWithCoverageBean> getAgenciesWithCoverage() throws ServiceException { Map<String, CoordinateBounds> agencyIdsAndCoverageAreas = _agencyService.getAgencyIdsAndCoverageAreas(); List<AgencyWithCoverageBean> beans = new ArrayList<AgencyWithCoverageBean>(); for (Map.Entry<String, CoordinateBounds> entry : agencyIdsAndCoverageAreas.entrySet()) { String agencyId = entry.getKey(); CoordinateBounds bounds = entry.getValue(); AgencyBean agencyBean = _agencyBeanService.getAgencyForId(agencyId); if (agencyBean == null) throw new ServiceException("agency not found: " + agencyId); AgencyWithCoverageBean bean = new AgencyWithCoverageBean(); bean.setAgency(agencyBean); bean.setLat((bounds.getMaxLat() + bounds.getMinLat()) / 2); bean.setLon((bounds.getMaxLon() + bounds.getMinLon()) / 2); bean.setLatSpan(bounds.getMaxLat() - bounds.getMinLat()); bean.setLonSpan(bounds.getMaxLon() - bounds.getMinLon()); beans.add(bean); } return beans; }
@Override public List<AgencyWithCoverageBean> getAgenciesWithCoverage() throws ServiceException { Map<String, CoordinateBounds> agencyIdsAndCoverageAreas = _agencyService.getAgencyIdsAndCoverageAreas(); List<AgencyWithCoverageBean> beans = new ArrayList<AgencyWithCoverageBean>(); for (Map.Entry<String, CoordinateBounds> entry : agencyIdsAndCoverageAreas.entrySet()) { String agencyId = entry.getKey(); CoordinateBounds bounds = entry.getValue(); AgencyBean agencyBean = _agencyBeanService.getAgencyForId(agencyId); if (agencyBean == null) throw new ServiceException("agency not found: " + agencyId); AgencyWithCoverageBean bean = new AgencyWithCoverageBean(); bean.setAgency(agencyBean); bean.setLat((bounds.getMaxLat() + bounds.getMinLat()) / 2); bean.setLon((bounds.getMaxLon() + bounds.getMinLon()) / 2); bean.setLatSpan(bounds.getMaxLat() - bounds.getMinLat()); bean.setLonSpan(bounds.getMaxLon() - bounds.getMinLon()); beans.add(bean); } return beans; }