Search in sources :

Example 1 with TileBaseMap

use of org.activityinfo.shared.map.TileBaseMap in project activityinfo by bedatadriven.

the class LeafletReportOverlays method setBaseMap.

public void setBaseMap(BaseMap baseMap) {
    TileBaseMap tileBaseMap = MapboxLayers.toTileBaseMap(baseMap);
    if (!Objects.equal(currentBaseMap, tileBaseMap)) {
        if (baseLayer != null) {
            mapWidget.removeLayer(baseLayer);
        }
        Options options = new Options();
        options.setProperty("minZoom", tileBaseMap.getMinZoom());
        options.setProperty("maxZoom", tileBaseMap.getMaxZoom());
        baseLayer = new TileLayer(tileBaseMap.getTileUrlPattern(), options);
        mapWidget.addLayer(baseLayer, true);
        if (mapWidget.getZoom() > tileBaseMap.getMaxZoom()) {
            mapWidget.setZoom(tileBaseMap.getMaxZoom());
        }
        if (mapWidget.getZoom() < tileBaseMap.getMinZoom()) {
            mapWidget.setZoom(tileBaseMap.getMinZoom());
        }
    }
}
Also used : Options(org.discotools.gwt.leaflet.client.Options) GeoJSONOptions(org.discotools.gwt.leaflet.client.layers.others.GeoJSONOptions) TileLayer(org.discotools.gwt.leaflet.client.layers.raster.TileLayer) TileBaseMap(org.activityinfo.shared.map.TileBaseMap)

Example 2 with TileBaseMap

use of org.activityinfo.shared.map.TileBaseMap in project activityinfo by bedatadriven.

the class MapGenerator method getBaseMap.

private BaseMap getBaseMap(String baseMapId) {
    BaseMapResult maps = dispatcher.execute(new GetBaseMaps());
    for (TileBaseMap map : maps.getBaseMaps()) {
        if (map.getId().equals(baseMapId)) {
            return map;
        }
    }
    LOGGER.log(Level.SEVERE, "Could not find base map id=" + baseMapId);
    return TileBaseMap.createNullMap(baseMapId);
}
Also used : BaseMapResult(org.activityinfo.shared.command.result.BaseMapResult) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) GetBaseMaps(org.activityinfo.shared.command.GetBaseMaps)

Example 3 with TileBaseMap

use of org.activityinfo.shared.map.TileBaseMap in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawBasemap.

protected void drawBasemap(MapReportElement element, TileHandler tileHandler) {
    TiledMap map = createTileMap(element);
    BaseMap baseMap = element.getContent().getBaseMap();
    try {
        if (baseMap instanceof TileBaseMap) {
            drawTiledBaseMap(tileHandler, map, baseMap);
        } else if (baseMap instanceof GoogleBaseMap) {
            drawTiledBaseMap(tileHandler, map, MapboxLayers.toTileBaseMap(baseMap));
        }
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Exception drawing basemap", e);
    }
}
Also used : TileBaseMap(org.activityinfo.shared.map.TileBaseMap) TiledMap(org.activityinfo.server.report.generator.map.TiledMap) GoogleBaseMap(org.activityinfo.shared.map.GoogleBaseMap) GoogleBaseMap(org.activityinfo.shared.map.GoogleBaseMap) BaseMap(org.activityinfo.shared.map.BaseMap) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) IOException(java.io.IOException)

Example 4 with TileBaseMap

use of org.activityinfo.shared.map.TileBaseMap 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 5 with TileBaseMap

use of org.activityinfo.shared.map.TileBaseMap in project activityinfo by bedatadriven.

the class ItextReportRendererTest method htmlImages.

@Test
public void htmlImages() throws IOException {
    DummyPivotTableData data = new DummyPivotTableData();
    PivotChartContent chartContent = new PivotChartContent();
    chartContent.setData(data.table);
    chartContent.setYMin(0);
    chartContent.setYStep(100);
    chartContent.setFilterDescriptions(Collections.EMPTY_LIST);
    PivotChartReportElement chart = new PivotChartReportElement(Type.Pie);
    chart.setTitle("My Pie Chart");
    chart.setCategoryDimensions(data.colDims);
    chart.setSeriesDimensions(data.rowDims);
    chart.setContent(chartContent);
    PivotContent tableContent = new PivotContent();
    tableContent.setFilterDescriptions(Collections.EMPTY_LIST);
    tableContent.setData(data.table);
    PivotTableReportElement table = new PivotTableReportElement();
    table.setColumnDimensions(data.colDims);
    table.setRowDimensions(data.rowDims);
    table.setTitle("My Table");
    table.setContent(tableContent);
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("http://mt{s}.aimaps.net/nordkivu.cd/v1/z{z}/{x}x{y}.png");
    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);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(chart);
    report.addElement(table);
    report.addElement(new TextReportElement("Testing 1..2.3.. français"));
    report.addElement(map);
    renderToPdf(report, "piechart.pdf");
    renderToHtml(report, "piechart.html");
    // renderToHtmlUsingWriter(report, "piechart2.html");
    renderToRtf(report, "piechart.rtf");
}
Also used : 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) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) Extents(org.activityinfo.shared.util.mapping.Extents) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PivotContent(org.activityinfo.shared.report.content.PivotContent) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent) Test(org.junit.Test)

Aggregations

TileBaseMap (org.activityinfo.shared.map.TileBaseMap)11 MapContent (org.activityinfo.shared.report.content.MapContent)5 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)5 Test (org.junit.Test)5 BaseMapResult (org.activityinfo.shared.command.result.BaseMapResult)4 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)4 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)4 MapMarker (org.activityinfo.shared.report.content.MapMarker)4 ReportContent (org.activityinfo.shared.report.content.ReportContent)4 Report (org.activityinfo.shared.report.model.Report)4 Extents (org.activityinfo.shared.util.mapping.Extents)4 GetBaseMaps (org.activityinfo.shared.command.GetBaseMaps)3 BaseMap (org.activityinfo.shared.map.BaseMap)2 GoogleBaseMap (org.activityinfo.shared.map.GoogleBaseMap)2 BubbleMapLayer (org.activityinfo.shared.report.model.layers.BubbleMapLayer)2 IconMapLayer (org.activityinfo.shared.report.model.layers.IconMapLayer)2 File (java.io.File)1 IOException (java.io.IOException)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)1