Search in sources :

Example 1 with PolygonMapLayer

use of org.activityinfo.shared.report.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);
    FileOutputStream fos = new FileOutputStream("target/report-tests/polygon.pdf");
    PdfReportRenderer pdfr = new PdfReportRenderer(TestGeometry.get(), "");
    pdfr.render(map, fos);
    fos.close();
}
Also used : PolygonMapLayer(org.activityinfo.shared.report.model.layers.PolygonMapLayer) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) MapContent(org.activityinfo.shared.report.content.MapContent) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test)

Example 2 with PolygonMapLayer

use of org.activityinfo.shared.report.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.shared.report.model.layers.PolygonMapLayer) MapLayer(org.activityinfo.shared.report.model.layers.MapLayer) PolygonMapLayer(org.activityinfo.shared.report.model.layers.PolygonMapLayer)

Example 3 with PolygonMapLayer

use of org.activityinfo.shared.report.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);
    FileOutputStream fos = new FileOutputStream("target/report-tests/polygon-hole.pdf");
    PdfReportRenderer pdfr = new PdfReportRenderer(TestGeometry.get(), "");
    pdfr.render(map, fos);
    fos.close();
}
Also used : PolygonMapLayer(org.activityinfo.shared.report.model.layers.PolygonMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AdminOverlay(org.activityinfo.shared.report.content.AdminOverlay) PolygonLegend(org.activityinfo.shared.report.content.PolygonLegend) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) FileOutputStream(java.io.FileOutputStream) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Test(org.junit.Test)

Aggregations

PolygonMapLayer (org.activityinfo.shared.report.model.layers.PolygonMapLayer)3 FileOutputStream (java.io.FileOutputStream)2 PdfReportRenderer (org.activityinfo.server.report.renderer.itext.PdfReportRenderer)2 MapContent (org.activityinfo.shared.report.content.MapContent)2 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)2 Test (org.junit.Test)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 AdminMarker (org.activityinfo.shared.report.content.AdminMarker)1 AdminOverlay (org.activityinfo.shared.report.content.AdminOverlay)1 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)1 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)1 PolygonLegend (org.activityinfo.shared.report.content.PolygonLegend)1 MapLayer (org.activityinfo.shared.report.model.layers.MapLayer)1