Hi,
In geotools 14.<latest> (built from the 14.x branch) Im'm seeing the following
exception when using PGRaster:
Exception in thread "Thread-35" java.lang.ClassCastException:
java.awt.image.Raster cannot be cast to java.awt.image.WritableRaster
at
org.geotools.gce.imagemosaic.jdbc.AbstractThread.rescaleImageViaPlanarImage(AbstractThread.java:108)
at
org.geotools.gce.imagemosaic.jdbc.ImageComposerThread.run(ImageComposerThread.java:170)
I don't know if it still happens in later versions, but I don't think the
relevant code has changed much. The attached patch makes the problem go away,
but as I don't fully understand the problem I'm not sure if it's the right fix.
Frank
--
Frank Gevaerts [email protected]
fks bvba - Formal and Knowledge Systems http://www.fks.be/
Schampbergstraat 32 Tel: ++32-(0)11-21 49 11
B-3511 KURINGEN-HASSELT Fax: ++32-(0)11-22 04 19
>From cf98c68fc770e3379e0f7e2d6a06878b4bca8fee Mon Sep 17 00:00:00 2001
From: Frank Gevaerts <[email protected]>
Date: Mon, 4 Jul 2016 14:08:48 +0200
Subject: [PATCH] Ensure that we get a WritableRaster from the rescaler.
RenderedOp.getData() doesn't always return a WritableRaster, so call
copyData() instead. This may waste some memory, but that's better than
a ClassCastException.
---
.../src/main/java/org/geotools/gce/imagemosaic/jdbc/AbstractThread.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/AbstractThread.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/AbstractThread.java
index 6f1e7ad..66aae77 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/AbstractThread.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/AbstractThread.java
@@ -105,7 +105,7 @@ abstract class AbstractThread extends Thread {
0.0f,
Interpolation.getInstance(interpolation));
RenderedOp result = w.getRenderedOperation();
- WritableRaster scaledImageRaster = (WritableRaster) result.getData();
+ WritableRaster scaledImageRaster = result.copyData();
ColorModel colorModel = image.getColorModel();
--
2.8.1
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel