sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1683689 - in /sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum: BursaWolfParametersTest.java TimeDependentBWPTest.java
Date Fri, 05 Jun 2015 09:41:52 GMT
Author: desruisseaux
Date: Fri Jun  5 09:41:52 2015
New Revision: 1683689

URL: http://svn.apache.org/r1683689
Log:
Referencing: added test cases for BursaWolfParmeters.get/setValues(...) methods.

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

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1683689&r1=1683688&r2=1683689&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] Fri Jun  5 09:41:52 2015
@@ -38,7 +38,7 @@ import static org.apache.sis.test.mock.G
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public final strictfp class BursaWolfParametersTest extends TestCase {
@@ -117,6 +117,34 @@ public final strictfp class BursaWolfPar
     }
 
     /**
+     * Tests {@link BursaWolfParameters#getValues()}.
+     */
+    @Test
+    public void testGetValues() {
+        assertArrayEquals("Translation only", new double[] {-168, -60, 320},
+                createNTF_to_WGS84().getValues(), STRICT);
+        assertArrayEquals("All 7 params", new double[] {-82.981, -99.719, -110.709, -0.5076,
0.1503, 0.3898, -0.3143},
+                createED87_to_WGS84().getValues(), STRICT);
+        assertArrayEquals("Mixed", new double[] {0, 0, 4.5, 0, 0, 0.554, 0.219},
+                createWGS72_to_WGS84().getValues(), STRICT);
+    }
+
+    /**
+     * Tests {@link BursaWolfParameters#setValues(double[])}.
+     */
+    @Test
+    @DependsOnMethod("testGetValues")
+    public void testSetValues() {
+        final BursaWolfParameters actual =  createWGS72_to_WGS84();
+        final BursaWolfParameters expected = createED87_to_WGS84();
+        final double[] values = expected.getValues();
+        assertFalse("equals(Object) before to set the values.", actual.equals(expected));
+        actual.setValues(values);
+        assertArrayEquals("getValues() after setting the values.", values, actual.getValues(),
STRICT);
+        // Can not test assertEquals(expected, actual) because of different geographic extent.
+    }
+
+    /**
      * Tests {@link BursaWolfParameters#getPositionVectorTransformation(Date)}.
      * This test transform a point from WGS72 to WGS84, and conversely,
      * as documented in the example section of EPSG operation method 9606.
@@ -194,9 +222,10 @@ public final strictfp class BursaWolfPar
      * Tests the string representation of <cite>ED87 to WGS 84</cite> parameters
(EPSG:1146).
      */
     @Test
+    @DependsOnMethod("testGetValues")
     public void testToString() {
-        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
-        assertEquals("ToWGS84[-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143]",
bursaWolf.toString());
+        assertEquals("ToWGS84[-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143]",
createED87_to_WGS84().toString());
+        assertEquals("ToWGS84[-168.0, -60.0, 320.0]", createNTF_to_WGS84().toString());
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java?rev=1683689&r1=1683688&r2=1683689&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
[UTF-8] Fri Jun  5 09:41:52 2015
@@ -37,24 +37,17 @@ import static org.apache.sis.internal.re
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 @DependsOn(BursaWolfParametersTest.class)
 public final strictfp class TimeDependentBWPTest extends TestCase {
     /**
-     * Tests the {@link BursaWolfParameters#setPositionVectorTransformation(Matrix, double)}
method
-     * using the example given in the EPSG database for operation method EPSG:1053.
-     *
-     * @throws NoninvertibleMatrixException Should not happen.
+     * Creates a {@code TimeDependentBWP} using the example given in the EPSG database for
operation method EPSG:1053.
+     * The target datum given by the EPG example is actually GDA94, but it is coincident
with WGS84 to within 1 metre.
+     * For the purpose of this test, the target datum does not matter anyway.
      */
-    @Test
-    @DependsOnMethod("testEpsgCalculation")
-    public void testSetPositionVectorTransformation() throws NoninvertibleMatrixException
{
-        /*
-         * The target datum is actually GDA94, but it is coincident with WGS84 to within
1 metre.
-         * For the purpose of this test, the target datum does not matter anyway.
-         */
+    private static TimeDependentBWP create() {
         final TimeDependentBWP p = new TimeDependentBWP(WGS84, null, date("1994-01-01 00:00:00"));
         p.tX = -0.08468;    p.dtX = +1.42;
         p.tY = -0.01942;    p.dtY = +1.34;
@@ -63,10 +56,49 @@ public final strictfp class TimeDependen
         p.rY = -0.0022578;  p.drY = -1.1820;
         p.rZ = -0.0024015;  p.drZ = -1.1551;
         p.dS = +0.00971;    p.ddS = +0.000109;
+        return p;
+    }
+
+    /**
+     * Tests {@link TimeDependentBWP#invert()}. This will indirectly tests {@link TimeDependentBWP#getValues()}
+     * followed by {@link TimeDependentBWP#setValues(double[])} because of the way the {@code
invert()} method
+     * is implemented.
+     */
+    @Test
+    public void testInvert() {
+        /*
+         * Opportunistically test getValue() first because it is used by TimeDependentBWP.invert().
+         */
+        final double[] expected = {
+            -0.08468, -0.01942, +0.03201, +0.0004254, -0.0022578, -0.0024015, +0.00971,
+            +1.42,    +1.34,    +0.90,    -1.5461,    -1.1820,    -1.1551,    +0.000109
+        };
+        final TimeDependentBWP p = create();
+        assertArrayEquals(expected, p.getValues(), STRICT);
+        /*
+         * Now perform the actual TimeDependentBWP.invert() test.
+         */
+        for (int i=0; i<expected.length; i++) {
+            expected[i] = -expected[i];
+        }
+        p.invert();
+        assertArrayEquals(expected, p.getValues(), STRICT);
+    }
+
+    /**
+     * Tests the {@link TimeDependentBWP#setPositionVectorTransformation(Matrix, double)}
method
+     * using the example given in the EPSG database for operation method EPSG:1053.
+     *
+     * @throws NoninvertibleMatrixException Should not happen.
+     */
+    @Test
+    @DependsOnMethod("testEpsgCalculation")
+    public void testSetPositionVectorTransformation() throws NoninvertibleMatrixException
{
         /*
          * The transformation that we are going to test use as input
          * geocentric coordinates on ITRF2008 at epoch 2013.9.
          */
+        final TimeDependentBWP p = create();
         final Date time = p.getTimeReference();
         time.setTime(time.getTime() + StrictMath.round((2013.9 - 1994) * JULIAN_YEAR_LENGTH));
         assertEquals(date("2013-11-25 11:24:00"), time);



Mime
View raw message