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: Values stored in `DefaultSampleDimension` should be physical values ("data values"), not the compressed values in the file ("cell values").
Date Wed, 07 Jul 2021 13:23:50 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 9690268  Values stored in `DefaultSampleDimension` should be physical values ("data
values"), not the compressed values in the file ("cell values").
9690268 is described below

commit 9690268a0067fc9732c6c5b5df79e9f796c6f142
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jul 7 15:19:02 2021 +0200

    Values stored in `DefaultSampleDimension` should be physical values ("data values"),
    not the compressed values in the file ("cell values").
---
 .../iso/content/DefaultSampleDimension.java        | 21 +++++++++++-
 .../sis/internal/storage/MetadataBuilder.java      | 37 +++++++++++++---------
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
index 9ee9902..e81b0de 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
@@ -45,7 +45,13 @@ import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
  * <div class="preformat">{@code MD_SampleDimension}
  * {@code   └─units………………………} Units of data in each dimension included
in the resource.</div>
  *
- * <p><b>Limitations:</b></p>
+ * <h2>Terminology</h2>
+ * <cite>Data values</cite> should be physical values expressed in the unit of
measurement
+ * given by {@link #getUnits()}. <cite>Cell values</cite> are values stored in
the device,
+ * before conversion to data values by application of {@linkplain #getScaleFactor() scale
+ * factor} and {@linkplain #getOffset() offset}.
+ *
+ * <h2>Limitations</h2>
  * <ul>
  *   <li>Instances of this class are not synchronized for multi-threading.
  *       Synchronization, if needed, is caller's responsibility.</li>
@@ -86,26 +92,31 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Number of values used in a thematic classification resource.
+     * This value should be expressed in the unit of measurement given by {@link #units}.
      */
     private Integer numberOfValues;
 
     /**
      * Minimum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #units}.
      */
     private Double minValue;
 
     /**
      * Maximum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #units}.
      */
     private Double maxValue;
 
     /**
      * Mean value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #units}.
      */
     private Double meanValue;
 
     /**
      * Standard deviation of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #units}.
      */
     private Double standardDeviation;
 
@@ -252,6 +263,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Returns the minimum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @return minimum value of data values in each dimension included in the resource, or
{@code null} if unspecified.
      */
@@ -263,6 +275,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Sets the minimum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @param  newValue  the new new minimum value.
      */
@@ -273,6 +286,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Returns the maximum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @return maximum value of data values in each dimension included in the resource, or
{@code null} if unspecified.
      */
@@ -284,6 +298,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Sets the maximum value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @param  newValue  the new new maximum value.
      */
@@ -294,6 +309,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Returns the mean value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @return the mean value of data values in each dimension included in the resource,
or {@code null} if none.
      */
@@ -306,6 +322,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Sets the mean value of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @param  newValue  the new mean value of data values in each dimension included in
the resource.
      */
@@ -316,6 +333,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Returns the standard deviation of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @return standard deviation of data values in each dimension included in the resource,
or {@code null} if none.
      */
@@ -328,6 +346,7 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements
Sam
 
     /**
      * Sets the standard deviation of data values in each dimension included in the resource.
+     * This value should be expressed in the unit of measurement given by {@link #getUnits()}.
      *
      * @param  newValue  the new standard deviation of data values in each dimension included
in the resource.
      */
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
index ab352c0..51a60d9 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
@@ -2294,9 +2294,10 @@ parse:      for (int i = 0; i < length;) {
                 }
                 setBandIdentifier(name);
             }
-            band.getSampleRange().ifPresent((range) -> {
-                addMinimumSampleValue(range.getMinDouble(true));
-                addMaximumSampleValue(range.getMaxDouble(true));
+            // Really `getMeasurementRange()`, not `getSampleRange()`.
+            band.getMeasurementRange().ifPresent((range) -> {
+                addMinimumSampleValue(range.getMinDouble());
+                addMaximumSampleValue(range.getMaxDouble());
             });
             band.getTransferFunctionFormula().ifPresent((tr) -> {
                 setTransferFunction(tr.getScale(), tr.getOffset());
@@ -2405,16 +2406,18 @@ parse:      for (int i = 0; i < length;) {
     }
 
     /**
-     * Adds a minimal value for the current sample dimension. If a minimal value was already
defined, then
-     * the new value will be set only if it is smaller than the existing one. {@code NaN}
values are ignored.
-     * If a coverage contains more than one band, additional bands can be created by calling
-     * {@link #newSampleDimension()} before to call this method.
+     * Adds a minimal value for the current sample dimension. The value should be in the
unit of measurement
+     * specified by {@link #setSampleUnits(Unit)}. If a minimal value was already defined,
then the new value
+     * will be set only if it is smaller than the existing one. {@code NaN} values are ignored.
      * Storage location is:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/attributeGroup/attribute/minValue}</li>
      * </ul>
      *
+     * If a coverage contains more than one band, additional bands can be created by calling
+     * {@link #newSampleDimension()} before to call this method.
+     *
      * @param value  the minimal value to add to the existing range of sample values, or
{@code NaN} for no-operation.
      */
     public final void addMinimumSampleValue(final double value) {
@@ -2428,16 +2431,18 @@ parse:      for (int i = 0; i < length;) {
     }
 
     /**
-     * Adds a maximal value for the current sample dimension. If a maximal value was already
defined, then
-     * the new value will be set only if it is greater than the existing one. {@code NaN}
values are ignored.
-     * If a coverage contains more than one band, additional bands can be created by calling
-     * {@link #newSampleDimension()} before to call this method.
+     * Adds a maximal value for the current sample dimension. The value should be in the
unit of measurement
+     * specified by {@link #setSampleUnits(Unit)}. If a maximal value was already defined,
then the new value
+     * will be set only if it is greater than the existing one. {@code NaN} values are ignored.
      * Storage location is:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/attributeGroup/attribute/maxValue}</li>
      * </ul>
      *
+     * If a coverage contains more than one band, additional bands can be created by calling
+     * {@link #newSampleDimension()} before to call this method.
+     *
      * @param value  the maximal value to add to the existing range of sample values, or
{@code NaN} for no-operation.
      */
     public final void addMaximumSampleValue(final double value) {
@@ -2452,14 +2457,15 @@ parse:      for (int i = 0; i < length;) {
 
     /**
      * Sets the units of data in the current band.
-     * If a coverage contains more than one band, additional bands can be created by calling
-     * {@link #newSampleDimension()} before to call this method.
      * Storage location is:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/attributeGroup/attribute/unit}</li>
      * </ul>
      *
+     * If a coverage contains more than one band, additional bands can be created by calling
+     * {@link #newSampleDimension()} before to call this method.
+     *
      * @param  unit  units of measurement of sample values.
      */
     public final void setSampleUnits(final Unit<?> unit) {
@@ -2471,8 +2477,6 @@ parse:      for (int i = 0; i < length;) {
     /**
      * Sets the scale factor and offset which have been applied to the cell value.
      * The transfer function type is declared {@linkplain TransferFunctionType#LINEAR linear}
-     * If a coverage contains more than one band, additional bands can be created by calling
-     * {@link #newSampleDimension()} before to call this method.
      * Storage location is:
      *
      * <ul>
@@ -2481,6 +2485,9 @@ parse:      for (int i = 0; i < length;) {
      *   <li>{@code metadata/contentInfo/attributeGroup/attribute/transferFunctionType}</li>
      * </ul>
      *
+     * If a coverage contains more than one band, additional bands can be created by calling
+     * {@link #newSampleDimension()} before to call this method.
+     *
      * @param scale   the scale factor which has been applied to the cell value.
      * @param offset  the physical value corresponding to a cell value of zero.
      */

Mime
View raw message