Hi Simone,

I've been trying to use the 
org.geotools.coverage.processing.operation.Histogram operation against 
the sample geoserver coverages and the only one it works for the DEM. 
Problem being an NPE thrown at

java.lang.ClassCastException: [Ljava.lang.Object;
        at 
org.geotools.coverage.processing.OperationJAI.deriveSampleDimension(OperationJAI.java:781)
        at 
org.geotools.coverage.processing.OperationJAI.deriveGridCoverage(OperationJAI.java:580)
..

This is due to the coverage not defining any geophysics category and 
OperationJAI checking for null category list but not for an empty one.
The following patch seems to solve the problem. Do you think it's 
alright? I might be missing something fundamental, as I only tried what 
seemed obvious.

Index: src/main/java/org/geotools/coverage/processing/OperationJAI.java
===================================================================
--- src/main/java/org/geotools/coverage/processing/OperationJAI.java 
(revision 34115)
+++ src/main/java/org/geotools/coverage/processing/OperationJAI.java 
(working copy)
@@ -774,7 +774,7 @@
                  sampleDim = allBands[allBands.length == 1 ? 0 : numBands];
                  final List<Category> categories = 
sampleDim.getCategories();
                  // GridSampleDimension may contain no categories
-                if (categories == null) {
+                if (categories == null || categories.size() == 0) {
                      result[numBands] = sampleDim;
                      continue;
                  }


Cheers,
Gabriel

-- 
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to