Search in sources :

Example 6 with BubbleMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer in project activityinfo by bedatadriven.

the class TableGeneratorTest method testMap.

// 
// @Test
// public void tableWithMap() {
// 
// MapReportElement map = new MapReportElement();
// map.setBaseMapId(GoogleBaseMap.ROADMAP.getId());
// 
// BubbleMapLayer layer = new BubbleMapLayer();
// layer.addIndicator(INDICATOR_ID);
// map.addLayer(layer);
// 
// TableElement table = new TableElement();
// table.setMap(map);
// 
// TableColumn column = new TableColumn("Location", "location.name");
// table.addColumn(column);
// 
// TableColumn mapColumn = new TableColumn("Map", "map");
// table.addColumn(mapColumn);
// 
// DispatcherSync dispatcher = createDispatcher();
// TableGenerator gtor = new TableGenerator(dispatcher, new
// MapGenerator(dispatcher, null, null));
// gtor.generate(user, table, null, null);
// 
// Assert.assertNotNull("content is set", table.getContent());
// 
// TableData data = table.getContent().getData();
// List<SiteDTO> rows = data.getRows();
// Assert.assertEquals("row count", 1, rows.size());
// 
// SiteDTO row = rows.get(0);
// assertThat((String)row.get(column.getSitePropertyName()),
// equalTo("tampa bay"));
// assertThat((String)row.get("map"), equalTo("1"));
// }
@Test
public void testMap() {
    TableElement table = new TableElement();
    table.addColumn(new TableColumn("Index", "map"));
    table.addColumn(new TableColumn("Site", "location.name"));
    MapReportElement map = new MapReportElement();
    map.setBaseMapId("map1");
    CircledMapLayer layer = new BubbleMapLayer();
    layer.setLabelSequence(new ArabicNumberSequence());
    map.addLayer(layer);
    table.setMap(map);
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(GetSites.class))).andReturn(new SiteResult(dummySite())).anyTimes();
    TileBaseMap baseMap1 = new TileBaseMap();
    baseMap1.setId("map1");
    baseMap1.setMinZoom(0);
    baseMap1.setMaxZoom(12);
    baseMap1.setCopyright("(C)");
    baseMap1.setName("Grand Canyon");
    baseMap1.setTileUrlPattern("http://s/test.png");
    expect(dispatcher.execute(isA(GetBaseMaps.class))).andReturn(new BaseMapResult(Collections.singletonList(baseMap1)));
    replay(dispatcher);
    TableGenerator gtor = new TableGenerator(dispatcher, new MapGenerator(dispatcher, new MockIndicatorDAO()));
    gtor.generate(user, table, null, null);
    MapContent mapContent = map.getContent();
    Assert.assertNotNull("map content", mapContent);
    Assert.assertEquals("marker count", 1, mapContent.getMarkers().size());
    Assert.assertEquals("label on marker", "1", ((BubbleMapMarker) mapContent.getMarkers().get(0)).getLabel());
    Map<Integer, String> siteLabels = mapContent.siteLabelMap();
    Assert.assertEquals("site id in map", "1", siteLabels.get(1));
    SiteDTO row = table.getContent().getData().getRows().get(0);
    Assert.assertEquals("label on row", "1", row.get("map"));
}
Also used : ArabicNumberSequence(org.activityinfo.legacy.shared.reports.model.labeling.ArabicNumberSequence) MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) BaseMapResult(org.activityinfo.legacy.shared.command.result.BaseMapResult) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) TableColumn(org.activityinfo.legacy.shared.reports.model.TableColumn) TableElement(org.activityinfo.legacy.shared.reports.model.TableElement) MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) CircledMapLayer(org.activityinfo.legacy.shared.reports.model.layers.CircledMapLayer) GetBaseMaps(org.activityinfo.legacy.shared.command.GetBaseMaps) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Example 7 with BubbleMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer in project activityinfo by bedatadriven.

the class MgMapIntegrationTest method sitesBoundToAdminLevelsAreAutoClusteredProperly.

@Test
public void sitesBoundToAdminLevelsAreAutoClusteredProperly() throws IOException {
    BubbleMapLayer layer = new BubbleMapLayer();
    layer.addIndicator(NUMBER_OF_BENE_INDICATOR_ID);
    layer.setClustering(new AutomaticClustering());
    generateMap(layer, "mg-auto-cluster");
    assertThat(content.getMarkers().size(), equalTo(4));
    assertThat(content.getUnmappedSites().size(), equalTo(0));
}
Also used : BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) AutomaticClustering(org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering) Test(org.junit.Test)

Example 8 with BubbleMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer in project activityinfo by bedatadriven.

the class MgMapIntegrationTest method sitesBoundToAdminLevelsAreClusteredByAdminLevelMissingBounds.

@Test
public void sitesBoundToAdminLevelsAreClusteredByAdminLevelMissingBounds() throws IOException {
    BubbleMapLayer layer = new BubbleMapLayer();
    layer.addIndicator(NUMBER_OF_BENE_INDICATOR_ID);
    layer.setClustering(clusterByFokotany());
    generateMap(layer, "mg-cluster-fok");
    assertThat(content.getMarkers().size(), equalTo(10));
    assertThat(content.getUnmappedSites().size(), equalTo(0));
}
Also used : BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) Test(org.junit.Test)

Example 9 with BubbleMapLayer

use of org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer in project activityinfo by bedatadriven.

the class ReadWriteReportTest method readWriteReportTest.

@Test
public void readWriteReportTest() throws Throwable {
    Report report = new Report();
    MapReportElement map = new MapReportElement();
    map.getLayers().add(new BubbleMapLayer());
    PiechartMapLayer pielayer = new PiechartMapLayer();
    Slice slice1 = new Slice();
    slice1.setColor("FF00AA");
    slice1.setIndicatorId(1);
    Slice slice2 = new Slice();
    slice2.setColor("00FFAA");
    slice2.setIndicatorId(2);
    pielayer.getSlices().add(slice1);
    pielayer.getSlices().add(slice2);
    map.getLayers().add(pielayer);
    report.getElements().add(map);
    Report.class.getPackage();
    JAXBContext jc = JAXBContext.newInstance(Report.class.getPackage().getName());
    Marshaller marshaller = jc.createMarshaller();
    marshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    try (FileOutputStream fo = TestOutput.open(getClass(), "SomeXmlTest", ".xml")) {
        marshaller.marshal(report, fo);
    }
}
Also used : MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) Marshaller(javax.xml.bind.Marshaller) Report(org.activityinfo.legacy.shared.reports.model.Report) Slice(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer.Slice) FileOutputStream(java.io.FileOutputStream) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) JAXBContext(javax.xml.bind.JAXBContext) PiechartMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer) Test(org.junit.Test)

Aggregations

BubbleMapLayer (org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer)9 Test (org.junit.Test)7 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)4 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)3 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)2 AutomaticClustering (org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)2 ArabicNumberSequence (org.activityinfo.legacy.shared.reports.model.labeling.ArabicNumberSequence)2 PiechartMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer)2 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 GetBaseMaps (org.activityinfo.legacy.shared.command.GetBaseMaps)1 BaseMapResult (org.activityinfo.legacy.shared.command.result.BaseMapResult)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 BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)1 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)1