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: Replace the algorithm for default NTv2 accuracy by a hard-coded value for 1 cm on Earth. The rational is that it is very difficult to guess what is the accuracy. Statistics like the average difference between values can give very different values. With hard-coded default value, at least we know what it means.
Date Sun, 14 Oct 2018 22:13:12 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 f0f7cc4  Replace the algorithm for default NTv2 accuracy by a hard-coded value for
1 cm on Earth. The rational is that it is very difficult to guess what is the accuracy. Statistics
like the average difference between values can give very different values. With hard-coded
default value, at least we know what it means.
f0f7cc4 is described below

commit f0f7cc4ff620b9fd66786611fd3e956b5a1b50cf
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sun Oct 14 19:41:00 2018 +0200

    Replace the algorithm for default NTv2 accuracy by a hard-coded value for 1 cm on Earth.
    The rational is that it is very difficult to guess what is the accuracy.
    Statistics like the average difference between values can give very different values.
    With hard-coded default value, at least we know what it means.
---
 .../provider/DatumShiftGridCompressed.java            |  4 ++--
 .../referencing/provider/DatumShiftGridFile.java      |  6 ++++--
 .../sis/internal/referencing/provider/NTv2.java       | 19 ++++---------------
 3 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
index 2fb393a..ee1e644 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
@@ -112,7 +112,7 @@ final class DatumShiftGridCompressed<C extends Quantity<C>, T
extends Quantity<T
                 c -= average;
                 c -= (compressed[i] = (short) Math.round(c));
                 if (!(Math.abs(c) < tolerance)) {                       // Use '!' for
catching NaN values.
-                    return grid;    // Can not compress.
+                    return grid;                                        // Can not compress.
                 }
             }
             data[dim] = compressed;
@@ -196,7 +196,7 @@ final class DatumShiftGridCompressed<C extends Quantity<C>, T
extends Quantity<T
         if (iy < 0) {
             iy = 0;
             gridY = -1;
-        } else if (iy > ymax) {   // Subtraction of 2 already done by the constructor.
+        } else if (iy > ymax) {             // Subtraction of 2 already done by the constructor.
             iy = ymax;
             gridY = +1;
         }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
index cf1439d..0e11997 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
@@ -345,7 +345,9 @@ public abstract class DatumShiftGridFile<C extends Quantity<C>,
T extends Quanti
         private static final long serialVersionUID = -9221609983475286496L;
 
         /**
-         * The translation values.
+         * The translation values. {@code offsets.length} is the number of dimensions, and
{@code offsets[dim].length}
+         * shall be the same for all {@code dim} value. Component {@code dim} of the translation
vector at coordinate
+         * {@code gridX}, {@code gridY} is {@code offsets[dim][gridX + gridY*nx]}.
          */
         final float[][] offsets;
 
@@ -399,7 +401,7 @@ public abstract class DatumShiftGridFile<C extends Quantity<C>,
T extends Quanti
         }
 
         /**
-         * Returns the number of shift dimension.
+         * Returns the number of shift dimensions.
          */
         @Override
         public final int getTranslationDimensions() {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
index baf0c4c..d4a6767 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
@@ -45,6 +45,7 @@ import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.referencing.operation.transform.InterpolatedTransform;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.system.DataDirectory;
+import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.parameter.Parameters;
 import org.apache.sis.util.collection.Cache;
@@ -167,7 +168,7 @@ public final class NTv2 extends AbstractProvider {
      *
      * @author  Simon Reynard (Geomatys)
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.7
+     * @version 1.0
      * @since   0.7
      * @module
      */
@@ -345,22 +346,10 @@ public final class NTv2 extends AbstractProvider {
             /*
              * We need an estimation of translation accuracy, in order to decide when to
stop iterations
              * during inverse transformations. If we did not found that information in the
file, compute
-             * an arbitrary default accuracy derived from the variations found in actual
values.
+             * an arbitrary default accuracy.
              */
             if (Double.isNaN(grid.accuracy)) {
-                double txmin = Double.POSITIVE_INFINITY;
-                double txmax = Double.NEGATIVE_INFINITY;
-                double tymin = Double.POSITIVE_INFINITY;
-                double tymax = Double.NEGATIVE_INFINITY;
-                for (int i=Math.min(tx.length, ty.length); --i >= 0;) {
-                    double x = tx[i];
-                    double y = ty[i];
-                    if (x < txmin) txmin = x;
-                    if (x > txmax) txmax = x;
-                    if (y < tymin) tymin = y;
-                    if (y > tymax) tymax = y;
-                }
-                grid.accuracy = Math.min(txmax - txmin, tymax - tymin) / 1000;
+                grid.accuracy = Units.DEGREE.getConverterTo(unit).convert(Formulas.ANGULAR_TOLERANCE);
             }
             header.keySet().retainAll(Arrays.asList(overviewKeys));   // Keep only overview
records.
             return DatumShiftGridCompressed.compress(grid, null, precision / Math.max(dx,
dy));


Mime
View raw message