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: Use NaN for "no source median" to distinguish from 0.
Date Tue, 29 Sep 2020 17:36:28 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 bc38cbf  Use NaN for "no source median" to distinguish from 0.
bc38cbf is described below

commit bc38cbf7e288c2e453a9b0833efc5eb664870a51
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Sep 29 19:34:11 2020 +0200

    Use NaN for "no source median" to distinguish from 0.
---
 .../org/apache/sis/internal/referencing/WraparoundTransform.java | 9 ++++-----
 .../org/apache/sis/internal/referencing/provider/Wraparound.java | 2 +-
 .../apache/sis/internal/referencing/WraparoundTransformTest.java | 9 +++++----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
index b58dedd..ca4a0c1 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
@@ -106,7 +106,7 @@ public class WraparoundTransform extends AbstractMathTransform implements
Serial
      * @param  dimension            number of dimensions of the transform to create.
      * @param  wraparoundDimension  dimension where wraparound happens.
      * @param  period               period on wraparound axis.
-     * @param  sourceMedian         coordinate in the center of source envelope, or 0 if
none.
+     * @param  sourceMedian         coordinate in the center of source envelope, or {@link
Double#NaN} if none.
      * @return the wraparound transform (may be a cached instance).
      */
     public static WraparoundTransform create(final int dimension, final int wraparoundDimension,
@@ -115,8 +115,7 @@ public class WraparoundTransform extends AbstractMathTransform implements
Serial
         ArgumentChecks.ensureStrictlyPositive("dimension", dimension);
         ArgumentChecks.ensureBetween("wraparoundDimension", 0, dimension - 1, wraparoundDimension);
         ArgumentChecks.ensureStrictlyPositive("period", period);
-        if (sourceMedian != 0) {
-            ArgumentChecks.ensureFinite("sourceMedian", sourceMedian);
+        if (Double.isFinite(sourceMedian)) {
             return new WraparoundInEnvelope(dimension, wraparoundDimension, period, sourceMedian);
         }
         if (period == (Longitude.MAX_VALUE - Longitude.MIN_VALUE) && (wraparoundDimension
& ~1) == 0) {
@@ -168,7 +167,7 @@ public class WraparoundTransform extends AbstractMathTransform implements
Serial
      * {@link #wraparoundDimension} and {@link #period} unchanged.
      */
     WraparoundTransform redim(final int n) {
-        return create(n, wraparoundDimension, period, 0);
+        return create(n, wraparoundDimension, period, Double.NaN);
     }
 
     /**
@@ -287,7 +286,7 @@ public class WraparoundTransform extends AbstractMathTransform implements
Serial
             // Invalid median value. Assume caller means "no wrap".
             return tr;
         }
-        final double sm = (sourceMedian != null) ? sourceMedian.getOrdinate(wraparoundDimension)
- m : 0;
+        final double sm = (sourceMedian != null) ? sourceMedian.getOrdinate(wraparoundDimension)
- m : Double.NaN;
         final int dimension = tr.getTargetDimensions();
         MathTransform wraparound = create(dimension, wraparoundDimension, period, sm);
         if (m != 0) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
index 34c95fc..6251947 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
@@ -115,6 +115,6 @@ public final class Wraparound extends AbstractProvider {
         return WraparoundTransform.create(
                 pg.intValue(DIMENSION),
                 pg.intValue(WRAPAROUND_DIMENSION),
-                pg.doubleValue(PERIOD), 0);
+                pg.doubleValue(PERIOD), Double.NaN);
     }
 }
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
index 59fb0e2..2ed1986 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
@@ -30,6 +30,7 @@ import org.apache.sis.referencing.operation.matrix.Matrix4;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
+import static java.lang.Double.NaN;
 import static org.opengis.test.Assert.*;
 
 
@@ -49,10 +50,10 @@ public final strictfp class WraparoundTransformTest extends TestCase {
     public void testCache() {
         final double period = 360;
         final WraparoundTransform t1, t2, t3, t4;
-        assertSame   (WraparoundTransform.create(3, 0, period, 0), t1 = WraparoundTransform.create(3,
0, period, 0));
-        assertNotSame(WraparoundTransform.create(3, 0, period, 0), t2 = WraparoundTransform.create(3,
1, period, 0));
-        assertNotSame(WraparoundTransform.create(3, 0, period, 0), t3 = WraparoundTransform.create(2,
0, period, 0));
-        assertNotSame(WraparoundTransform.create(3, 0, period, 0), t4 = WraparoundTransform.create(3,
2, period, 0));
+        assertSame   (WraparoundTransform.create(3, 0, period, NaN), t1 = WraparoundTransform.create(3,
0, period, NaN));
+        assertNotSame(WraparoundTransform.create(3, 0, period, NaN), t2 = WraparoundTransform.create(3,
1, period, NaN));
+        assertNotSame(WraparoundTransform.create(3, 0, period, NaN), t3 = WraparoundTransform.create(2,
0, period, NaN));
+        assertNotSame(WraparoundTransform.create(3, 0, period, NaN), t4 = WraparoundTransform.create(3,
2, period, NaN));
         assertEquals(3, t1.getSourceDimensions());
         assertEquals(3, t2.getSourceDimensions());
         assertEquals(2, t3.getSourceDimensions());


Mime
View raw message