sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1541276 - /sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
Date Tue, 12 Nov 2013 22:30:28 GMT
Author: desruisseaux
Date: Tue Nov 12 22:30:27 2013
New Revision: 1541276

URL: http://svn.apache.org/r1541276
Log:
Identified the magnitude of the difference between our calculated values and the EPSG ones.
Verified that we get the same result when calculating from the pre-corrected values given
in the EPSG example.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java?rev=1541276&r1=1541275&r2=1541276&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
[UTF-8] Tue Nov 12 22:30:27 2013
@@ -21,6 +21,7 @@ import org.opengis.referencing.operation
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -47,15 +48,16 @@ public final strictfp class TimeDependen
      * @throws NoninvertibleMatrixException Should not happen.
      */
     @Test
+    @DependsOnMethod("testEpsgCalculation")
     public void testSetPositionVectorTransformation() throws NoninvertibleMatrixException
{
         final TimeDependentBWP p = new TimeDependentBWP(null, null, date("1994-01-01 00:00:00"));
-        p.tX = -84.68  / 1000;  p.dtX = +1.42;
-        p.tY = -19.42  / 1000;  p.dtY = +1.34;
-        p.tZ = +32.01  / 1000;  p.dtZ = +0.90;
-        p.rX = +0.4254 / 1000;  p.drX = -1.5461;
-        p.rY = -2.2578 / 1000;  p.drY = -1.1820;
-        p.rZ = -2.4015 / 1000;  p.drZ = -1.1551;
-        p.dS = +0.00971;        p.ddS = +0.000109;
+        p.tX = -0.08468;    p.dtX = +1.42;
+        p.tY = -0.01942;    p.dtY = +1.34;
+        p.tZ = +0.03201;    p.dtZ = +0.90;
+        p.rX = +0.0004254;  p.drX = -1.5461;
+        p.rY = -0.0022578;  p.drY = -1.1820;
+        p.rZ = -0.0024015;  p.drZ = -1.1551;
+        p.dS = +0.00971;    p.ddS = +0.000109;
         /*
          * The transformation that we are going to test use as input
          * geocentric coordinates on ITRF2008 at epoch 2013.9.
@@ -64,13 +66,87 @@ public final strictfp class TimeDependen
         time.setTime(time.getTime() + StrictMath.round((2013.9 - 1994) * JULIAN_YEAR_LENGTH));
         assertEquals(date("2013-11-25 11:24:00"), time);
         /*
-         * Transform the point and compare with the expected value given in the EPSG examples.
+         * Transform the point given in the EPSG example and compare with the coordinate
+         * that we obtain if we do the calculation ourself using the intermediate values
+         * given in EPSG example.
          */
         final MatrixSIS toGDA94    = MatrixSIS.castOrCopy(p.getPositionVectorTransformation(time));
         final MatrixSIS toITRF2008 = toGDA94.inverse();
         final MatrixSIS source     = Matrices.create(4, 1, new double[] {-3789470.702, 4841770.411,
-1690893.950, 1});
         final MatrixSIS target     = Matrices.create(4, 1, new double[] {-3789470.008, 4841770.685,
-1690895.103, 1});
-//      assertMatrixEquals("toGDA94",    target, toGDA94   .multiply(source), 0.001);
-//      assertMatrixEquals("toITRF2008", source, toITRF2008.multiply(target), 0.001);
+        final MatrixSIS actual     = toGDA94.multiply(source);
+        compareWithExplicitCalculation(actual);
+        /*
+         * Now compare with the expected value given in the EPSG example. The 0.013 tolerance
threshold
+         * is for the X ordinate and has been determined empirically in testEpsgCalculation().
+         */
+        assertMatrixEquals("toGDA94",    target, actual, 0.013);
+        assertMatrixEquals("toITRF2008", source, toITRF2008.multiply(target), 0.013);
+    }
+
+    /**
+     * Compares the coordinates calculated with the {@link TimeDependentBWP#getPositionVectorTransformation(Date)}
+     * matrix with the coordinates calculated ourselves from the numbers given in the EPSG
examples. Note that the
+     * EPSG documentation truncates the numerical values given in their example, so it is
normal that we have a
+     * slight difference.
+     *
+     * @param actual The coordinates calculated by the matrix, or {@code null} for comparing
against
+     *        the EPSG expected values.
+     */
+    private void compareWithExplicitCalculation(final Matrix actual) {
+        /*
+         * Following are Bursa-Wolf parameters corrected for the rate of changes. The numerical
values here
+         * are different than the numerical values in testSetPositionVectorTransformation()
because of this
+         * correction. Units are metres and radians.
+         */
+        final double tX = -0.056;
+        final double tY = +0.007;
+        final double tZ = +0.050;
+        final double rX = -1.471021E-07;
+        final double rY = -1.249830E-07;
+        final double rZ = -1.230844E-07;
+        final double dS = +0.01188;
+        /*
+         * The source coordinates. This is the same coordinates than testSetPositionVectorTransformation().
+         */
+        final double Xs = -3789470.702;
+        final double Ys =  4841770.411;
+        final double Zs = -1690893.950;
+        /*
+         * Application of the 7 parameter Position Vector transformation.
+         * (the multiplications by 1 are like no-op, but kept for visualizing the matrix
terms).
+         */
+        final double M  = 1 + (dS * 1E-6);
+        final double Xt = M * (  1 * Xs   +  -rZ * Ys   +   rY * Zs)   +   tX;
+        final double Yt = M * (+rZ * Xs   +    1 * Ys   +  -rX * Zs)   +   tY;
+        final double Zt = M * (-rY * Xs   +   rX * Ys   +    1 * Zs)   +   tZ;
+        /*
+         * Compares with the coordinates calculated by the TimeDependentBWP matrix (first
case), or
+         * with the expected coordinates provided by EPSG (second case). See testEpsgCalculation()
+         * for a discussion about the second case.
+         */
+        if (actual != null) {
+            assertEquals("X", Xt, actual.getElement(0, 0), 0.0005);
+            assertEquals("Y", Yt, actual.getElement(1, 0), 0.0005);
+            assertEquals("Z", Zt, actual.getElement(2, 0), 0.0005);
+        } else {
+            assertEquals("X", -3789470.008, Xt, 0.013); // Smallest tolerance value such
as the test do not fail.
+            assertEquals("Y",  4841770.685, Yt, 0.009);
+            assertEquals("Z", -1690895.103, Zt, 0.003);
+        }
+    }
+
+    /**
+     * Tries to apply ourselves the example given for operation method EPSG:1053 in EPSG
database 8.2.7.
+     * For a unknown reason, we do not get exactly the values that EPSG said that we should
get when applying
+     * the 7 parameter Position Vector transformation from the parameter values as corrected
by EPSG themselves.
+     * We find a difference of 13, 9 and 3 millimetres along the X, Y and Z axis respectively.
+     *
+     * <p>The purpose of this test is to ensure that we get the same errors when calculating
from the corrected values
+     * provided by EPSG, rather than as an error in {@link TimeDependentBWP#getPositionVectorTransformation(Date)}</p>
+     */
+    @Test
+    public void testEpsgCalculation() {
+        compareWithExplicitCalculation(null);
     }
 }



Mime
View raw message