use of org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel in project activityinfo by bedatadriven.
the class GeoDigestRenderer method renderDatabases.
private void renderDatabases(StringBuilder html, GeoDigestModel model) throws IOException {
html.append("<div class='geo-data' style='margin-top:20px'>");
Collection<DatabaseModel> databases = model.getDatabases();
for (DatabaseModel database : databases) {
if (database.isRenderable()) {
renderDatabase(html, database);
}
}
html.append("</div>");
}
use of org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel in project activityinfo by bedatadriven.
the class GeoDigestModelBuilder method createDatabaseModel.
private void createDatabaseModel(GeoDigestModel model, Database database) throws IOException {
DatabaseModel databaseModel = new DatabaseModel(model, database);
List<Integer> siteIds = findSiteIds(database, model.getUserDigest().getFrom());
LOGGER.finest("rendering geo digest for user " + model.getUserDigest().getUser().getId() + " and database " + database.getId() + " - found " + siteIds.size() + " site(s) that were edited since " + DateFormatter.formatDateTime(model.getUserDigest().getFrom()));
if (!siteIds.isEmpty()) {
MapReportElement reportModel = new MapReportElement();
reportModel.setMaximumZoomLevel(9);
BubbleMapLayer layer = createLayer(siteIds);
reportModel.setLayers(layer);
MapContent content = dispatcher.execute(new GenerateElement<MapContent>(reportModel));
databaseModel.setContent(content);
if (!content.getMarkers().isEmpty()) {
reportModel.setContent(content);
GeneratedResource storage = storageProvider.create("image/png", "map.png");
try (OutputStream outputStream = storage.openOutputStream()) {
imageMapRenderer.render(reportModel, outputStream);
}
databaseModel.setUrl(storage.getDownloadUri());
}
}
}
Aggregations