Search in sources :

Example 1 with AdministrativeLevelClustering

use of org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering in project activityinfo by bedatadriven.

the class PointLayerGenerator method queryFor.

private GetSites queryFor(Filter effectiveFilter, PointMapLayer layer) {
    Filter layerFilter = new Filter(effectiveFilter, layer.getFilter());
    for (int id : layer.getIndicatorIds()) {
        Indicator indicator = indicators.get(id);
        if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SITE_COUNT) {
            layerFilter.addRestriction(DimensionType.Activity, indicator.getActivity().getId());
        } else {
            layerFilter.addRestriction(DimensionType.Indicator, indicator.getId());
        }
    }
    layerFilter.addRestriction(DimensionType.Indicator, physicalIndicators(layer));
    GetSites query = new GetSites();
    query.setFilter(layerFilter);
    query.setFetchAttributes(false);
    query.setFetchAdminEntities(layer.getClustering() instanceof AdministrativeLevelClustering);
    query.setFetchAllIndicators(false);
    query.setFetchIndicators(physicalIndicators(layer));
    return query;
}
Also used : AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator)

Example 2 with AdministrativeLevelClustering

use of org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering in project activityinfo by bedatadriven.

the class MapGeneratorTest method adminMapIcon.

@Test
public void adminMapIcon() {
    AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
    clustering.getAdminLevels().add(1);
    IconMapLayer layer = new IconMapLayer();
    layer.setClustering(clustering);
    layer.getIndicatorIds().add(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());
    IconMapMarker marker = (IconMapMarker) result.getMarkers().get(0);
    assertThat(marker.getSiteIds().size(), equalTo(1));
    assertThat(marker.getSiteIds().get(0), equalTo(3));
    System.out.println(marker.getTitle());
    // assertThat(marker., equalTo(10000d));
    assertThat(result.getUnmappedSites().size(), equalTo(0));
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) IconMapLayer(org.activityinfo.shared.report.model.layers.IconMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) Test(org.junit.Test)

Example 3 with AdministrativeLevelClustering

use of org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering in project activityinfo by bedatadriven.

the class ClusteringOptionsWidget method buildForm.

private void buildForm(Set<CountryDTO> countries) {
    radios = Lists.newArrayList();
    radios.add(new ClusteringRadio(I18N.CONSTANTS.none(), new NoClustering()));
    radios.add(new ClusteringRadio(I18N.CONSTANTS.automatic(), new AutomaticClustering()));
    if (countries.size() == 1) {
        CountryDTO country = countries.iterator().next();
        for (AdminLevelDTO level : country.getAdminLevels()) {
            AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
            clustering.getAdminLevels().add(level.getId());
            radios.add(new ClusteringRadio(level.getName(), clustering));
        }
    }
    radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setStyleAttribute("padding", "5px");
    for (ClusteringRadio radio : radios) {
        radioGroup.add(radio);
        if (radio.getClustering().equals(value)) {
            radioGroup.setValue(radio);
        }
    }
    add(radioGroup);
    radioGroup.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            ClusteringRadio radio = (ClusteringRadio) radioGroup.getValue();
            setValue(radio.getClustering(), true);
        }
    });
    layout();
// unmask();
}
Also used : AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) CountryDTO(org.activityinfo.shared.dto.CountryDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) NoClustering(org.activityinfo.shared.report.model.clustering.NoClustering) AutomaticClustering(org.activityinfo.shared.report.model.clustering.AutomaticClustering)

Example 4 with AdministrativeLevelClustering

use of org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering 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());
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) MapContent(org.activityinfo.shared.report.content.MapContent) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Test(org.junit.Test)

Aggregations

AdministrativeLevelClustering (org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering)4 MapContent (org.activityinfo.shared.report.content.MapContent)2 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)2 Test (org.junit.Test)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 Filter (org.activityinfo.shared.command.Filter)1 GetSites (org.activityinfo.shared.command.GetSites)1 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)1 CountryDTO (org.activityinfo.shared.dto.CountryDTO)1 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)1 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)1 AutomaticClustering (org.activityinfo.shared.report.model.clustering.AutomaticClustering)1 NoClustering (org.activityinfo.shared.report.model.clustering.NoClustering)1 BubbleMapLayer (org.activityinfo.shared.report.model.layers.BubbleMapLayer)1 IconMapLayer (org.activityinfo.shared.report.model.layers.IconMapLayer)1