← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14456: PNG maps, better handling of boundary layer

 

------------------------------------------------------------
revno: 14456
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-26 23:18:35 +0100
message:
  PNG maps, better handling of boundary layer
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/InternalMap.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.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	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-03-26 22:18:35 +0000
@@ -147,21 +147,19 @@
             return null;
         }
         
-        boolean dataLayer = map.getMapViews().get( 0 ).isDataLayer();
+        InternalMapLayer dataLayer = internalMap.getFirstDataLayer();
         
         // Build representation of a map using GeoTools, then render as image
         BufferedImage mapImage = MapUtils.render( internalMap, width, height );
 
-        if ( !dataLayer )
+        if ( dataLayer == null )
         {
             return mapImage;
         }
         else
         {
-            // Build the legend set, then render it to an image
-            InternalMapLayer mapLayer = internalMap.getLayers().get( 0 ); //TODO improve
-            
-            LegendSet legendSet = new LegendSet( mapLayer ); //TODO
+            // Build the legend set, then render it to an image            
+            LegendSet legendSet = new LegendSet( dataLayer );
             
             BufferedImage titleImage = MapUtils.renderTitle( map.getName(), width );
             
@@ -258,6 +256,7 @@
         mapLayer.setName( name );
         mapLayer.setPeriod( period );
         mapLayer.setMethod( mapView.getMethod() );
+        mapLayer.setLayer( mapView.getLayer() );
         mapLayer.setRadiusLow( radiusLow );
         mapLayer.setRadiusHigh( radiusHigh );
         mapLayer.setColorLow( colorLow );

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMap.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMap.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMap.java	2014-03-26 22:18:35 +0000
@@ -34,10 +34,39 @@
 public class InternalMap
 {
     private List<InternalMapLayer> layers = new ArrayList<InternalMapLayer>();
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public InternalMap()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    /**
+     * Returns the first data layer of the list of layers for this map. Returns
+     * null of none of the layers are data layers.
+     */
+    public InternalMapLayer getFirstDataLayer()
+    {
+        for ( InternalMapLayer layer : layers )
+        {
+            if ( layer != null && layer.isDataLayer() )
+            {
+                return layer;
+            }
+        }
+        
+        return null;
+    }
     
-    public InternalMap()
-    {
-    }
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
 
     public List<InternalMapLayer> getLayers()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2014-03-26 22:18:35 +0000
@@ -65,6 +65,8 @@
 
     protected Integer method;
 
+    protected String layer;
+    
     protected Integer radiusHigh;
 
     protected Integer radiusLow;
@@ -106,6 +108,15 @@
     }
     
     /**
+     * Indicates whether this layer is a data layer.
+     * @return
+     */
+    public boolean isDataLayer()
+    {
+        return MapView.DATA_LAYERS.contains( layer );
+    }
+        
+    /**
      * Interpolates the radii of this map layer's set of map objects according
      * the highest and lowest values among them.
      */
@@ -432,6 +443,16 @@
         this.method = method;
     }
 
+    public String getLayer()
+    {
+        return layer;
+    }
+
+    public void setLayer( String layer )
+    {
+        this.layer = layer;
+    }
+
     public Integer getRadiusHigh()
     {
         return radiusHigh;