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());
}
}
}
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);
}
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);
}
}
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");
}
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");
}
Aggregations