sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 07/07: Fix the `SAMPLE_RESOLUTIONS_KEY` values to `double[]` in the specification, but keep implementation tolerant to any number type.
Date Tue, 23 Jun 2020 17:57:45 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

commit 4a35aa028588853fd0840b7a00d144b12bc0f6f6
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jun 23 19:55:28 2020 +0200

    Fix the `SAMPLE_RESOLUTIONS_KEY` values to `double[]` in the specification, but keep implementation
tolerant to any number type.
---
 .../src/main/java/org/apache/sis/gui/coverage/CellFormat.java       | 3 +--
 .../sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java | 2 +-
 .../main/java/org/apache/sis/image/PositionalConsistencyImage.java  | 6 +-----
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CellFormat.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CellFormat.java
index c73c58d..462f039 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CellFormat.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CellFormat.java
@@ -269,8 +269,7 @@ final class CellFormat extends SimpleStringProperty {
     private static OptionalInt getFractionDigits(final RenderedImage image, final int band)
{
         final Object property = image.getProperty(PlanarImage.SAMPLE_RESOLUTIONS_KEY);
         if (property != null) {
-            final int c = Numbers.getEnumConstant(property.getClass().getComponentType());
-            if (c >= Numbers.BYTE && c <= Numbers.BIG_DECIMAL && band
< Array.getLength(property)) {
+            if (Numbers.isNumber(property.getClass().getComponentType()) && band
< Array.getLength(property)) {
                 final double resolution = Math.abs(((Number) Array.get(property, band)).doubleValue());
                 if (resolution > 0 && resolution <= Double.MAX_VALUE) {   
 // Non-zero, non-NaN and finite.
                     return OptionalInt.of(DecimalFunctions.fractionDigitsForDelta(resolution,
false));
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java
index 6b41d96..20ed0f5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java
@@ -130,7 +130,7 @@ public abstract class PlanarImage implements RenderedImage {
      * This information can be used for choosing the number of fraction digits to show when
writing sample values
      * in text format.
      *
-     * <p>Values should be instances of {@code float[]} or {@code double[]}.
+     * <p>Values should be instances of {@code double[]}.
      * The array length should be the number of bands. This property may be computed automatically
during
      * {@linkplain org.apache.sis.coverage.grid.GridCoverage#forConvertedValues(boolean)
conversions from
      * integer values to floating point values}.</p>
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/PositionalConsistencyImage.java
b/core/sis-feature/src/main/java/org/apache/sis/image/PositionalConsistencyImage.java
index d45d7bc..24ffd5d 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/PositionalConsistencyImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/PositionalConsistencyImage.java
@@ -106,11 +106,7 @@ final class PositionalConsistencyImage extends ComputedImage {
     @Override
     public Object getProperty(final String key) {
         if (SAMPLE_RESOLUTIONS_KEY.equals(key)) {
-            /*
-             * Division by 8 is an arbitrary value for having one more digit
-             * and keep a number having an exact representation in base 2.
-             */
-            return new float[] {(float) (ResamplingGrid.TOLERANCE / 8)};
+            return new double[] {ResamplingGrid.TOLERANCE / 8};
         } else {
             return super.getProperty(key);
         }


Mime
View raw message