sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1533644 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-referencing/src/test/java/org/apache/sis/referencing/datum/ sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix...
Date Fri, 18 Oct 2013 21:52:52 GMT
Author: desruisseaux
Date: Fri Oct 18 21:52:52 2013
New Revision: 1533644

URL: http://svn.apache.org/r1533644
Log:
Added some tests for BursaWolfParameters class.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -268,7 +268,7 @@ public class BursaWolfParameters extends
      * @param  targetDatum The target datum (usually WGS 84) for this set of parameters,
or {@code null} if unspecified.
      * @throws IllegalArgumentException if the specified matrix does not meet the conditions.
      *
-     * @see #getPositionVectorTransformation()
+     * @see #getPositionVectorTransformation(boolean)
      */
     public BursaWolfParameters(final Matrix matrix, final double tolerance, final GeodeticDatum
targetDatum)
             throws IllegalArgumentException
@@ -317,12 +317,13 @@ public class BursaWolfParameters extends
 
     /**
      * Returns {@code true} if the {@linkplain #targetDatum target datum} is equals (at least
on computation purpose)
-     * to the WGS84 datum. This method may conservatively returns {@code false} if the specified
datum is uncertain.
+     * to the WGS84 datum. If the datum is unspecified, then this method returns {@code true}
since WGS84 is the only
+     * datum supported by the WKT 1 format, and is what users often mean.
      *
      * @return {@code true} if the given datum is equal to WGS84 for computational purpose.
      */
     final boolean isToWGS84() {
-        return (targetDatum != null) &&
+        return (targetDatum == null) ||
                 (IdentifiedObjects.nameMatches(targetDatum, "WGS 84") ||
                  IdentifiedObjects.nameMatches(targetDatum, "WGS84"));
     }
@@ -364,19 +365,21 @@ public class BursaWolfParameters extends
      * This affine transform can be applied on <strong>geocentric</strong> coordinates.
      * This is identified as operation method 1033 in the EPSG database.
      *
+     * @param  inverse If {@code true}, returns the inverse transformation instead.
      * @return An affine transform in geocentric space created from this Bursa-Wolf parameters.
      *
      * @see DefaultGeodeticDatum#getPositionVectorTransformation(GeodeticDatum)
      */
     @EPSG(type = OperationMethod.class, code = 1033)
-    public Matrix getPositionVectorTransformation() {
-        final double  S = 1 + dS / PPM;
-        final double RS = TO_RADIANS * S;
+    public Matrix getPositionVectorTransformation(final boolean inverse) {
+        final double sgn = inverse ? -1 : +1;
+        final double   S = 1 + sgn*dS / PPM;
+        final double  RS = sgn*TO_RADIANS * S;
         return new Matrix4(
-                 S,  -rZ*RS,  +rY*RS,  tX,
-            +rZ*RS,       S,  -rX*RS,  tY,
-            -rY*RS,  +rX*RS,       S,  tZ,
-                 0,       0,       0,   1);
+                 S,  -rZ*RS,  +rY*RS,  sgn*tX,
+            +rZ*RS,       S,  -rX*RS,  sgn*tY,
+            -rY*RS,  +rX*RS,       S,  sgn*tZ,
+                 0,       0,       0,      1);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -30,9 +30,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.OperationMethod;
 import org.apache.sis.referencing.EPSG;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
 import org.apache.sis.internal.util.CollectionsExt;
-import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Immutable;
 import org.apache.sis.io.wkt.Formatter;
@@ -260,21 +258,12 @@ public class DefaultGeodeticDatum extend
      * @param  targetDatum The target datum.
      * @return An affine transform from {@code this} to {@code target} in geocentric space,
or {@code null} if none.
      *
-     * @see BursaWolfParameters#getPositionVectorTransformation()
+     * @see BursaWolfParameters#getPositionVectorTransformation(boolean)
      */
     @EPSG(type = OperationMethod.class, code = 1033)
     public Matrix getPositionVectorTransformation(final GeodeticDatum targetDatum) {
         ensureNonNull("targetDatum", targetDatum);
-        try {
-            return getPositionVectorTransformation(this, targetDatum, null);
-        } catch (NoninvertibleMatrixException e) {
-            /*
-             * Should never happen, unless the user has overriden BursaWolfParameters.getPositionVectorTransformation()
-             * and create an invalid matrix. Returning 'null' is compliant with this method
contract.
-             */
-            Logging.unexpectedException(DefaultGeodeticDatum.class, "getPositionVectorTransformation",
e);
-            return null;
-        }
+        return getPositionVectorTransformation(this, targetDatum, null);
     }
 
     /**
@@ -288,13 +277,13 @@ public class DefaultGeodeticDatum extend
      * @return An affine transform from {@code source} to {@code target}, or {@code null}
if none.
      */
     private static Matrix getPositionVectorTransformation(final GeodeticDatum source, final
GeodeticDatum target,
-            Set<GeodeticDatum> exclusion) throws NoninvertibleMatrixException
+            Set<GeodeticDatum> exclusion)
     {
         final BursaWolfParameters[] sourceParam = bursaWolf(source);
         if (sourceParam != null) {
             for (final BursaWolfParameters candidate : sourceParam) {
                 if (deepEquals(target, candidate.targetDatum, ComparisonMode.IGNORE_METADATA))
{
-                    return candidate.getPositionVectorTransformation();
+                    return candidate.getPositionVectorTransformation(false);
                 }
             }
         }
@@ -306,7 +295,7 @@ public class DefaultGeodeticDatum extend
         if (targetParam != null) {
             for (final BursaWolfParameters candidate : targetParam) {
                 if (deepEquals(source, candidate.targetDatum, ComparisonMode.IGNORE_METADATA))
{
-                    return MatrixSIS.castOrCopy(candidate.getPositionVectorTransformation()).inverse();
+                    return candidate.getPositionVectorTransformation(true);
                 }
             }
         }

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1533644&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.datum;
+
+import org.opengis.referencing.operation.OperationMethod;
+import org.opengis.referencing.operation.Transformation;
+import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.EPSG;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests {@link BursaWolfParameters}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-2.2)
+ * @version 0.4
+ * @module
+ */
+public final strictfp class BursaWolfParametersTest extends TestCase {
+    /**
+     * Tests {@link BursaWolfParameters#getPositionVectorTransformation(boolean)}.
+     * This test transform a point from WGS72 to WGS84, and conversely,
+     * as documented in the example section of EPSG operation method 9606.
+     */
+    @Test
+    @EPSG(type = OperationMethod.class, code = 9606)
+    public void testGetPositionVectorTransformation() {
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(0, 0, 4.5, 0, 0, 0.554,
0.219, null);
+        final MatrixSIS toWGS84 = MatrixSIS.castOrCopy(bursaWolf.getPositionVectorTransformation(false));
+        final MatrixSIS toWGS72 = MatrixSIS.castOrCopy(bursaWolf.getPositionVectorTransformation(true));
+        final MatrixSIS source  = Matrices.create(4, 1, new double[] {3657660.66, 255768.55,
5201382.11, 1});
+        final MatrixSIS target  = Matrices.create(4, 1, new double[] {3657660.78, 255778.43,
5201387.75, 1});
+        assertMatrixEquals("toWGS84", target, toWGS84.multiply(source), 0.01);
+        assertMatrixEquals("toWGS72", source, toWGS72.multiply(target), 0.01);
+    }
+
+    /**
+     * Tests serialization of <cite>ED87 to WGS 84</cite> parameters (EPSG:1146).
+     */
+    @Test
+    @EPSG(type = Transformation.class, code = 1146)
+    public void testToString() {
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(
+                -82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143, null);
+        assertEquals("TOWGS84[-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143]",
bursaWolf.toString());
+    }
+
+    /**
+     * Tests {@link BursaWolfParameters} serialization.
+     */
+    @Test
+    public void testSerialization() {
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(
+                -82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143, null);
+        assertSerializedEquals(bursaWolf);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -98,6 +98,6 @@ public final strictfp class Matrix3Test 
                 0,  0,  1}, expected, TOLERANCE);
 
         // Now the actual test.
-        assertMatrixEquals(expected, SIZE, SIZE, A.solve(B), TOLERANCE);
+        assertEqualsElements(expected, SIZE, SIZE, A.solve(B), TOLERANCE);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -160,7 +160,7 @@ public abstract strictfp class MatrixTes
      * @param actual    The SIS matrix to compare to JAMA.
      * @param tolerance The tolerance threshold, usually either {@link #STRICT} or {@link
#TOLERANCE}.
      */
-    static void assertMatrixEquals(final Matrix expected, final MatrixSIS actual, final double
tolerance) {
+    static void assertEqualsJAMA(final Matrix expected, final MatrixSIS actual, final double
tolerance) {
         final int numRow = actual.getNumRow();
         final int numCol = actual.getNumCol();
         assertEquals("numRow", expected.getRowDimension(),    numRow);
@@ -184,7 +184,7 @@ public abstract strictfp class MatrixTes
      * Asserts that the given matrix is equals to the given expected values, up to the given
tolerance threshold.
      * This method compares the elements values in two slightly redundant ways.
      */
-    static void assertMatrixEquals(final double[] expected, final int numRow, final int numCol,
+    static void assertEqualsElements(final double[] expected, final int numRow, final int
numCol,
             final MatrixSIS actual, final double tolerance)
     {
         assertEquals("numRow", numRow, actual.getNumRow());
@@ -227,7 +227,7 @@ public abstract strictfp class MatrixTes
          * The JAMA constructor uses column-major array (FORTRAN convention), while SIS uses
          * row-major array. So we have to transpose the JAMA matrix after construction.
          */
-        assertMatrixEquals(new Matrix(elements, numCol).transpose(), matrix, STRICT);
+        assertEqualsJAMA(new Matrix(elements, numCol).transpose(), matrix, STRICT);
         assertArrayEquals("getElements", elements, matrix.getElements(), STRICT);
     }
 
@@ -249,14 +249,14 @@ public abstract strictfp class MatrixTes
         /*
          * End of initialization - now perform the actual test.
          */
-        assertMatrixEquals(reference, matrix, STRICT);
+        assertEqualsJAMA(reference, matrix, STRICT);
         for (int k=0; k<50; k++) {
             final int    j = random.nextInt(numRow);
             final int    i = random.nextInt(numCol);
             final double e = random.nextDouble() * 100;
             reference.set(j, i, e);
             matrix.setElement(j, i, e);
-            assertMatrixEquals(reference, matrix, STRICT);
+            assertEqualsJAMA(reference, matrix, STRICT);
         }
     }
 
@@ -343,7 +343,7 @@ public abstract strictfp class MatrixTes
          * array. In other words, the JAMA matrix is already transposed from the SIS point
of view.
          */
         matrix.transpose();
-        assertMatrixEquals(new Matrix(elements, numCol), matrix, STRICT);
+        assertEqualsJAMA(new Matrix(elements, numCol), matrix, STRICT);
     }
 
     /**
@@ -402,7 +402,7 @@ public abstract strictfp class MatrixTes
              */
             final Matrix referenceResult = reference.times(referenceArg);
             final MatrixSIS matrixResult = matrix.multiply(matrixArg);
-            assertMatrixEquals(referenceResult, matrixResult, TOLERANCE);
+            assertEqualsJAMA(referenceResult, matrixResult, TOLERANCE);
         }
     }
 
@@ -442,7 +442,7 @@ public abstract strictfp class MatrixTes
              */
             final Matrix referenceResult = reference.solve(referenceArg);
             final MatrixSIS matrixResult = matrix.solve(matrixArg);
-            assertMatrixEquals(referenceResult, matrixResult, SolverTest.TOLERANCE);
+            assertEqualsJAMA(referenceResult, matrixResult, SolverTest.TOLERANCE);
         }
     }
 
@@ -466,7 +466,7 @@ public abstract strictfp class MatrixTes
                 continue; // To close to a singular matrix - search an other one.
             }
             final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
-            assertMatrixEquals(reference.inverse(), matrix.inverse(), TOLERANCE);
+            assertEqualsJAMA(reference.inverse(), matrix.inverse(), TOLERANCE);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -124,7 +124,7 @@ public final strictfp class NonSquareMat
             0,       0,            1
         };
         final MatrixSIS inverse = (Y != null) ? matrix.solve(Y) : matrix.inverse();
-        assertMatrixEquals(expected, 5, 3, inverse, TOLERANCE);
+        assertEqualsElements(expected, 5, 3, inverse, TOLERANCE);
     }
 
     /**
@@ -151,7 +151,7 @@ public final strictfp class NonSquareMat
             0,       0,  0,        0,   1
         };
         final MatrixSIS inverse = (Y != null) ? matrix.solve(Y) : matrix.inverse();
-        assertMatrixEquals(expected, 3, 5, inverse, TOLERANCE);
+        assertEqualsElements(expected, 3, 5, inverse, TOLERANCE);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/SolverTest.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -25,7 +25,8 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static java.lang.Double.NaN;
-import static org.apache.sis.referencing.operation.matrix.MatrixTestCase.assertMatrixEquals;
+import static org.apache.sis.referencing.operation.matrix.MatrixTestCase.assertEqualsJAMA;
+import static org.apache.sis.referencing.operation.matrix.MatrixTestCase.assertEqualsElements;
 
 
 /**
@@ -114,7 +115,7 @@ public final strictfp class SolverTest e
                 continue;
             }
             final MatrixSIS U = Solver.solve(matrix, matrixArg);
-            assertMatrixEquals(jama, U, TOLERANCE);
+            assertEqualsJAMA(jama, U, TOLERANCE);
         }
     }
 
@@ -144,7 +145,7 @@ public final strictfp class SolverTest e
             0,     0,  0,      0,    1
         };
         MatrixSIS inverse = Solver.inverse(matrix, false);
-        assertMatrixEquals(expected, 5, 5, inverse, TOLERANCE);
+        assertEqualsElements(expected, 5, 5, inverse, TOLERANCE);
         /*
          * Set a scale factor to NaN. The translation term for the corresponding
          * dimension become unknown, so it most become NaN in the inverse matrix.
@@ -164,7 +165,7 @@ public final strictfp class SolverTest e
             0,     0,  0,      0,    1
         };
         inverse = Solver.inverse(matrix, false);
-        assertMatrixEquals(expected, 5, 5, inverse, TOLERANCE);
+        assertEqualsElements(expected, 5, 5, inverse, TOLERANCE);
         /*
          * Set a scale factor to NaN with translation equals to 0.
          * The zero value should be preserved, since 0 × any == 0
@@ -185,7 +186,7 @@ public final strictfp class SolverTest e
             0,     0,  0,      0,    1
         };
         inverse = Solver.inverse(matrix, false);
-        assertMatrixEquals(expected, 5, 5, inverse, TOLERANCE);
+        assertEqualsElements(expected, 5, 5, inverse, TOLERANCE);
         /*
          * Set a translation term to NaN. The translation should be NaN in
          * the inverse matrix too, but the scale factor can still be compute.
@@ -205,6 +206,6 @@ public final strictfp class SolverTest e
             0,     0,  0,      0,    1
         };
         inverse = Solver.inverse(matrix, false);
-        assertMatrixEquals(expected, 5, 5, inverse, TOLERANCE);
+        assertEqualsElements(expected, 5, 5, inverse, TOLERANCE);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Oct 18 21:52:52 2013
@@ -47,6 +47,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.NamedIdentifierTest.class,
     org.apache.sis.referencing.AbstractIdentifiedObjectTest.class,
     org.apache.sis.referencing.AbstractReferenceSystemTest.class,
+    org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
 
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1533644&r1=1533643&r2=1533644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
Fri Oct 18 21:52:52 2013
@@ -29,6 +29,7 @@ import java.io.ByteArrayOutputStream;
 import javax.swing.tree.TreeNode;
 import javax.xml.parsers.ParserConfigurationException;
 import org.xml.sax.SAXException;
+import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
@@ -53,6 +54,33 @@ public strictfp class Assert extends org
     }
 
     /**
+     * Asserts that the given matrix is equals to the expected one, up to the given tolerance
value.
+     *
+     * @param message   Header of the exception message in case of failure, or {@code null}
if none.
+     * @param expected  The expected matrix.
+     * @param actual    The matrix to compare.
+     * @param tolerance The tolerance threshold.
+     */
+    public static void assertMatrixEquals(final String message, final Matrix expected, final
Matrix actual, final double tolerance) {
+        if (TestCase.PENDING_NEXT_GEOAPI_RELEASE) {
+            // TODO: Remove this method, so we inherit the GeoAPI one instead.
+        }
+        final int numRow = actual.getNumRow();
+        final int numCol = actual.getNumCol();
+        assertEquals("numRow", expected.getNumRow(), numRow);
+        assertEquals("numCol", expected.getNumCol(), numCol);
+        for (int j=0; j<numRow; j++) {
+            for (int i=0; i<numCol; i++) {
+                final double e = expected.getElement(j,i);
+                final double a = actual.getElement(j,i);
+                if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a)
!= Double.doubleToLongBits(e)) {
+                    fail("Matrix.getElement(" + j + ", " + i + "): expected " + e + " but
got " + a);
+                }
+            }
+        }
+    }
+
+    /**
      * Asserts that the two given objects are not equal.
      * This method tests all {@link ComparisonMode} except {@code DEBUG}.
      *



Mime
View raw message