Search in sources :

Example 1 with MapMarker

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

the class LeafletMarkerDrilldownEventHandler method handle.

@Override
public void handle(Event event) {
    final JSObject targetOptions = event.getTarget().getProperty("options");
    MapMarker markerModel = LeafletMarkerFactory.getModel(targetOptions);
    final Filter effectiveFilter = new Filter();
    effectiveFilter.addRestriction(DimensionType.Site, markerModel.getSiteIds());
    effectiveFilter.addRestriction(DimensionType.Indicator, markerModel.getIndicatorIds());
    drillDownEditor.drillDown(effectiveFilter);
}
Also used : MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Filter(org.activityinfo.legacy.shared.command.Filter) JSObject(org.discotools.gwt.leaflet.client.jsobject.JSObject)

Example 2 with MapMarker

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

the class LeafletReportOverlays method addMarkers.

public Extents addMarkers(List<MapMarker> markers, EventHandler<Event> markerEventHandler) {
    Extents extents = Extents.emptyExtents();
    for (MapMarker marker : markers) {
        markerLayer.addLayer(LeafletMarkerFactory.create(marker, markerEventHandler));
        extents.grow(marker.getLat(), marker.getLng());
    }
    return extents;
}
Also used : MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Extents(org.activityinfo.model.type.geo.Extents)

Example 3 with MapMarker

use of org.activityinfo.legacy.shared.reports.content.MapMarker 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 4 with MapMarker

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

the class MgMapIntegrationTest method siteBoundsToAdminLevelsAreMappedAsBubbles.

@Test
public void siteBoundsToAdminLevelsAreMappedAsBubbles() throws IOException {
    BubbleMapLayer layer = new BubbleMapLayer();
    layer.addIndicator(NUMBER_OF_BENE_INDICATOR_ID);
    generateMap(layer, "mg-bubbles");
    assertThat(content.getMarkers().size(), equalTo(10));
    MapMarker marker = getMarkerForSite(1336279918);
    assertThat(marker.getX(), equalTo(262));
    assertThat(marker.getY(), equalTo(113));
}
Also used : MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) Test(org.junit.Test)

Example 5 with MapMarker

use of org.activityinfo.legacy.shared.reports.content.MapMarker 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)

Aggregations

MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)8 BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)4 Test (org.junit.Test)3 IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)2 ArrayList (java.util.ArrayList)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)1 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)1 BubbleMapLayer (org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer)1 IconMapLayer (org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer)1 Extents (org.activityinfo.model.type.geo.Extents)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 JSObject (org.discotools.gwt.leaflet.client.jsobject.JSObject)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