Re: [Geotools-devel] ClassCastException in imagemosaic-jdbc

2016-07-16 Thread Christian Mueller
Hi Frank

Sorry for the late reply.  If you apply the patch, does it break the build
?.  If not, please make a pull request.

Cheers
Christian

On Tue, Jul 5, 2016 at 3:02 PM, Frank Gevaerts 
wrote:

> Hi,
>
> In geotools 14. (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 frank.gevae...@fks.be
> fks bvba - Formal and Knowledge Systemshttp://www.fks.be/
> Schampbergstraat 32Tel:  ++32-(0)11-21 49 11
> B-3511 KURINGEN-HASSELTFax:  ++32-(0)11-22 04 19
>
>
> --
> 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
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>


-- 
DI Christian Mueller MSc (GIS), MSc (IT-Security)
OSS Open Source Solutions GmbH
--
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
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel


[Geotools-devel] ClassCastException in imagemosaic-jdbc

2016-07-14 Thread Frank Gevaerts
Hi,

In geotools 14. (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 frank.gevae...@fks.be
fks bvba - Formal and Knowledge Systemshttp://www.fks.be/
Schampbergstraat 32Tel:  ++32-(0)11-21 49 11
B-3511 KURINGEN-HASSELTFax:  ++32-(0)11-22 04 19
>From cf98c68fc770e3379e0f7e2d6a06878b4bca8fee Mon Sep 17 00:00:00 2001
From: Frank Gevaerts 
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
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel