use of org.activityinfo.legacy.shared.reports.model.MapReportElement in project activityinfo by bedatadriven.
the class ExcelMapDataExporter method render.
@Override
public void render(ReportElement element, OutputStream stm) throws IOException {
if (!(element instanceof MapReportElement)) {
throw new RuntimeException("ExcelMapDataExporter accepts only MapElements");
}
MapContent content = ((MapReportElement) element).getContent();
Workbook book = new HSSFWorkbook();
Sheet sheet = book.createSheet();
Helper helper = new Helper(book);
Row headerRow = sheet.createRow(0);
helper.addCell(headerRow, 0, "Latitude");
helper.addCell(headerRow, 1, "Longitude");
helper.addCell(headerRow, 2, "Value");
helper.addCell(headerRow, 3, "Color");
helper.addCell(headerRow, 4, "Icon");
int rowIndex = 1;
for (MapMarker marker : content.getMarkers()) {
Row dataRow = sheet.createRow(rowIndex++);
helper.addCell(dataRow, 0, marker.getLat());
helper.addCell(dataRow, 1, marker.getLng());
if (marker instanceof BubbleMapMarker) {
BubbleMapMarker bmarker = (BubbleMapMarker) marker;
helper.addCell(dataRow, 2, bmarker.getValue());
helper.addCell(dataRow, 3, bmarker.getColor());
}
if (marker instanceof IconMapMarker) {
IconMapMarker imarker = (IconMapMarker) marker;
if (imarker.getIcon() != null) {
helper.addCell(dataRow, 4, imarker.getIcon().getName());
}
}
}
book.write(stm);
}
use of org.activityinfo.legacy.shared.reports.model.MapReportElement in project activityinfo by bedatadriven.
the class MapGeneratorTest method adminMapBubbles.
@Test
public void adminMapBubbles() {
AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
clustering.getAdminLevels().add(1);
BubbleMapLayer layer = new BubbleMapLayer();
layer.setClustering(clustering);
layer.addIndicator(1);
Filter filter = new Filter();
filter.addRestriction(DimensionType.Site, 3);
MapReportElement map = new MapReportElement();
map.addLayer(layer);
map.setFilter(filter);
MapContent result = (MapContent) execute(new GenerateElement(map));
System.out.println(result.getMarkers());
BubbleMapMarker marker = (BubbleMapMarker) result.getMarkers().get(0);
assertThat(marker.getSiteIds().size(), equalTo(1));
assertThat(marker.getSiteIds().get(0), equalTo(3));
assertThat(marker.getValue(), equalTo(10000d));
assertThat(result.getUnmappedSites().size(), equalTo(0));
System.out.println(marker.getTitle());
}
use of org.activityinfo.legacy.shared.reports.model.MapReportElement in project activityinfo by bedatadriven.
the class MapGeneratorTest method adminMapIcon.
@Test
public void adminMapIcon() {
AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
clustering.getAdminLevels().add(1);
IconMapLayer layer = new IconMapLayer();
layer.setClustering(clustering);
layer.getIndicatorIds().add(1);
Filter filter = new Filter();
filter.addRestriction(DimensionType.Site, 3);
MapReportElement map = new MapReportElement();
map.addLayer(layer);
map.setFilter(filter);
MapContent result = (MapContent) execute(new GenerateElement(map));
System.out.println(result.getMarkers());
IconMapMarker marker = (IconMapMarker) result.getMarkers().get(0);
assertThat(marker.getSiteIds().size(), equalTo(1));
assertThat(marker.getSiteIds().get(0), equalTo(3));
System.out.println(marker.getTitle());
// assertThat(marker., equalTo(10000d));
assertThat(result.getUnmappedSites().size(), equalTo(0));
}
use of org.activityinfo.legacy.shared.reports.model.MapReportElement in project activityinfo by bedatadriven.
the class PolygonGeneratorTest method basicTest.
@Test
public void basicTest() throws IOException {
PolygonMapLayer layer = new PolygonMapLayer();
layer.addIndicatorId(1);
layer.setAdminLevelId(1383);
MapReportElement map = new MapReportElement();
map.addLayer(layer);
MapContent content = execute(new GenerateElement<MapContent>(map));
map.setContent(content);
Reports.toPdf(getClass(), map, "polygon");
try (FileOutputStream fos = TestOutput.open(getClass(), "polygon.pdf")) {
PdfReportRenderer renderer = new PdfReportRenderer(TestGeometry.get(), MAP_ICON_PATH);
renderer.render(map, fos);
}
}
use of org.activityinfo.legacy.shared.reports.model.MapReportElement in project activityinfo by bedatadriven.
the class MgMapIntegrationTest method generateMap.
private void generateMap(MapLayer layer, String fileName) throws IOException {
map = new MapReportElement();
map.addLayer(layer);
content = (MapContent) execute(new GenerateElement(map));
renderToFile(map, fileName);
}
Aggregations