sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Fix an IndexOfBoundsException when the "visible band" is -1 (sentinel value for information not available).
Date Mon, 06 Apr 2020 23:31:39 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 5c85521  Fix an IndexOfBoundsException when the "visible band" is -1 (sentinel value
for information not available).
5c85521 is described below

commit 5c85521a624e3b7e707a21ef79add9efd126a946
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Apr 7 01:29:35 2020 +0200

    Fix an IndexOfBoundsException when the "visible band" is -1 (sentinel value for information
not available).
---
 .../main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java   | 2 +-
 .../src/main/java/org/apache/sis/coverage/grid/GridCoverage2D.java      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
index 6ce1f11..22d50a5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
@@ -212,7 +212,7 @@ final class ConvertedGridCoverage extends GridCoverage {
          * That image should never be null. But if an implementation wants to do so, respect
that.
          */
         if (image != null) {
-            final ColorModel colorModel = createColorModel(ImageUtilities.getVisibleBand(image),
dataType);
+            final ColorModel colorModel = createColorModel(Math.max(0, ImageUtilities.getVisibleBand(image)),
dataType);
             image = BandedSampleConverter.create(image, null, dataType, colorModel, getRanges(),
converters);
         }
         return image;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage2D.java
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage2D.java
index 154d751..791bb72 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage2D.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage2D.java
@@ -147,7 +147,7 @@ public class GridCoverage2D extends GridCoverage {
     {
         super(source.gridGeometry, range);
         final int dataType = ConvertedGridCoverage.getDataType(range, isConverted);
-        final ColorModel colorModel = createColorModel(ImageUtilities.getVisibleBand(source.data),
dataType);
+        final ColorModel colorModel = createColorModel(Math.max(0, ImageUtilities.getVisibleBand(source.data)),
dataType);
         data           = BandedSampleConverter.create(source.data, null, dataType, colorModel,
getRanges(), converters);
         gridToImageX   = source.gridToImageX;
         gridToImageY   = source.gridToImageY;


Mime
View raw message