dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25222
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12448: PNG maps, implemented support for user-defined map legend sets
------------------------------------------------------------
revno: 12448
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-10-06 19:25:44 +0200
message:
PNG maps, implemented support for user-defined map legend sets
modified:
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/IntervalSet.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-10-06 17:01:11 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-10-06 17:25:44 +0000
@@ -43,8 +43,6 @@
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.mapgeneration.IntervalSet.DistributionStrategy;
import org.hisp.dhis.mapping.Map;
-import org.hisp.dhis.mapping.MapLegend;
-import org.hisp.dhis.mapping.MapLegendSet;
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -223,6 +221,8 @@
// TODO MapView might be extended to feature stroke width
int strokeWidth = DEFAULT_STROKE_WIDTH;
+
+ boolean hasLegendSet = mapView.hasLegendSet();
// Create and setup an internal layer
InternalMapLayer mapLayer = new InternalMapLayer();
@@ -252,11 +252,19 @@
// Create an interval set for this map layer that distributes its map
// objects into their respective intervals
- // TODO Make interval length a parameter
- IntervalSet.applyIntervalSetToMapLayer( DistributionStrategy.STRATEGY_EQUAL_RANGE, mapLayer, mapLayer.getClasses() );
-
+
+ if ( hasLegendSet )
+ {
+ IntervalSet.getIntervalSet( mapLayer, mapView.getLegendSet() );
+ }
+ else
+ {
+ IntervalSet.applyIntervalSetToMapLayer( DistributionStrategy.STRATEGY_EQUAL_RANGE, mapLayer, mapLayer.getClasses() );
+ }
+
// Update the radius of each map object in this map layer according to
// its map object's highest and lowest values
+
if ( !isIndicator )
{
mapLayer.applyInterpolatedRadii();
@@ -265,20 +273,6 @@
return mapLayer;
}
- private IntervalSet getIntervalSet( MapLegendSet legendSet )
- {
- IntervalSet intervalSet = new IntervalSet();
-
- for ( MapLegend legend : legendSet.getMapLegends() )
- {
- Color color = MapUtils.createColorFromString( legend.getColor() );
-
- Interval interval = new Interval( color, legend.getStartValue(), legend.getEndValue() );
- }
-
- return intervalSet;
- }
-
/**
* Creates a list of aggregated map values.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/IntervalSet.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/IntervalSet.java 2013-10-06 17:01:11 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/IntervalSet.java 2013-10-06 17:25:44 +0000
@@ -32,6 +32,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.hisp.dhis.mapping.MapLegend;
+import org.hisp.dhis.mapping.MapLegendSet;
import org.springframework.util.Assert;
/**
@@ -176,6 +178,26 @@
return intervalSet;
}
+ public static IntervalSet getIntervalSet( InternalMapLayer mapLayer, MapLegendSet legendSet )
+ {
+ IntervalSet intervalSet = new IntervalSet();
+
+ for ( MapLegend legend : legendSet.getMapLegends() )
+ {
+ Color color = MapUtils.createColorFromString( legend.getColor() );
+
+ Interval interval = new Interval( color, legend.getStartValue(), legend.getEndValue() );
+
+ intervalSet.getIntervals().add( interval );
+ }
+
+ distributeAndUpdateMapObjectsForMapLayer( mapLayer, intervalSet );
+
+ mapLayer.setIntervalSet( intervalSet );
+
+ return intervalSet;
+ }
+
/**
* Creates and applies to the given map layer a fixed length interval set
* distributing map objects into intervals that has (optimally) the same