[Schmitzm-commits] r395 - in branches/1.0-gt2-2.6: dist src/skrueger

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 14 13:37:59 CEST 2009


Author: mojays
Date: 2009-09-14 13:37:53 +0200 (Mon, 14 Sep 2009)
New Revision: 395

Modified:
   branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6-src.zip
   branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6.jar
   branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java
Log:
new method in RasterLegendData to create sample GridCoverage2D for each legend entry

Modified: branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6-src.zip
===================================================================
(Binary files differ)

Modified: branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6.jar
===================================================================
(Binary files differ)

Modified: branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java	2009-09-14 11:36:28 UTC (rev 394)
+++ branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java	2009-09-14 11:37:53 UTC (rev 395)
@@ -32,9 +32,15 @@
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
+import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.geometry.Envelope2D;
+import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
 
+import schmitzm.geotools.GTUtil;
+import schmitzm.geotools.grid.GridUtil;
 import skrueger.i8n.Translation;
 
 /**
@@ -81,4 +87,25 @@
 		return linkedList;
 
 	}
+
+    /**
+     * Creates a sample {@link GridCoverage2D} (size 1x1, WGS84) for each
+     * legend value.  These rasters can be used to do visualize the
+     * legend item in the corresponding color via {@link GridCoverageRenderer}.
+     */
+    public Map<Double, GridCoverage2D> createSampleRasters() {
+      Map<Double, GridCoverage2D> sampleRaster = new HashMap<Double, GridCoverage2D>();
+      
+      for (Double rasterValue : keySet()) {
+        GridCoverage2D grid = GridUtil.GRID_FAC.create(
+            "Legend_"+rasterValue,
+            new float[][] { { rasterValue.floatValue() } },
+            new Envelope2D(GTUtil.WGS84, 0,0,1,1)
+        );
+        sampleRaster.put(rasterValue, grid);
+      }
+      
+      
+      return sampleRaster;
+    }
 }



More information about the Schmitzm-commits mailing list