sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/03: Minor cleanup of debugging code.
Date Tue, 16 Apr 2019 12:51:10 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 ccf389e934071da3d273ed56d6ce7581188d6fb2
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Apr 16 14:25:43 2019 +0200

    Minor cleanup of debugging code.
---
 .../operation/transform/InterpolatedTransform.java | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
index a70f625..936e070 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
@@ -416,7 +416,9 @@ public class InterpolatedTransform extends DatumShiftTransform {
         private static final long serialVersionUID = 4335801994727826360L;
 
         /**
-         * Set to {@code true} for debugging.
+         * Whether to enable debugging. If {@code true}, additional but very costly {@code
assert} statements will
+         * be enabled, and some information will be printed to the standard output stream.
Enabling debugging slows
+         * down considerably the transformations; it should be done only for small set of
test data.
          */
         private static final boolean DEBUG = false;
 
@@ -569,19 +571,18 @@ public class InterpolatedTransform extends DatumShiftTransform {
                         final double dx  = (ex * m11 - ey * m01) / det;         // Errors
in source units.
                         final double dy  = (ey * m00 - ex * m10) / det;
                         if (DEBUG) {
-                            Matrix m = forward.grid.derivativeInCell(xi, yi);
-                            assert m.getElement(0,0) == m00;
-                            assert m.getElement(0,1) == m01;
-                            assert m.getElement(1,0) == m10;
-                            assert m.getElement(1,1) == m11;
-
-                            m = Matrices.inverse(m);
-                            double[] c = ((MatrixSIS) m).multiply(new double[] {ex, ey});
-                            assert Math.abs(dx - c[0]) < 1E-5 : Arrays.toString(c) + "
 :  " + dx;
-                            assert Math.abs(dy - c[1]) < 1E-5 : Arrays.toString(c) + "
 :  " + dy;
-
                             System.out.printf("  source=(%9.3f %9.3f) target=(%9.3f %9.3f)
error=(%11.6f %11.6f) → (%11.6f %11.6f)%n",
                                                  xi, yi, (xi+tx), (yi+ty), ex, ey, dx, dy);
+
+                            Matrix m = forward.grid.derivativeInCell(xi, yi);
+                            assert m.getElement(0,0) == m00 &                   // Expect
`m` computed in exact same way.
+                                   m.getElement(0,1) == m01 &
+                                   m.getElement(1,0) == m10 &
+                                   m.getElement(1,1) == m11 : m;
+
+                            final double[] d = Matrices.inverse(m).multiply(new double[]
{ex, ey});
+                            assert Math.abs(dx - d[0]) < tol &
+                                   Math.abs(dy - d[1]) < tol : Arrays.toString(d) + "
versus [" + dx + ", " + dy + "]";
                         }
                         xi -= dx;
                         yi -= dy;


Mime
View raw message