Search in sources :

Example 1 with AdminMarker

use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.

the class AdminChloroplethFeatures method style.

@Override
public JSObject style(JSObject feature) {
    int adminEntityId = feature.getPropertyAsInt("id");
    AdminMarker polygon = overlay.getPolygon(adminEntityId);
    JSObject style = JSObject.createJSObject();
    style.setProperty("fillColor", LeafletUtil.color(polygon.getColor()));
    style.setProperty("fillOpacity", 0.5);
    style.setProperty("stroke", true);
    style.setProperty("weight", 2);
    style.setProperty("color", LeafletUtil.color(overlay.getOutlineColor()));
    return style;
}
Also used : AdminMarker(org.activityinfo.shared.report.content.AdminMarker) JSObject(org.discotools.gwt.leaflet.client.jsobject.JSObject)

Example 2 with AdminMarker

use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.

the class PolygonLayerGenerator method queryBuckets.

private void queryBuckets(DispatcherSync dispatcher, Filter layerFilter) {
    PivotSites query = new PivotSites();
    query.setFilter(layerFilter);
    AdminDimension adminDimension = new AdminDimension(layer.getAdminLevelId());
    query.setDimensions(adminDimension);
    MagnitudeScaleBuilder scaleBuilder = new MagnitudeScaleBuilder(layer);
    this.pivotResult = dispatcher.execute(query);
    for (Bucket bucket : pivotResult.getBuckets()) {
        EntityCategory category = (EntityCategory) bucket.getCategory(adminDimension);
        if (category != null) {
            int adminEntityId = category.getId();
            AdminMarker polygon = overlay.getPolygon(adminEntityId);
            if (polygon != null) {
                polygon.setValue(bucket.doubleValue());
                scaleBuilder.addValue(bucket.doubleValue());
            }
        }
    }
    colorScale = scaleBuilder.build();
}
Also used : PivotSites(org.activityinfo.shared.command.PivotSites) Bucket(org.activityinfo.shared.command.result.Bucket) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory)

Example 3 with AdminMarker

use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawAdminOverlay.

@LogSlow(threshold = 50)
protected void drawAdminOverlay(TiledMap map, Graphics2D g2d, AdminOverlay overlay) {
    List<AdminGeo> geometry = geometryProvider.getGeometries(overlay.getAdminLevelId());
    Color strokeColor = ColorUtil.colorFromString(overlay.getOutlineColor());
    g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    for (AdminGeo adminGeo : geometry) {
        AdminMarker polygon = overlay.getPolygon(adminGeo.getId());
        if (polygon != null) {
            GeneralPath path = PathUtils.toPath(map, adminGeo.getGeometry());
            g2d.setColor(bubbleFillColor(ColorUtil.colorFromString(polygon.getColor())));
            g2d.fill(path);
            g2d.setColor(strokeColor);
            g2d.draw(path);
        }
    }
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) AdminGeo(org.activityinfo.server.geo.AdminGeo) GeneralPath(com.google.code.appengine.awt.geom.GeneralPath) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) Color(com.google.code.appengine.awt.Color) LogSlow(org.activityinfo.server.util.logging.LogSlow)

Example 4 with AdminMarker

use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.

the class PolygonLayerGenerator method queryBounds.

private void queryBounds(DispatcherSync dispatcher, Filter layerFilter) {
    GetAdminEntities query = new GetAdminEntities();
    query.setLevelId(layer.getAdminLevelId());
    AdminEntityResult entities = dispatcher.execute(query);
    for (AdminEntityDTO entity : entities.getData()) {
        if (entity.hasBounds()) {
            AdminMarker marker = new AdminMarker(entity);
            overlay.addPolygon(marker);
        }
    }
}
Also used : AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) AdminEntityResult(org.activityinfo.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities)

Example 5 with AdminMarker

use of org.activityinfo.shared.report.content.AdminMarker 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

AdminMarker (org.activityinfo.shared.report.content.AdminMarker)5 BasicStroke (com.google.code.appengine.awt.BasicStroke)1 Color (com.google.code.appengine.awt.Color)1 GeneralPath (com.google.code.appengine.awt.geom.GeneralPath)1 FileOutputStream (java.io.FileOutputStream)1 AdminGeo (org.activityinfo.server.geo.AdminGeo)1 PdfReportRenderer (org.activityinfo.server.report.renderer.itext.PdfReportRenderer)1 LogSlow (org.activityinfo.server.util.logging.LogSlow)1 GetAdminEntities (org.activityinfo.shared.command.GetAdminEntities)1 PivotSites (org.activityinfo.shared.command.PivotSites)1 AdminEntityResult (org.activityinfo.shared.command.result.AdminEntityResult)1 Bucket (org.activityinfo.shared.command.result.Bucket)1 AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 AdminOverlay (org.activityinfo.shared.report.content.AdminOverlay)1 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)1 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)1 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)1 MapContent (org.activityinfo.shared.report.content.MapContent)1 PolygonLegend (org.activityinfo.shared.report.content.PolygonLegend)1