Search in sources :

Example 1 with BubbleMapMarker

use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker 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);
}
Also used : MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 2 with BubbleMapMarker

use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker 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());
}
Also used : MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) AdministrativeLevelClustering(org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering) MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) Test(org.junit.Test)

Example 3 with BubbleMapMarker

use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.

the class LeafletMarkerFactory method create.

public static Marker create(MapMarker mapMarker, final EventHandler... markerEventHandlers) {
    final Marker marker;
    if (mapMarker instanceof IconMapMarker) {
        marker = createIconMapMarker((IconMapMarker) mapMarker);
    } else if (mapMarker instanceof PieMapMarker) {
        marker = createPieMapMarker((PieMapMarker) mapMarker);
    } else if (mapMarker instanceof BubbleMapMarker) {
        marker = createBubbleMapMarker((BubbleMapMarker) mapMarker);
    } else {
        final Options options = new Options();
        setModel(options.getJSObject(), mapMarker);
        marker = new Marker(toLatLng(mapMarker), options);
    }
    if (markerEventHandlers != null) {
        for (EventHandler handler : markerEventHandlers) {
            EventHandlerManager.addEventHandler(marker, EventHandler.Events.click, handler);
        }
    }
    return marker;
}
Also used : IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions) Options(org.discotools.gwt.leaflet.client.Options) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) EventHandler(org.discotools.gwt.leaflet.client.events.handler.EventHandler) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker)

Example 4 with BubbleMapMarker

use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.

the class GeoDigestRenderer method renderDatabase.

private void renderDatabase(StringBuilder html, DatabaseModel databaseModel) throws IOException {
    html.append("<div class='geo-database' style='margin-top:20px'>");
    html.append("<span class='geo-header' style='font-weight:bold; color: #" + BUBBLE_COLOR + ";'>");
    html.append(databaseModel.getName());
    html.append("</span><br>");
    html.append("<img class='geo-graph' width=\"450px\" src=\"");
    html.append(databaseModel.getUrl());
    html.append("\" /><br><br>");
    for (MapMarker marker : databaseModel.getContent().getMarkers()) {
        String label = ((BubbleMapMarker) marker).getLabel();
        html.append("<span class='geo-marker-header' style='color: #" + BUBBLE_COLOR + "; font-weight:bold;'>");
        html.append(label);
        html.append(":</span><br>");
        LOGGER.finest(marker.getSiteIds().size() + " sites for marker " + label + ": " + marker.getSiteIds());
        renderSites(html, databaseModel, marker.getSiteIds());
    }
    if (!databaseModel.getContent().getUnmappedSites().isEmpty()) {
        html.append("<br><span class='geo-unmapped-header' style='color:black; font-weight:bold;'>");
        html.append(I18N.MESSAGES.geoDigestUnmappedSites());
        html.append(":</span><br>");
        LOGGER.finest(databaseModel.getContent().getUnmappedSites().size() + " unmapped sites");
        renderSites(html, databaseModel, databaseModel.getContent().getUnmappedSites());
    }
    html.append("</div>");
}
Also used : BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)

Example 5 with BubbleMapMarker

use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.

the class LRTBComparatorTest method testComparator.

@Test
public void testComparator() {
    MapMarker ul = new BubbleMapMarker();
    ul.setX(1);
    ul.setY(1);
    MapMarker ul2 = new BubbleMapMarker();
    ul2.setX(60);
    ul2.setY(0);
    MapMarker c = new BubbleMapMarker();
    c.setX(30);
    c.setY(50);
    MapMarker ll = new BubbleMapMarker();
    ll.setX(0);
    ll.setY(80);
    List<MapMarker> list = new ArrayList<MapMarker>();
    list.add(ll);
    list.add(c);
    list.add(ul2);
    list.add(ul);
    Collections.sort(list, new MapMarker.LRTBComparator());
    for (MapMarker marker : list) {
        System.out.println(marker.toString());
    }
    Assert.assertEquals(ul, list.get(0));
    Assert.assertEquals(ul2, list.get(1));
    Assert.assertEquals(c, list.get(2));
    Assert.assertEquals(ll, list.get(3));
}
Also used : BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) ArrayList(java.util.ArrayList) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) Test(org.junit.Test)

Aggregations

BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)5 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)4 IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)2 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)2 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)1 AdministrativeLevelClustering (org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering)1 BubbleMapLayer (org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Options (org.discotools.gwt.leaflet.client.Options)1 EventHandler (org.discotools.gwt.leaflet.client.events.handler.EventHandler)1 CircleMarker (org.discotools.gwt.leaflet.client.marker.CircleMarker)1 Marker (org.discotools.gwt.leaflet.client.marker.Marker)1 MarkerOptions (org.discotools.gwt.leaflet.client.marker.MarkerOptions)1 IconOptions (org.discotools.gwt.leaflet.client.types.IconOptions)1