Search in sources :

Example 1 with PolygonMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer in project activityinfo by bedatadriven.

the class NewLayerWizard method createLayer.

public MapLayer createLayer() {
    MapLayer layer = layerTypePage.newLayer();
    layer.setName(composeName());
    for (Integer indicatorId : indicatorPage.getSelectedIds()) {
        layer.addIndicatorId(indicatorId);
    }
    if (layer instanceof PolygonMapLayer) {
        ((PolygonMapLayer) layer).setAdminLevelId(adminLevelPage.getSelectedLevelId());
    }
    return layer;
}
Also used : PolygonMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer) PolygonMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer) MapLayer(org.activityinfo.legacy.shared.reports.model.layers.MapLayer)

Example 2 with PolygonMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer 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);
    }
}
Also used : PolygonMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer) MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test)

Example 3 with PolygonMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer in project activityinfo by bedatadriven.

the class PolygonGeneratorTest method polygonWithHole.

@Test
public void polygonWithHole() throws IOException {
    AdminMarker marker = new AdminMarker();
    marker.setAdminEntityId(1930);
    marker.setColor("#FFBBBB");
    AdminOverlay overlay = new AdminOverlay(1383);
    overlay.setOutlineColor("#FF0000");
    overlay.addPolygon(marker);
    PolygonMapLayer layer = new PolygonMapLayer();
    layer.addIndicatorId(1);
    layer.setAdminLevelId(1383);
    MapContent content = new MapContent();
    content.setZoomLevel(8);
    content.setBaseMap(GoogleBaseMap.ROADMAP);
    content.setCenter(new AiLatLng(12.60500192642215, -7.98924994468689));
    content.getAdminOverlays().add(overlay);
    content.setFilterDescriptions(new ArrayList<FilterDescription>());
    PolygonLegend.ColorClass clazz1 = new PolygonLegend.ColorClass(1, 53.6, "0000FF");
    PolygonLegend.ColorClass clazz2 = new PolygonLegend.ColorClass(600, 600, "FF0000");
    PolygonLegend legend = new PolygonLegend(layer, Lists.newArrayList(clazz1, clazz2));
    content.getLegends().add(legend);
    IndicatorDTO indicator = new IndicatorDTO();
    indicator.setId(1);
    indicator.setName("Indicator Test");
    content.getIndicators().add(indicator);
    MapReportElement map = new MapReportElement();
    map.addLayer(layer);
    map.setContent(content);
    try (FileOutputStream fos = TestOutput.open(getClass(), "polygon-hole.pdf")) {
        PdfReportRenderer renderer = new PdfReportRenderer(TestGeometry.get(), MAP_ICON_PATH);
        renderer.render(map, fos);
    }
}
Also used : PolygonMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) FileOutputStream(java.io.FileOutputStream) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) Test(org.junit.Test)

Aggregations

PolygonMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer)3 FileOutputStream (java.io.FileOutputStream)2 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)2 PdfReportRenderer (org.activityinfo.server.report.renderer.itext.PdfReportRenderer)2 Test (org.junit.Test)2 IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)1 MapLayer (org.activityinfo.legacy.shared.reports.model.layers.MapLayer)1 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)1