Search in sources :

Example 6 with MapMarker

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

the class ItextReportRendererTest method googleMapsBaseMap.

@Test
public void googleMapsBaseMap() throws IOException {
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    TileBaseMap referenceBaseMap = new TileBaseMap();
    referenceBaseMap.setTileUrlPattern("http://www.activityinfo.org/resources/tile/admin.cd/{z}/{x}/{y}.png");
    referenceBaseMap.setName("Administrative Map");
    BaseMap[] baseMaps = new BaseMap[] { referenceBaseMap, GoogleBaseMap.HYBRID, GoogleBaseMap.ROADMAP, GoogleBaseMap.SATELLITE, GoogleBaseMap.TERRAIN };
    for (BaseMap baseMap : baseMaps) {
        BubbleMapMarker marker1 = new BubbleMapMarker();
        marker1.setLat(-2.45);
        marker1.setLng(28.8);
        marker1.setX(100);
        marker1.setY(100);
        marker1.setRadius(25);
        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 satelliteMap = new MapReportElement();
        satelliteMap.setTitle(baseMap.toString());
        satelliteMap.setContent(mapContent);
        report.addElement(satelliteMap);
    }
    // renderToPdf(report, "google map.pdf");
    // renderToHtml(report, "google map.html");
    renderToRtf(report, "google map.rtf");
}
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) Report(org.activityinfo.shared.report.model.Report) MapContent(org.activityinfo.shared.report.content.MapContent) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Extents(org.activityinfo.shared.util.mapping.Extents) GoogleBaseMap(org.activityinfo.shared.map.GoogleBaseMap) BaseMap(org.activityinfo.shared.map.BaseMap) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) Test(org.junit.Test)

Example 7 with MapMarker

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

the class PPTMapRenderer method render.

public void render(MapReportElement element, SlideShow ppt) throws IOException {
    // add first slide
    Slide slide = ppt.createSlide();
    // calculate map offset
    Dimension pageSize = ppt.getPageSize();
    int offsetX = ((int) pageSize.getWidth() - element.getWidth()) / 2;
    int offsetY = ((int) pageSize.getHeight() - element.getHeight()) / 2;
    // add the map background image
    drawBasemap(element, new PPTTileHandler(ppt, slide));
    // keep a list of map icons
    Map<String, Integer> iconPictureIndex = new HashMap<String, Integer>();
    // Add the indicator markers to the slide as shapes
    for (MapMarker marker : element.getContent().getMarkers()) {
        if (inView(element, marker)) {
            if (marker instanceof IconMapMarker) {
                addIconMarker(ppt, slide, offsetX, offsetY, iconPictureIndex, (IconMapMarker) marker);
            } else if (marker instanceof BubbleMapMarker) {
                addBubble(slide, offsetX, offsetY, (BubbleMapMarker) marker);
            }
        }
    }
}
Also used : MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Slide(org.apache.poi.hslf.model.Slide) HashMap(java.util.HashMap) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Dimension(com.google.code.appengine.awt.Dimension)

Example 8 with MapMarker

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

the class LRTBComparatorTest method testComparator.

@Test
public void testComparator() {
    MapMarker ul = new MapMarker();
    ul.setX(1);
    ul.setY(1);
    MapMarker ul2 = new MapMarker();
    ul2.setX(60);
    ul2.setY(0);
    MapMarker c = new MapMarker();
    c.setX(30);
    c.setY(50);
    MapMarker ll = new MapMarker();
    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 : MapMarker(org.activityinfo.shared.report.content.MapMarker) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with MapMarker

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

the class ItextReportRendererTest method legendTest.

@Test
public void legendTest() throws IOException {
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    marker1.setValue(300);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    BubbleMapLayer layer1 = new BubbleMapLayer();
    layer1.addIndicatorId(101);
    layer1.setMinRadius(10);
    layer1.setMaxRadius(10);
    BubbleLayerLegend legend1 = new BubbleLayerLegend();
    legend1.setDefinition(layer1);
    legend1.setMinValue(1000);
    legend1.setMaxValue(3000);
    BubbleMapLayer layer2 = new BubbleMapLayer();
    layer2.addIndicatorId(102);
    layer2.addIndicatorId(103);
    layer2.setMinRadius(10);
    layer2.setMaxRadius(25);
    BubbleLayerLegend legend2 = new BubbleLayerLegend();
    legend2.setDefinition(layer2);
    legend2.setMinValue(600);
    legend2.setMaxValue(999);
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    IconLayerLegend legend3 = new IconLayerLegend();
    legend3.setDefinition(layer3);
    List<PieChartLegend> pieChartLegends = Lists.newArrayList();
    List<PiechartMapLayer> pieChartLayers = Lists.newArrayList();
    int[] indicatorIds = new int[] { 101, 102, 103 };
    for (int sliceCount = 1; sliceCount < 10; ++sliceCount) {
        PiechartMapLayer pieChartLayer = new PiechartMapLayer();
        for (int i = 0; i != sliceCount; ++i) {
            pieChartLayer.addIndicatorId(indicatorIds[i % indicatorIds.length]);
        }
        pieChartLayer.setMinRadius(25);
        pieChartLayer.setMaxRadius(25);
        PieChartLegend pieChartLegend = new PieChartLegend();
        pieChartLegend.setDefinition(pieChartLayer);
        pieChartLayers.add(pieChartLayer);
        pieChartLegends.add(pieChartLegend);
    }
    IndicatorDTO indicator101 = new IndicatorDTO();
    indicator101.setId(101);
    indicator101.setName("Nombre de salles de classe fonctionnelles (construites, rehabilitees, equipees) " + "pour l'education formelle et non formelle.");
    IndicatorDTO indicator102 = new IndicatorDTO();
    indicator102.setId(102);
    indicator102.setName("Nombre d'enfants ayant beneficie de kits scolaires, recreatifs et didactiques");
    IndicatorDTO indicator103 = new IndicatorDTO();
    indicator103.setId(103);
    indicator103.setName("Pourcentage des ménages qui utilsent la moustiquaire rationnellement");
    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));
    mapContent.getIndicators().addAll(Arrays.asList(indicator101, indicator102, indicator103));
    mapContent.addLegend(legend1);
    mapContent.addLegend(legend2);
    mapContent.addLegend(legend3);
    mapContent.getLegends().addAll(pieChartLegends);
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    map.addLayer(layer1);
    map.addLayer(layer2);
    map.addLayer(layer3);
    map.getLayers().addAll(pieChartLayers);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "legend.pdf");
    renderToHtml(report, "legend.html");
    renderToRtf(report, "legend.rtf");
    renderToPpt(map, "legend.ppt");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) BubbleLayerLegend(org.activityinfo.shared.report.content.BubbleLayerLegend) 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) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) Extents(org.activityinfo.shared.util.mapping.Extents) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) PieChartLegend(org.activityinfo.shared.report.content.PieChartLegend) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) PiechartMapLayer(org.activityinfo.shared.report.model.layers.PiechartMapLayer) IconLayerLegend(org.activityinfo.shared.report.content.IconLayerLegend) Test(org.junit.Test)

Aggregations

MapMarker (org.activityinfo.shared.report.content.MapMarker)9 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)7 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)6 MapContent (org.activityinfo.shared.report.content.MapContent)5 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)5 Extents (org.activityinfo.shared.util.mapping.Extents)5 Test (org.junit.Test)5 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)4 ReportContent (org.activityinfo.shared.report.content.ReportContent)4 Report (org.activityinfo.shared.report.model.Report)4 ArrayList (java.util.ArrayList)2 BubbleLayerLegend (org.activityinfo.shared.report.content.BubbleLayerLegend)2 IconMapLayer (org.activityinfo.shared.report.model.layers.IconMapLayer)2 Dimension (com.google.code.appengine.awt.Dimension)1 HashMap (java.util.HashMap)1 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)1 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)1 Clusterer (org.activityinfo.server.report.generator.map.cluster.Clusterer)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 BaseMap (org.activityinfo.shared.map.BaseMap)1