Search in sources :

Example 1 with TileBaseMap

use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.

the class BaseMapPanel method loadTileMapLabel.

private void loadTileMapLabel() {
    label.setText(I18N.CONSTANTS.loading());
    dispatcher.execute(new GetBaseMaps(), new AsyncCallback<BaseMapResult>() {

        @Override
        public void onFailure(Throwable caught) {
            label.setText(value);
        }

        @Override
        public void onSuccess(BaseMapResult result) {
            for (TileBaseMap baseMap : result.getBaseMaps()) {
                if (baseMap.getId().equals(value)) {
                    label.setText(baseMap.getName());
                    return;
                }
            }
            label.setText(value);
        }
    });
}
Also used : BaseMapResult(org.activityinfo.legacy.shared.command.result.BaseMapResult) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) GetBaseMaps(org.activityinfo.legacy.shared.command.GetBaseMaps)

Example 2 with TileBaseMap

use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.

the class MapboxLayers method toTileBaseMap.

public static TileBaseMap toTileBaseMap(BaseMap baseMap) {
    if (baseMap instanceof TileBaseMap) {
        return (TileBaseMap) baseMap;
    } else {
        String url;
        if (baseMap.equals(GoogleBaseMap.ROADMAP)) {
            url = MAPBOX_STREETS;
        } else if (baseMap.equals(GoogleBaseMap.TERRAIN)) {
            url = MAPBOX_TERRAIN;
        } else if (baseMap.equals(GoogleBaseMap.SATELLITE)) {
            url = MAPBOX_SATELLITE;
        } else if (baseMap.equals(GoogleBaseMap.HYBRID)) {
            url = MAPBOX_HYBRID;
        } else {
            url = MAPBOX_STREETS;
        }
        TileBaseMap tileBaseMap = new TileBaseMap();
        tileBaseMap.setId(url);
        tileBaseMap.setMinZoom(2);
        tileBaseMap.setMaxZoom(18);
        tileBaseMap.setTileUrlPattern(url);
        return tileBaseMap;
    }
}
Also used : TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap)

Example 3 with TileBaseMap

use of org.activityinfo.legacy.shared.model.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.legacy.shared.command.result.BaseMapResult) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) GetBaseMaps(org.activityinfo.legacy.shared.command.GetBaseMaps)

Example 4 with TileBaseMap

use of org.activityinfo.legacy.shared.model.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.legacy.shared.model.TileBaseMap) TiledMap(org.activityinfo.server.report.generator.map.TiledMap) BaseMap(org.activityinfo.legacy.shared.model.BaseMap) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) IOException(java.io.IOException)

Example 5 with TileBaseMap

use of org.activityinfo.legacy.shared.model.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");
    renderToImage(map, "iconMarker.png");
}
Also used : IconMapLayer(org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) Extents(org.activityinfo.model.type.geo.Extents) Test(org.junit.Test)

Aggregations

TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)10 Test (org.junit.Test)5 Extents (org.activityinfo.model.type.geo.Extents)4 GetBaseMaps (org.activityinfo.legacy.shared.command.GetBaseMaps)3 BaseMapResult (org.activityinfo.legacy.shared.command.result.BaseMapResult)3 BaseMap (org.activityinfo.legacy.shared.model.BaseMap)2 BubbleMapLayer (org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer)2 IconMapLayer (org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer)2 IOException (java.io.IOException)1 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)1 IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)1 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)1 TableColumn (org.activityinfo.legacy.shared.reports.model.TableColumn)1 TableElement (org.activityinfo.legacy.shared.reports.model.TableElement)1 ArabicNumberSequence (org.activityinfo.legacy.shared.reports.model.labeling.ArabicNumberSequence)1 CircledMapLayer (org.activityinfo.legacy.shared.reports.model.layers.CircledMapLayer)1 PiechartMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1