Search in sources :

Example 1 with BaseMapResult

use of org.activityinfo.shared.command.result.BaseMapResult in project activityinfo by bedatadriven.

the class BaseMapDialog method loadBaseMaps.

private void loadBaseMaps() {
    listView.getStore().removeAll();
    listView.getStore().add(googleThumb(GoogleBaseMap.ROADMAP, I18N.CONSTANTS.googleRoadmap()));
    listView.getStore().add(googleThumb(GoogleBaseMap.SATELLITE, I18N.CONSTANTS.googleSatelliteMap()));
    listView.getStore().add(googleThumb(GoogleBaseMap.HYBRID, I18N.CONSTANTS.googleHybrid()));
    listView.getStore().add(googleThumb(GoogleBaseMap.TERRAIN, I18N.CONSTANTS.googleTerrainMap()));
    updateSelection();
    service.execute(new GetBaseMaps(), new MaskingAsyncMonitor(listView, I18N.CONSTANTS.loading()), new AsyncCallback<BaseMapResult>() {

        @Override
        public void onFailure(Throwable caught) {
            failLoadingBaseMaps();
        }

        @Override
        public void onSuccess(BaseMapResult result) {
            List<ModelData> thumbnails = new ArrayList<ModelData>();
            for (BaseMap baseMap : result.getBaseMaps()) {
                thumbnails.add(tileThumb(baseMap));
            }
            listView.getStore().add(thumbnails);
            updateSelection();
        }
    });
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) BaseModelData(com.extjs.gxt.ui.client.data.BaseModelData) MaskingAsyncMonitor(org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor) BaseMapResult(org.activityinfo.shared.command.result.BaseMapResult) GetBaseMaps(org.activityinfo.shared.command.GetBaseMaps) ArrayList(java.util.ArrayList) List(java.util.List) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) GoogleBaseMap(org.activityinfo.shared.map.GoogleBaseMap) BaseMap(org.activityinfo.shared.map.BaseMap)

Example 2 with BaseMapResult

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

Example 3 with BaseMapResult

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

Example 4 with BaseMapResult

use of org.activityinfo.shared.command.result.BaseMapResult in project activityinfo by bedatadriven.

the class DTOs method baseMaps.

public static BaseMapResult baseMaps() {
    TileBaseMap map = new TileBaseMap();
    map.setName("Administrative Map");
    map.setCopyright("Foobar");
    map.setId("admin");
    map.setMinZoom(0);
    map.setMaxZoom(16);
    return new BaseMapResult(Collections.singletonList(map));
}
Also used : TileBaseMap(org.activityinfo.shared.map.TileBaseMap) BaseMapResult(org.activityinfo.shared.command.result.BaseMapResult)

Example 5 with BaseMapResult

use of org.activityinfo.shared.command.result.BaseMapResult 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.shared.report.model.labeling.ArabicNumberSequence) MapContent(org.activityinfo.shared.report.content.MapContent) BaseMapResult(org.activityinfo.shared.command.result.BaseMapResult) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) TableColumn(org.activityinfo.shared.report.model.TableColumn) TableElement(org.activityinfo.shared.report.model.TableElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) SiteResult(org.activityinfo.shared.command.result.SiteResult) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) CircledMapLayer(org.activityinfo.shared.report.model.layers.CircledMapLayer) GetBaseMaps(org.activityinfo.shared.command.GetBaseMaps) SiteDTO(org.activityinfo.shared.dto.SiteDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Aggregations

BaseMapResult (org.activityinfo.shared.command.result.BaseMapResult)5 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)5 GetBaseMaps (org.activityinfo.shared.command.GetBaseMaps)4 BaseModelData (com.extjs.gxt.ui.client.data.BaseModelData)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 SiteResult (org.activityinfo.shared.command.result.SiteResult)1 SiteDTO (org.activityinfo.shared.dto.SiteDTO)1 BaseMap (org.activityinfo.shared.map.BaseMap)1 GoogleBaseMap (org.activityinfo.shared.map.GoogleBaseMap)1 MapContent (org.activityinfo.shared.report.content.MapContent)1 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)1 TableColumn (org.activityinfo.shared.report.model.TableColumn)1 TableElement (org.activityinfo.shared.report.model.TableElement)1 ArabicNumberSequence (org.activityinfo.shared.report.model.labeling.ArabicNumberSequence)1 BubbleMapLayer (org.activityinfo.shared.report.model.layers.BubbleMapLayer)1 CircledMapLayer (org.activityinfo.shared.report.model.layers.CircledMapLayer)1