Search in sources :

Example 1 with IconMapMarker

use of org.activityinfo.shared.report.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.shared.report.model.PointValue) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) Cluster(org.activityinfo.server.report.generator.map.cluster.Cluster) AiLatLng(org.activityinfo.shared.report.content.AiLatLng)

Example 2 with IconMapMarker

use of org.activityinfo.shared.report.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 : CreationHelper(org.apache.poi.ss.usermodel.CreationHelper) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) MapContent(org.activityinfo.shared.report.content.MapContent) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) Workbook(org.apache.poi.ss.usermodel.Workbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 3 with IconMapMarker

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

the class ItextReportRendererTest method iconTest.

@Test
public void iconTest() throws IOException {
    IconMapMarker marker1 = new IconMapMarker();
    marker1.setIcon(MapIcon.fromEnum(Icon.Default));
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    MapContent mapContent = new MapContent();
    mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
    mapContent.setBaseMap(baseMap);
    mapContent.setZoomLevel(8);
    mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
    mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    map.addLayer(layer3);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "iconMarker.pdf");
    renderToHtml(report, "iconMarker.html");
    renderToRtf(report, "iconMarker.rtf");
    renderToPpt(map, "iconMarker.ppt");
    renderToImage(map, "iconMarker.png");
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportContent(org.activityinfo.shared.report.content.ReportContent) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) IconMapLayer(org.activityinfo.shared.report.model.layers.IconMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) Extents(org.activityinfo.shared.util.mapping.Extents) Test(org.junit.Test)

Example 4 with IconMapMarker

use of org.activityinfo.shared.report.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.shared.report.model.MapReportElement) AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) IconMapLayer(org.activityinfo.shared.report.model.layers.IconMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) Test(org.junit.Test)

Example 5 with IconMapMarker

use of org.activityinfo.shared.report.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));
    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.shared.report.model.MapIcon) Point(org.discotools.gwt.leaflet.client.types.Point) MapIcon(org.activityinfo.shared.report.model.MapIcon) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Aggregations

IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)6 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)4 MapMarker (org.activityinfo.shared.report.content.MapMarker)4 MapContent (org.activityinfo.shared.report.content.MapContent)3 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)3 IconMapLayer (org.activityinfo.shared.report.model.layers.IconMapLayer)2 Test (org.junit.Test)2 Dimension (com.google.code.appengine.awt.Dimension)1 HashMap (java.util.HashMap)1 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)1 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)1 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)1 PieMapMarker (org.activityinfo.shared.report.content.PieMapMarker)1 ReportContent (org.activityinfo.shared.report.content.ReportContent)1 MapIcon (org.activityinfo.shared.report.model.MapIcon)1 PointValue (org.activityinfo.shared.report.model.PointValue)1 Report (org.activityinfo.shared.report.model.Report)1 AdministrativeLevelClustering (org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering)1 Extents (org.activityinfo.shared.util.mapping.Extents)1 Slide (org.apache.poi.hslf.model.Slide)1