use of org.activityinfo.shared.util.mapping.Extents 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");
}
use of org.activityinfo.shared.util.mapping.Extents 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");
}
use of org.activityinfo.shared.util.mapping.Extents in project activityinfo by bedatadriven.
the class LocationMap method afterRender.
@Override
protected void afterRender() {
super.afterRender();
Extents countryBounds = searchPresenter.getCountry().getBounds();
MapOptions mapOptions = new MapOptions();
mapOptions.setCenter(new LatLng(countryBounds.getCenterY(), countryBounds.getCenterX()));
mapOptions.setZoom(6);
mapOptions.setProperty("crs", new EPSG3857());
TileLayer baseLayer = new TileLayer(MapboxLayers.MAPBOX_STREETS, new Options());
markerLayer = new LayerGroup(new ILayer[0]);
map = new Map(getElement().getElementsByTagName("div").getItem(0), mapOptions);
map.addLayer(baseLayer);
map.addLayer(markerLayer);
bindEvents();
}
use of org.activityinfo.shared.util.mapping.Extents in project activityinfo by bedatadriven.
the class AdminTileRenderer method render.
public byte[] render(int zoom, int x, int y) throws IOException {
Extents extents = TileMath.tileBounds(zoom, x, y);
mapPixelBounds = new Envelope(0, TileMath.TILE_SIZE, 0, TileMath.TILE_SIZE);
Envelope envelope = new Envelope(extents.getMinLon(), extents.getMaxLon(), extents.getMinLat(), extents.getMaxLat());
Geometry filter = gf.toGeometry(envelope);
LOGGER.info("Creating Buffered Image...");
BufferedImage image = new BufferedImage(TileMath.TILE_SIZE, TileMath.TILE_SIZE, ColorSpace.TYPE_RGB);
Graphics2D g2d = image.createGraphics();
g2d.setPaint(Color.WHITE);
g2d.fillRect(0, 0, TileMath.TILE_SIZE, TileMath.TILE_SIZE);
LOGGER.info("Querying geometry...");
Criteria criteria = session.createCriteria(AdminEntity.class);
criteria.add(SpatialRestrictions.filter("geometry", filter));
criteria.add(Restrictions.eq("level", level));
TiledMap map = new TiledMap(zoom, new Tile(x, y));
g2d.setColor(Color.BLACK);
g2d.setStroke(new BasicStroke(1));
g2d.setFont(new Font("Arial", 0, 10));
List<AdminEntity> entities = criteria.list();
/*
* Project Geometry onto this tile
*/
LOGGER.info("Projecting geometry...");
GeometryProjecter projector = new GeometryProjecter(map);
Map<Integer, Geometry> projected = Maps.newHashMap();
for (AdminEntity entity : entities) {
LOGGER.info(entity.getName());
Geometry transformed = projector.transform(entity.getGeometry());
Geometry simplified = DouglasPeuckerSimplifier.simplify(transformed, 1.25);
projected.put(entity.getId(), simplified);
}
/*
* Draw outlines
*/
LOGGER.info("Drawing geometry...");
for (AdminEntity entity : entities) {
Geometry geom = projected.get(entity.getId());
g2d.draw(toPath(geom));
}
/*
* Draw labels
*/
LOGGER.info("Drawing geometry...");
for (AdminEntity entity : entities) {
Geometry geom = projected.get(entity.getId());
// Polygon polygon = largestPolygon(geom);
//
// if (polygon != null) {
// labelPolygon(g2d, polygon, entity.getName());
// }
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
return baos.toByteArray();
}
use of org.activityinfo.shared.util.mapping.Extents in project activityinfo by bedatadriven.
the class GetSitePointsHandler method toPointList.
protected SitePointList toPointList(List<SiteDTO> sites) {
Extents bounds = Extents.empty();
List<SitePointDTO> points = new ArrayList<SitePointDTO>(sites.size());
for (SiteDTO site : sites) {
if (site.hasLatLong()) {
points.add(new SitePointDTO(site.getId(), site.getLongitude(), site.getLatitude()));
bounds.grow(site.getLatitude(), site.getLongitude());
}
}
return new SitePointList(bounds, points);
}
Aggregations