You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/07/07 11:12:11 UTC
[sis] branch geoapi-4.0 updated: Fix an `IllegalArgumentException`
when creating a coverage with bands using incompatible units.
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 ac5e8e0 Fix an `IllegalArgumentException` when creating a coverage with bands using incompatible units.
ac5e8e0 is described below
commit ac5e8e0fb80e6781e329bf4e6603181904d084d7
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Jul 7 13:10:53 2021 +0200
Fix an `IllegalArgumentException` when creating a coverage with bands using incompatible units.
---
.../java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java | 9 +++++++++
1 file changed, 9 insertions(+)
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 fc58d79..1bfad3b 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
@@ -28,6 +28,7 @@ import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.apache.sis.referencing.operation.transform.MathTransforms;
import org.apache.sis.coverage.SampleDimension;
+import org.apache.sis.measure.MeasurementRange;
import org.apache.sis.measure.NumberRange;
import org.apache.sis.image.DataType;
@@ -172,6 +173,14 @@ final class ConvertedGridCoverage extends GridCoverage {
if (union == null) {
union = range;
} else {
+ /*
+ * We do not want unit conversions for this union, because the union is used
+ * only for determining a data type having the capacity to store the values.
+ * The physical meaning of those values is not relevant here.
+ */
+ if (union instanceof MeasurementRange<?>) {
+ union = new NumberRange<>(union);
+ }
union = union.unionAny(range);
}
}