[Schmitzm-commits] r1510 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/grid

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 14 17:00:36 CET 2011


Author: alfonx
Date: 2011-03-14 17:00:35 +0100 (Mon, 14 Mar 2011)
New Revision: 1510

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/grid/GridUtil.java
Log:
Added a comment about how to improve histogram performance

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/grid/GridUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/grid/GridUtil.java	2011-03-14 14:43:12 UTC (rev 1509)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/grid/GridUtil.java	2011-03-14 16:00:35 UTC (rev 1510)
@@ -51,7 +51,6 @@
 import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
-import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.geometry.Envelope2D;
 import org.geotools.styling.ColorMap;
 import org.geotools.styling.RasterSymbolizer;
@@ -141,7 +140,34 @@
 	 *            Runden). Nur relevant, wenn {@code hishistogramSteps} = -1
 	 * @author Martin Schmitz
 	 * @author Andreas Enders
+	 * 
+	 * @deprecated Stefan says: use <code> 
+	  		GridCoverage2D coverage = reader.read(null);
+			final OperationJAI op = new OperationJAI("Histogram");
+			ParameterValueGroup params = op.getParameters();
+			params.parameter("Source").setValue(coverage);
+
+			coverage = (GridCoverage2D) op.doOperation(params, null);
+			final Histogram hist = (Histogram) coverage
+					.getProperty("histogram");
+
+			final int[][] bins = hist.getBins();
+			double low = hist.getLowValue(0);
+			double high = hist.getHighValue(0);
+
+			int countBins = -1;
+			for (double d = low; d < high; d += 1.) {
+				countBins++;
+				if (hist.getBins()[0][countBins] == 0)
+					continue;
+
+				if (!getValues().contains(d))
+					uniques.add(d);
+			}
+</code> if you really want a histogram. It
+	 *             is about 50x faster!
 	 */
+	@Deprecated
 	public static GridStatistic determineStatistic(GridCoverage2D gc, int band,
 			int histogramSteps, Integer histogrammDigits) {
 		GridStatistic gs = new GridStatistic();
@@ -374,10 +400,11 @@
 	public static Style createDefaultStyle() {
 		Style defaultStyle = createStyle(null, 1.0);
 		defaultStyle.setName(DEFAULT_RASTER_STYLE_NAME);
-		
-//		defaultStyle.setTitle(DEFAULT_RASTER_STYLE_TITLE);
-		defaultStyle.getDescription().setTitle( new SimpleInternationalString( DEFAULT_RASTER_STYLE_TITLE) );
 
+		// defaultStyle.setTitle(DEFAULT_RASTER_STYLE_TITLE);
+		defaultStyle.getDescription().setTitle(
+				new SimpleInternationalString(DEFAULT_RASTER_STYLE_TITLE));
+
 		defaultStyle.featureTypeStyles().get(0).semanticTypeIdentifiers()
 				.add(SemanticType.RASTER);
 
@@ -549,12 +576,12 @@
 		// properties.put("GC_NODATA", -9999.0);
 
 		return CoverageFactoryFinder.getGridCoverageFactory(null).create(
-				gc.getName(), gc.getRenderedImage(),
-				(GridGeometry2D) gc.getGridGeometry(), sampleDim, null, // new
-																		// GridCoverage[]
-																		// {
-																		// raster
-																		// },
+				gc.getName(), gc.getRenderedImage(), gc.getGridGeometry(),
+				sampleDim, null, // new
+									// GridCoverage[]
+									// {
+									// raster
+									// },
 				properties);
 	}
 



More information about the Schmitzm-commits mailing list