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;
}
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));
}
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();
}
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());
}
Aggregations