use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsAction method execute.
@SkipValidation
@Override
public String execute() {
_log.info("ServiceAlerts.execute()");
/*
if (submit) {
_log.info("Service Alert submitted");
//doSubmit();
//return "submitResult";
}
if (clear) {
_log.info("Service Alert cleared");
//doClear();
//return "clearResult";
}
*/
// Check that we have permission:
super.execute();
try {
_agencies = _transitDataService.getAgenciesWithCoverage();
_situationsByAgency = new List[_agencies.size()];
// for (AgencyWithCoverageBean agency : _agencies) {
for (int i = 0; i < _agencies.size(); ++i) {
AgencyWithCoverageBean agency = _agencies.get(i);
String agencyId = agency.getAgency().getId();
ListBean<ServiceAlertRecordBean> result = _transitDataService.getAllServiceAlertRecordsForAgencyId(agencyId);
List<ServiceAlertRecordBean> serviceAlerts = result.getList();
_situationsByAgency[i] = serviceAlerts;
}
for (int i = 0; i < _agencies.size(); ++i) {
_log.info("Agency " + _agencies.get(i).getAgency().getId());
List<ServiceAlertRecordBean> serviceAlerts = _situationsByAgency[i];
for (ServiceAlertRecordBean serviceAlert : serviceAlerts) {
_log.info(" Alert: " + serviceAlert.getServiceAlertBean().getSummaries().get(0));
}
}
} catch (Throwable t) {
_log.error("unable to retrieve agencies with coverage", t);
_log.error("issue connecting to TDS -- check your configuration in data-sources.xml");
throw new RuntimeException("Check your onebusaway-nyc-transit-data-federation-webapp configuration", t);
}
return SUCCESS;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class RemoteConfigAction method getMapBounds.
public String getMapBounds() {
List<AgencyWithCoverageBean> agencyWithCoverageBeans = _transitDataService.getAgenciesWithCoverage();
Double minLat = 999d;
Double minLon = 999d;
Double maxLat = -999d;
Double maxLon = -999d;
for (AgencyWithCoverageBean agencyWithCoverageBean : agencyWithCoverageBeans) {
if (agencyWithCoverageBean.getLat() != 0 && agencyWithCoverageBean.getLon() != 0) {
minLat = Math.min(minLat, agencyWithCoverageBean.getLat() - agencyWithCoverageBean.getLatSpan() / 2);
minLon = Math.min(minLon, agencyWithCoverageBean.getLon() - agencyWithCoverageBean.getLonSpan() / 2);
maxLat = Math.max(maxLat, agencyWithCoverageBean.getLat() + agencyWithCoverageBean.getLatSpan() / 2);
maxLon = Math.max(maxLon, agencyWithCoverageBean.getLon() + agencyWithCoverageBean.getLonSpan() / 2);
}
}
return "{ swLat: " + minLat + ", swLon: " + minLon + ", neLat: " + maxLat + ", neLon: " + maxLon + " }";
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class ConfigAction method getMapBounds.
public String getMapBounds() {
List<AgencyWithCoverageBean> agencyWithCoverageBeans = _transitDataService.getAgenciesWithCoverage();
Double minLat = 999d;
Double minLon = 999d;
Double maxLat = -999d;
Double maxLon = -999d;
for (AgencyWithCoverageBean agencyWithCoverageBean : agencyWithCoverageBeans) {
if (agencyWithCoverageBean.getLat() != 0 && agencyWithCoverageBean.getLon() != 0) {
minLat = Math.min(minLat, agencyWithCoverageBean.getLat() - agencyWithCoverageBean.getLatSpan() / 2);
minLon = Math.min(minLon, agencyWithCoverageBean.getLon() - agencyWithCoverageBean.getLonSpan() / 2);
maxLat = Math.max(maxLat, agencyWithCoverageBean.getLat() + agencyWithCoverageBean.getLatSpan() / 2);
maxLon = Math.max(maxLon, agencyWithCoverageBean.getLon() + agencyWithCoverageBean.getLonSpan() / 2);
}
}
return "{ swLat: " + minLat + ", swLon: " + minLon + ", neLat: " + maxLat + ", neLon: " + maxLon + " }";
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class SearchServiceImpl method refreshCachesIfNecessary.
// we keep an internal cache of route short/long names because if we moved
// this into the
// transit data federation, we'd also have to move the model factory and
// some other agency-specific
// conventions, which wouldn't be pretty.
//
// long-term FIXME: figure out how to split apart the model creation a bit
// more from the actual
// search process.
public void refreshCachesIfNecessary() {
String currentBundleId = _transitDataService.getActiveBundleId();
if ((_bundleIdForCaches != null && _bundleIdForCaches.equals(currentBundleId)) || currentBundleId == null) {
return;
}
_routeShortNameToRouteBeanMap.clear();
_routeIdToRouteBeanMap.clear();
_routeLongNameToRouteBeanMap.clear();
_stopCodeToStopIdMap.clear();
for (AgencyWithCoverageBean agency : _transitDataService.getAgenciesWithCoverage()) {
for (RouteBean routeBean : _transitDataService.getRoutesForAgencyId(agency.getAgency().getId()).getList()) {
if (routeBean.getShortName() != null)
if (_routeShortNameToRouteBeanMap.containsKey(routeBean.getShortName().toUpperCase())) {
_routeShortNameToRouteBeanMap.get(routeBean.getShortName().toUpperCase()).add(routeBean);
} else {
_routeShortNameToRouteBeanMap.put(routeBean.getShortName().toUpperCase(), new ArrayList<RouteBean>(Arrays.asList(routeBean)));
}
if (routeBean.getLongName() != null)
if (_routeLongNameToRouteBeanMap.containsKey(routeBean.getLongName())) {
_routeLongNameToRouteBeanMap.get(routeBean.getLongName()).add(routeBean);
} else {
_routeLongNameToRouteBeanMap.put(routeBean.getLongName(), new ArrayList<RouteBean>(Arrays.asList(routeBean)));
}
_routeIdToRouteBeanMap.put(routeBean.getId(), routeBean);
}
List<StopBean> stopsList = _transitDataService.getAllRevenueStops(agency);
for (StopBean stop : stopsList) {
_stopCodeToStopIdMap.put(agency.getAgency().getId() + "_" + stop.getCode().toUpperCase(), stop.getId());
}
}
_bundleIdForCaches = currentBundleId;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class DefaultWebappConfigurationSource method getConfiguration.
@Override
public Map<String, Object> getConfiguration(String contextPath) {
Map<String, Object> config = new HashMap<String, Object>();
config.put("apiKey", "web");
config.put("baseUrl", contextPath);
config.put("apiUrl", contextPath + "/api");
List<AgencyWithCoverageBean> agenciesWithCoverage = _transitDataService.getAgenciesWithCoverage();
CoordinateBounds bounds = new CoordinateBounds();
for (AgencyWithCoverageBean awc : agenciesWithCoverage) {
if (awc.getLatSpan() <= 0 || awc.getLonSpan() <= 0)
continue;
bounds.addPoint(awc.getLat() + awc.getLatSpan() / 2, awc.getLon() + awc.getLonSpan() / 2);
bounds.addPoint(awc.getLat() - awc.getLatSpan() / 2, awc.getLon() - awc.getLonSpan() / 2);
}
if (bounds.isEmpty()) {
config.put("centerLat", 0.0);
config.put("centerLon", 0.0);
config.put("spanLat", 180.0);
config.put("spanLon", 180.0);
} else {
config.put("centerLat", (bounds.getMinLat() + bounds.getMaxLat()) / 2);
config.put("centerLon", (bounds.getMinLon() + bounds.getMaxLon()) / 2);
config.put("spanLat", bounds.getMaxLat() - bounds.getMinLat());
config.put("spanLon", bounds.getMaxLon() - bounds.getMinLon());
}
config.put("hasDefaultServiceArea", _serviceAreaService.hasDefaultServiceArea());
config.put("googleMapsApiKey", _googleMapsApiKey);
config.put("tracker", _googleAnalyticsAnalyticsKey);
return config;
}
Aggregations