geosolutions-it / jai-ext

Java Advanced Imaging Open Source Replacement Wannabe
Apache License 2.0
89 stars 38 forks source link

Mosaicking different images, some having nodata and some not, may throw a NPE #265

Closed dromagnoli closed 4 years ago

dromagnoli commented 4 years ago

Mosaicking different granules, some having nodata defined and some not, may throw a NPE when computing a tile not intersecting all the sources.

These are the findings based on an example made of 3 granules where: source0 and source1 has nodata defined whilst source2 doesn't. source1 is displaced in such a way that it will no contribute to tile 0,0.

The boolean hasNodata Flags get therefore initialized like this: hasNodata[0] = true hasNodata[1] = true hasNodata[2] = false

When computing the first Tile [x=0,y=0], sources[1] will get skipped so only sources[0] and sources[2] will contribute to the result and get used. Using initialized hasNodata array with old numbering results into inconsistent information trying to access the nodataRange of the second image which was actually not available, resulting into a NPE.