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 fcb23b6f6745361d72b88034ff22f4ea41528253
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Feb 28 10:44:19 2025 +0100

    Safety against resolution of zero during metadata construction.
---
 .../main/org/apache/sis/storage/base/MetadataBuilder.java         | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
index 6d4cefd9cb..f4ed3b4507 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
@@ -2019,7 +2019,7 @@ public class MetadataBuilder {
                 final double distance = 
unit.getConverterToAny(targetUnit).convert(resolution[i]);
                 if (setter == null) {
                     addTemporalResolution(distance);
-                } else if (Double.isFinite(distance)) {
+                } else if (distance > 0 && distance != 
Double.POSITIVE_INFINITY) {
                     var r = new DefaultResolution();
                     setter.accept(r, shared(distance));
                     addIfNotPresent(identification().getSpatialResolutions(), 
r);
@@ -2060,7 +2060,7 @@ public class MetadataBuilder {
      * @param  duration  the resolution in days, or {@code NaN} for 
no-operation.
      */
     public final void addTemporalResolution(final double duration) {
-        if (Double.isFinite(duration)) {
+        if (duration > 0 && duration != Double.POSITIVE_INFINITY) {
             addIfNotPresent(identification().getTemporalResolutions(),
                     Duration.ofNanos(Math.round(duration * 
Constants.NANOSECONDS_PER_DAY)));
         }
@@ -2261,7 +2261,7 @@ public class MetadataBuilder {
 
     /**
      * Sets the degree of detail in the given dimension.
-     * This method does nothing if the given resolution if NaN or infinite.
+     * This method does nothing if the given resolution is NaN or infinite.
      * Storage location is:
      *
      * <ul>
@@ -2273,7 +2273,7 @@ public class MetadataBuilder {
      * @param  unit        the resolution unit, of {@code null} if unknown.
      */
     public final void setAxisResolution(final int dimension, double 
resolution, final Unit<?> unit) {
-        if (Double.isFinite(resolution)) {
+        if (resolution > 0 && resolution != Double.POSITIVE_INFINITY) {
             /*
              * Value should be a Quantity<?>. Since GeoAPI does not yet allow 
that,
              * we convert to metres for now. Future version should store the 
value

Reply via email to