Hi all,
I have pushed further the investigation into the ImageMosaic plugin.
Here is a test case I have added to ImageMosaicReaderTest to reproduce the exception with the data sample provided in attachement.
@Test
public void testMosaic_sample() throws Exception {
URL dds = TestData.url(this, “mosaic/mosaic.shp”);
final AbstractGridFormat format = getFormat(dds);
final ImageMosaicReader reader = getReader(dds, format);
final ParameterValue gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue();
// BBOX corresponding to a tile in error => Zone with no data only
// 13.135375,41.470875,13.588,41.9235&WIDTH=256&HEIGHT=256
double x1 = 13.135375;
double y1 = 41.470875;
double x2 = 13.588;
double y2 = 41.9235;
final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double { x1, y1 }, new double { x2, y2 });
cropEnvelope.setCoordinateReferenceSystem(reader.getCrs());
gg.setValue(new GridGeometry2D(PixelInCell.CELL_CENTER, reader.getOriginalGridToWorld(PixelInCell.CELL_CENTER), cropEnvelope, null));
final ParameterValue outTransp = ImageMosaicFormat.OUTPUT_TRANSPARENT_COLOR.createValue();
outTransp.setValue(Color.black);
final GridCoverage2D read = reader.read(new GeneralParameterValue { gg, outTransp });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
What I have found is that in my case, in this function of ImageWorker, the colorModel is a FloatDoubleColorModel and this case is not handled.
public final ImageWorker makeColorTransparent(final Color transparentColor)
throws IllegalStateException
{
if (transparentColor == null) {
throw new IllegalArgumentException(
Errors.format(ErrorKeys.NULL_ARGUMENT_$1, “transparentColor”));
}
final ColorModel cm = image.getColorModel();
if (cm instanceof IndexColorModel) {
return maskIndexColorModel(transparentColor);
} else if (cm instanceof ComponentColorModel) {
switch (image.getSampleModel().getDataType()) {
case DataBuffer.TYPE_BYTE: {
return maskComponentColorModelByte(transparentColor);
}
// Add other types here if we support them…
}
}
throw new IllegalStateException(Errors.format(ErrorKeys.UNSUPPORTED_DATA_TYPE));
}
So I’ve tested a quick and dirty fix in RasterLayerResponse and that solved my problem (but it’s dirty)
private RenderedImage postProcessRaster(RenderedImage image) {
// alpha on the final mosaic
if (finalTransparentColor != null) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine(“Support for alpha on final mosaic”);
final ColorModel cm = image.getColorModel();
if (cm instanceof FloatDoubleColorModel) {
return image;
}
return ImageUtilities.maskColor(finalTransparentColor, image);
}
Don’t hesitate if you need more informations,
Regards,
Damien
De : Despres [mailto:damien.despres@anonymised.com]
Envoyé : lundi 20 février 2012 11:09
À : ‘Andrea Aime’
Cc : geoserver-devel@lists.sourceforge.net
Objet : Re: [Geoserver-devel] ImageMosaic error when no Data in a tile
Hi,
I’ve the same issue if i remove an image without any change in the shape ;-(
Damien
De : Despres [mailto:damien.despres@anonymised.com]
Envoyé : lundi 20 février 2012 10:58
À : ‘Andrea Aime’
Cc : geoserver-devel@lists.sourceforge.net
Objet : Re: [Geoserver-devel] ImageMosaic error when no Data in a tile
Hi,
I have first set the location field to « empty string » in the shapefile but i have also tried with removing the feature and the results are the same.
But you’re right I have not tried to remove images without any changes to the shapefiles. I will try this.
Thanks,
Damien
De : andrea.aime@anonymised.com [mailto:andrea.aime@anonymised.com] De la part de Andrea Aime
Envoyé : lundi 20 février 2012 10:44
À : Despres
Cc : Simone Giannecchini; geoserver-devel@lists.sourceforge.net
Objet : Re: [Geoserver-devel] ImageMosaic error when no Data in a tile
On Mon, Feb 20, 2012 at 10:01 AM, Despres <damien.despres@anonymised.com> wrote:
Hi Simone,
Thanks for your help, I’ve tried with latest 2.1.x nightly build :
· Build Information
- Version 2.1-SNAPSHOT
- Subversion Revision 16772
- Build Date 20-Feb-2012 05:02
- GeoTools Version 2.7-SNAPSHOT (rev 38575)
I think there might be some misunderstanding here, as far as I can see Damien has
removed records from the shapefile, not removed images from disk, right?
Cheers
Andrea
–
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
(attachments)
mosaic.zip (156 KB)