Search in sources :

Example 1 with IconMapMarker

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

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

the class IconLayerGenerator method createMarkersFrom.

private void createMarkersFrom(List<Cluster> clusters, TiledMap map, MapContent content) {
    for (Cluster cluster : clusters) {
        IconMapMarker marker = new IconMapMarker();
        marker.setX(cluster.getPoint().getX());
        marker.setY(cluster.getPoint().getY());
        AiLatLng latlng = map.fromPixelToLatLng(cluster.getPoint());
        marker.setLat(latlng.getLat());
        marker.setLng(latlng.getLng());
        marker.setTitle(formatTitle(cluster));
        marker.setIcon(icon);
        marker.setIndicatorId(layer.getIndicatorIds().get(0));
        for (PointValue pv : cluster.getPointValues()) {
            marker.getSiteIds().add(pv.getSite().getId());
        }
        content.getMarkers().add(marker);
    }
}
Also used : PointValue(org.activityinfo.legacy.shared.reports.model.PointValue) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) Cluster(org.activityinfo.server.report.generator.map.cluster.Cluster) AiLatLng(org.activityinfo.model.type.geo.AiLatLng)

Example 3 with IconMapMarker

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

the class MapGeneratorTest method adminMapIcon.

@Test
public void adminMapIcon() {
    AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
    clustering.getAdminLevels().add(1);
    IconMapLayer layer = new IconMapLayer();
    layer.setClustering(clustering);
    layer.getIndicatorIds().add(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());
    IconMapMarker marker = (IconMapMarker) result.getMarkers().get(0);
    assertThat(marker.getSiteIds().size(), equalTo(1));
    assertThat(marker.getSiteIds().get(0), equalTo(3));
    System.out.println(marker.getTitle());
    // assertThat(marker., equalTo(10000d));
    assertThat(result.getUnmappedSites().size(), equalTo(0));
}
Also used : MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) AdministrativeLevelClustering(org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering) IconMapLayer(org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer) MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) Test(org.junit.Test)

Example 4 with IconMapMarker

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

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

the class LeafletMarkerFactory method createIconMapMarker.

/**
 * Creates a Leaflet marker based on an ActivityInfo MapIcon
 */
public static Marker createIconMapMarker(IconMapMarker model) {
    MapIcon iconModel = model.getIcon();
    String iconUrl = "mapicons/" + iconModel.getName() + ".png";
    IconOptions iconOptions = new IconOptions();
    iconOptions.setIconUrl(iconUrl);
    iconOptions.setIconAnchor(new Point(iconModel.getAnchorX(), iconModel.getAnchorY()));
    iconOptions.setIconSize(new Point(iconModel.getWidth(), iconModel.getHeight()));
    Options markerOptions = new MarkerOptions();
    markerOptions.setProperty("icon", new Icon(iconOptions));
    setModel(markerOptions.getJSObject(), model);
    return new Marker(toLatLng(model), markerOptions);
}
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) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) Point(org.discotools.gwt.leaflet.client.types.Point) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) 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) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Aggregations

IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)5 BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)3 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)3 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)2 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)2 Options (org.discotools.gwt.leaflet.client.Options)2 CircleMarker (org.discotools.gwt.leaflet.client.marker.CircleMarker)2 Marker (org.discotools.gwt.leaflet.client.marker.Marker)2 MarkerOptions (org.discotools.gwt.leaflet.client.marker.MarkerOptions)2 IconOptions (org.discotools.gwt.leaflet.client.types.IconOptions)2 MapIcon (org.activityinfo.legacy.shared.reports.model.MapIcon)1 PointValue (org.activityinfo.legacy.shared.reports.model.PointValue)1 AdministrativeLevelClustering (org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering)1 IconMapLayer (org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer)1 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)1 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 EventHandler (org.discotools.gwt.leaflet.client.events.handler.EventHandler)1 Icon (org.discotools.gwt.leaflet.client.types.Icon)1