From: Eduardo Suarez-S. <e.s...@gm...> - 2017-01-13 12:16:00
|
I think I found it. Let the saved tile be 10x10 pixels from 0 to 10, scale = 1 in both x and y, and let's try to get a tile described by the corners (2.5,2.5) and (12.5,12.5). In this case, x=round((2.5-1)/1)=3 and width=round(10-2.5)=8. But 3+8>10 pixels of our saved tile. Hence the error. So this is my proposed solution: diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java index ff55c89..1181321 100644 --- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java +++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java @@ -135,15 +135,11 @@ public class ImageDecoderThread extends AbstractThread { .getMinimum(0)) / scaleX)); int y = (int) (Math - .round((savedTileEnvelope.getMaximum(1) - tileEnvelope - .getMaximum(1)) + .round((tileEnvelope.getMinimum(1) - savedTileEnvelope + .getMinimum(1)) / scaleY)); - int width = (int) (Math.round(bufferedImage.getWidth() - / savedTileEnvelope.getSpan(0) - * tileEnvelope.getSpan(0))); - int height = (int) (Math.round(bufferedImage.getHeight() - / savedTileEnvelope.getSpan(1) - * tileEnvelope.getSpan(1))); + int width = bufferedImage.getWidth() - x; + int height = bufferedImage.getHeight() - y; if ((width > 0) && (height > 0)) { The computation of 'y' may be kept as already is, or may be changed as proposed. Error has disappeared. On Fri, Jan 13, 2017 at 10:06 AM, Eduardo Suarez-Santana < e.s...@gm...> wrote: > I'm getting this error while trying to seed some layers in geoserver/gwc > via imagemosaicjdbc: > > ene 13 09:06:41 windserver server[805]: Exception in thread > "pool-21-thread-1" > java.awt.image.RasterFormatException: (parentX + width) is outside raster > ene 13 09:06:41 windserver server[805]: at java.awt.image.WritableRaster. > createWritableChild(WritableRaster.java:228) > ene 13 09:06:41 windserver server[805]: at java.awt.image.BufferedImage. > getSubimage(BufferedImage.java:1202) > ene 13 09:06:41 windserver server[805]: at org.geotools.gce.imagemosaic. > jdbc.ImageDecoderThread.run(ImageDecoderThread.java:150) > ene 13 09:06:41 windserver server[805]: at java.util.concurrent. > ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > ene 13 09:06:41 windserver server[805]: at java.util.concurrent. > ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > ene 13 09:06:41 windserver server[805]: at java.lang.Thread.run(Thread. > java:745) > > and looking at the source it doesn't look good to me: > > diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/ > geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java > b/modules/plugin/imagemosaic-jdbc/src/main/java/org/ > geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java > index ff55c89..b45368f 100644 > --- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/ > geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java > +++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/ > geotools/gce/imagemosaic/jdbc/ImageDecoderThread.java > @@ -135,8 +135,8 @@ public class ImageDecoderThread extends AbstractThread > { > .getMinimum(0)) > / scaleX)); > int y = (int) (Math > - .round((savedTileEnvelope.getMaximum(1) - tileEnvelope > - .getMaximum(1)) > + .round((savedTileEnvelope.getMinimum(1) - tileEnvelope > + .getMinimum(1)) > / scaleY)); > int width = (int) (Math.round(bufferedImage.getWidth() > / savedTileEnvelope.getSpan(0) > > Could you please check it out? > |