use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class ExcelMapDataExporter method render.
@Override
public void render(ReportElement element, OutputStream stm) throws IOException {
if (!(element instanceof MapReportElement)) {
throw new RuntimeException("ExcelMapDataExporter accepts only MapElements");
}
MapContent content = ((MapReportElement) element).getContent();
Workbook book = new HSSFWorkbook();
Sheet sheet = book.createSheet();
Helper helper = new Helper(book);
Row headerRow = sheet.createRow(0);
helper.addCell(headerRow, 0, "Latitude");
helper.addCell(headerRow, 1, "Longitude");
helper.addCell(headerRow, 2, "Value");
helper.addCell(headerRow, 3, "Color");
helper.addCell(headerRow, 4, "Icon");
int rowIndex = 1;
for (MapMarker marker : content.getMarkers()) {
Row dataRow = sheet.createRow(rowIndex++);
helper.addCell(dataRow, 0, marker.getLat());
helper.addCell(dataRow, 1, marker.getLng());
if (marker instanceof BubbleMapMarker) {
BubbleMapMarker bmarker = (BubbleMapMarker) marker;
helper.addCell(dataRow, 2, bmarker.getValue());
helper.addCell(dataRow, 3, bmarker.getColor());
}
if (marker instanceof IconMapMarker) {
IconMapMarker imarker = (IconMapMarker) marker;
if (imarker.getIcon() != null) {
helper.addCell(dataRow, 4, imarker.getIcon().getName());
}
}
}
book.write(stm);
}
use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class MapGeneratorTest method adminMapBubbles.
@Test
public void adminMapBubbles() {
AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
clustering.getAdminLevels().add(1);
BubbleMapLayer layer = new BubbleMapLayer();
layer.setClustering(clustering);
layer.addIndicator(1);
Filter filter = new Filter();
filter.addRestriction(DimensionType.Site, 3);
MapReportElement map = new MapReportElement();
map.addLayer(layer);
map.setFilter(filter);
MapContent result = (MapContent) execute(new GenerateElement(map));
System.out.println(result.getMarkers());
BubbleMapMarker marker = (BubbleMapMarker) result.getMarkers().get(0);
assertThat(marker.getSiteIds().size(), equalTo(1));
assertThat(marker.getSiteIds().get(0), equalTo(3));
assertThat(marker.getValue(), equalTo(10000d));
assertThat(result.getUnmappedSites().size(), equalTo(0));
System.out.println(marker.getTitle());
}
use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class LeafletMarkerFactory method create.
public static Marker create(MapMarker mapMarker, final EventHandler... markerEventHandlers) {
final Marker marker;
if (mapMarker instanceof IconMapMarker) {
marker = createIconMapMarker((IconMapMarker) mapMarker);
} else if (mapMarker instanceof PieMapMarker) {
marker = createPieMapMarker((PieMapMarker) mapMarker);
} else if (mapMarker instanceof BubbleMapMarker) {
marker = createBubbleMapMarker((BubbleMapMarker) mapMarker);
} else {
final Options options = new Options();
setModel(options.getJSObject(), mapMarker);
marker = new Marker(toLatLng(mapMarker), options);
}
if (markerEventHandlers != null) {
for (EventHandler handler : markerEventHandlers) {
EventHandlerManager.addEventHandler(marker, EventHandler.Events.click, handler);
}
}
return marker;
}
use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class GeoDigestRenderer method renderDatabase.
private void renderDatabase(StringBuilder html, DatabaseModel databaseModel) throws IOException {
html.append("<div class='geo-database' style='margin-top:20px'>");
html.append("<span class='geo-header' style='font-weight:bold; color: #" + BUBBLE_COLOR + ";'>");
html.append(databaseModel.getName());
html.append("</span><br>");
html.append("<img class='geo-graph' width=\"450px\" src=\"");
html.append(databaseModel.getUrl());
html.append("\" /><br><br>");
for (MapMarker marker : databaseModel.getContent().getMarkers()) {
String label = ((BubbleMapMarker) marker).getLabel();
html.append("<span class='geo-marker-header' style='color: #" + BUBBLE_COLOR + "; font-weight:bold;'>");
html.append(label);
html.append(":</span><br>");
LOGGER.finest(marker.getSiteIds().size() + " sites for marker " + label + ": " + marker.getSiteIds());
renderSites(html, databaseModel, marker.getSiteIds());
}
if (!databaseModel.getContent().getUnmappedSites().isEmpty()) {
html.append("<br><span class='geo-unmapped-header' style='color:black; font-weight:bold;'>");
html.append(I18N.MESSAGES.geoDigestUnmappedSites());
html.append(":</span><br>");
LOGGER.finest(databaseModel.getContent().getUnmappedSites().size() + " unmapped sites");
renderSites(html, databaseModel, databaseModel.getContent().getUnmappedSites());
}
html.append("</div>");
}
use of org.activityinfo.legacy.shared.reports.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class LRTBComparatorTest method testComparator.
@Test
public void testComparator() {
MapMarker ul = new BubbleMapMarker();
ul.setX(1);
ul.setY(1);
MapMarker ul2 = new BubbleMapMarker();
ul2.setX(60);
ul2.setY(0);
MapMarker c = new BubbleMapMarker();
c.setX(30);
c.setY(50);
MapMarker ll = new BubbleMapMarker();
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));
}
Aggregations