sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1753580 - /sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/
Date Wed, 20 Jul 2016 17:25:25 GMT
Author: desruisseaux
Date: Wed Jul 20 17:25:25 2016
New Revision: 1753580

URL: http://svn.apache.org/viewvc?rev=1753580&view=rev
Log:
Tests consolidation.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -17,15 +17,11 @@
 package org.apache.sis.referencing.operation.projection;
 
 import org.opengis.util.FactoryException;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.internal.referencing.Formulas;
-import org.apache.sis.internal.referencing.provider.MapProjection;
-import org.apache.sis.internal.system.DefaultFactories;
-import org.apache.sis.parameter.Parameters;
 
 import static java.lang.StrictMath.*;
+import static java.lang.Double.NaN;
 
 // Test dependencies
 import org.opengis.test.ToleranceModifier;
@@ -51,27 +47,6 @@ import static org.junit.Assert.*;
 @DependsOn(CylindricalEqualAreaTest.class)
 public final strictfp class AlbersEqualAreaTest extends MapProjectionTestCase {
     /**
-     * Creates a new map projection. See the class javadoc for an explanation about
-     * why we ask only for the standard parallels and not the latitude of origin.
-     *
-     * @param  a   semi-major axis length.
-     * @param  b   semi-minor axis length.
-     * @param  φ1  first standard parallel.
-     * @param  φ2  second standard parallel.
-     * @return newly created projection.
-     * @throws FactoryException if an error occurred while creating the map projection.
-     */
-    private static MathTransform create(final double a, final double b, double φ1, double
φ2) throws FactoryException {
-        final MapProjection method = new org.apache.sis.internal.referencing.provider.AlbersEqualArea();
-        final Parameters values = Parameters.castOrWrap(method.getParameters().createValue());
-        values.parameter("semi_major").setValue(a);
-        values.parameter("semi_minor").setValue(b);
-        values.parameter("standard_parallel_1").setValue(φ1);
-        values.parameter("standard_parallel_2").setValue(φ2);
-        return method.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class),
values);
-    }
-
-    /**
      * Returns whether the given projection is the spherical implementation.
      */
     private static boolean isSpherical(final AlbersEqualArea transform) {
@@ -86,11 +61,21 @@ public final strictfp class AlbersEqualA
      */
     @Test
     public void testSphere() throws FactoryException, TransformException {
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.AlbersEqualArea(),
+                6370997,    // Semi-major axis from Synder table 15
+                6370997,    // Semi-minor axis
+                0,          // Central meridian
+                0,          // Latitude of origin
+                29.5,       // Standard parallel 1 (from Synder table 15)
+                45.5,       // Standard parallel 2 (from Synder table 15)
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
+
         final double delta = toRadians(100.0 / 60) / 1852;                  // Approximatively
100 metres.
         derivativeDeltas = new double[] {delta, delta};
         toleranceModifier = ToleranceModifier.PROJECTION;
         tolerance = Formulas.LINEAR_TOLERANCE;
-        transform = create(6370997, 6370997, 29.5, 45.5);                   // Standard parallels
from Synder table 15.
         final AlbersEqualArea kernel = (AlbersEqualArea) getKernel();
         assertTrue("isSpherical", isSpherical(kernel));
         assertEquals("n", 0.6028370, kernel.nm, 0.5E-7);                    // Expected 'n'
value from Synder table 15.
@@ -110,8 +95,10 @@ public final strictfp class AlbersEqualA
         /*
          * Verify consistency with random points.
          */
-        verifyInDomain(new double[] {-20, 20}, new double[] {20, 50}, new int[] {5, 5},
-                TestUtilities.createRandomNumberGenerator());
+        verifyInDomain(new double[] {-20, 20},          // Minimal input ordinate values
+                       new double[] {+20, 50},          // Maximal input ordinate values
+                       new int[]    {  5,  5},          // Number of points to test
+                       TestUtilities.createRandomNumberGenerator());
     }
 
     /**
@@ -123,11 +110,21 @@ public final strictfp class AlbersEqualA
     @Test
     @DependsOnMethod("testSphere")
     public void testEllipse() throws FactoryException, TransformException {
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.AlbersEqualArea(),
+                6378206.4,  // Semi-major axis from Synder table 15
+                6356583.8,  // Semi-minor axis
+                0,          // Central meridian
+                0,          // Latitude of origin
+                29.5,       // Standard parallel 1 (from Synder table 15)
+                45.5,       // Standard parallel 2 (from Synder table 15)
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
+
         final double delta = toRadians(100.0 / 60) / 1852;                  // Approximatively
100 metres.
         derivativeDeltas = new double[] {delta, delta};
         toleranceModifier = ToleranceModifier.PROJECTION;
         tolerance = Formulas.LINEAR_TOLERANCE;
-        transform = create(6378206.4, 6356583.8, 29.5, 45.5);               // Standard parallels
from Synder table 15.
         final AlbersEqualArea kernel = (AlbersEqualArea) getKernel();
         assertFalse("isSpherical", isSpherical(kernel));
         /*
@@ -151,8 +148,10 @@ public final strictfp class AlbersEqualA
         /*
          * Verify consistency with random points.
          */
-        verifyInDomain(new double[] {-20, 20}, new double[] {20, 50}, new int[] {5, 5},
-                TestUtilities.createRandomNumberGenerator());
+        verifyInDomain(new double[] {-20, 20},          // Minimal input ordinate values
+                       new double[] {+20, 50},          // Maximal input ordinate values
+                       new int[]    {  5,  5},          // Number of points to test
+                       TestUtilities.createRandomNumberGenerator());
     }
 
     /**
@@ -168,11 +167,61 @@ public final strictfp class AlbersEqualA
         tolerance = Formulas.LINEAR_TOLERANCE;
 
         // Spherical case
-        transform = create(6400000, 6400000, 0, 2);
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.AlbersEqualArea(),
+                6400000,    // Semi-major axis
+                6400000,    // Semi-minor axis
+                0,          // Central meridian
+                0,          // Latitude of origin
+                0,          // Standard parallel 1
+                2,          // Standard parallel 2
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
+
         verifyTransform(new double[] {2, 1}, new double[] {223334.085, 111780.432});
 
         // Ellipsoidal case
-        transform = create(6378137, 6356752.314140347, 0, 2);
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.AlbersEqualArea(),
+                6378137,            // Semi-major axis
+                6356752.314140347,  // Semi-minor axis
+                0,                  // Central meridian
+                0,                  // Latitude of origin
+                0,                  // Standard parallel 1
+                2,                  // Standard parallel 2
+                NaN,                // Scale factor (none)
+                0,                  // False easting
+                0);                 // False northing
         verifyTransform(new double[] {2, 1}, new double[] {222571.609, 110653.327});
     }
+
+    /**
+     * Tests conversion of random points with non-zero central meridian, standard parallel
+     * and false easting/northing.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a point.
+     */
+    @Test
+    public void testRandomPoints() throws FactoryException, TransformException {
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.AlbersEqualArea(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                12,         // Central meridian
+                NaN,        // Latitude of origin (none)
+                24,         // Standard parallel 1
+                40,         // Standard parallel 2
+                NaN,        // Scale factor (none)
+                300,        // False easting
+                200);       // False northing
+
+        tolerance = Formulas.LINEAR_TOLERANCE;
+        toleranceModifier = ToleranceModifier.PROJECTION;
+        derivativeDeltas = new double[] {100, 100};
+        final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        verifyInDomain(new double[] {-40, 10},                  // Minimal input ordinate
values
+                       new double[] {+40, 60},                  // Maximal input ordinate
values
+                       new int[]    {  5,  5},                  // Number of points to test
+                       TestUtilities.createRandomNumberGenerator());
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -175,7 +175,7 @@ public final strictfp class ConformalPro
     /**
      * Tests the {@link NormalizedProjection#dy_dφ(double, double)} method.
      *
-     * @throws TransformException Should never happen.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     @DependsOnMethod("testExpOfNorthing")
@@ -232,7 +232,7 @@ public final strictfp class ConformalPro
      * In theory only the [-90° … +90°] range needs to be tested. However the function
is still
      * consistent in the [-90° … +270°] range so we test that range for tracking this
fact.
      *
-     * @throws ProjectionException Should never happen.
+     * @throws ProjectionException if an error occurred while projecting a point.
      */
     @Test
     @DependsOnMethod("testExpOfNorthing")

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -22,10 +22,12 @@ import org.opengis.test.ToleranceModifie
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.referencing.provider.LambertCylindricalEqualArea;
 import org.apache.sis.internal.referencing.provider.LambertCylindricalEqualAreaSpherical;
+import org.apache.sis.referencing.operation.transform.CoordinateDomain;
 import org.apache.sis.test.DependsOnMethod;
 import org.junit.Test;
 
 import static java.lang.StrictMath.*;
+import static java.lang.Double.NaN;
 
 
 /**
@@ -38,16 +40,6 @@ import static java.lang.StrictMath.*;
  */
 public final strictfp class CylindricalEqualAreaTest extends MapProjectionTestCase {
     /**
-     * Creates a map projection.
-     */
-    private void createCompleteProjection(final boolean ellipse,
-            final double centralMeridian, final double standardParallel) throws FactoryException
-    {
-        createCompleteProjection(new LambertCylindricalEqualArea(),
-                ellipse, centralMeridian, 0, standardParallel, 1, 0, 0);
-    }
-
-    /**
      * Tests the derivatives at a few points. This method compares the derivatives computed
by
      * the projection with an estimation of derivatives computed by the finite differences
method.
      *
@@ -69,7 +61,16 @@ public final strictfp class CylindricalE
      */
     @Test
     public void testEllipsoidal() throws FactoryException, TransformException {
-        createCompleteProjection(true, 0, 0);
+        createCompleteProjection(new LambertCylindricalEqualArea(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0,          // Central meridian
+                NaN,        // Latitude of origin
+                0,          // Standard parallel 1
+                NaN,        // Standard parallel 2
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         toleranceModifier = ToleranceModifier.PROJECTION;
         final double λ = 2;
@@ -90,7 +91,16 @@ public final strictfp class CylindricalE
     @Test
     @DependsOnMethod("testEllipsoidal")
     public void testSpherical() throws FactoryException, TransformException {
-        createCompleteProjection(false, 0, 0);
+        createCompleteProjection(new LambertCylindricalEqualArea(),
+                6371007,    // Semi-major axis length
+                6371007,    // Semi-minor axis length
+                0,          // Central meridian
+                NaN,        // Latitude of origin
+                0,          // Standard parallel 1
+                NaN,        // Standard parallel 2
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         toleranceModifier = ToleranceModifier.PROJECTION;
         final double λ = 2;
@@ -114,7 +124,16 @@ public final strictfp class CylindricalE
     @Test
     @DependsOnMethod("testSpherical")
     public void testSphericalWithConformalSphereRadius() throws FactoryException, TransformException
{
-        createCompleteProjection(new LambertCylindricalEqualAreaSpherical(), true, 0, 0,
0, 1, 0, 0);
+        createCompleteProjection(new LambertCylindricalEqualAreaSpherical(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0,          // Central meridian
+                NaN,        // Latitude of origin
+                0,          // Standard parallel 1
+                NaN,        // Standard parallel 2
+                NaN,        // Scale factor (none)
+                0,          // False easting
+                0);         // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         toleranceModifier = ToleranceModifier.PROJECTION;
         final double λ = 2;
@@ -125,4 +144,32 @@ public final strictfp class CylindricalE
                         new double[] {x, y,  -x, y,  x, -y,  -x, -y});
         testDerivative();
     }
+
+    /**
+     * Tests conversion of random points with non-zero central meridian, standard parallel
+     * and false easting/northing.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a point.
+     */
+    @Test
+    public void testRandomPoints() throws FactoryException, TransformException {
+        createCompleteProjection(new LambertCylindricalEqualArea(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                12,         // Central meridian
+                NaN,        // Latitude of origin (none)
+                24,         // Standard parallel 1
+                NaN,        // Standard parallel 2
+                NaN,        // Scale factor (none)
+                300,        // False easting
+                200);       // False northing
+
+        tolerance = Formulas.LINEAR_TOLERANCE;
+        toleranceModifier = ToleranceModifier.PROJECTION;
+        derivativeDeltas = new double[] {100, 100};
+        final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        verifyInDomain(CoordinateDomain.GEOGRAPHIC_SAFE, 0);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -27,6 +27,7 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.test.ReferencingAssert;
 import org.junit.Test;
 
+import static java.lang.Double.NaN;
 import static java.lang.StrictMath.toRadians;
 import static org.apache.sis.internal.metadata.ReferencingServices.AUTHALIC_RADIUS;
 
@@ -38,7 +39,7 @@ import static org.apache.sis.internal.me
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.8
  * @module
  */
 public final strictfp class EquirectangularTest extends MapProjectionTestCase {
@@ -61,7 +62,7 @@ public final strictfp class Equirectangu
      * an affine transform, the WKT formatter should handle this projection in a special
way and shows the
      * projection parameters instead than the affine transform parameters (except in "show
internal" mode).
      *
-     * @throws FactoryException should never happen.
+     * @throws FactoryException if an error occurred while creating the map projection.
      */
     @Test
     public void testWKT() throws FactoryException {
@@ -90,19 +91,19 @@ public final strictfp class Equirectangu
     /**
      * Tests a simple transform on a sphere.
      *
-     * @throws FactoryException should never happen.
-     * @throws TransformException should never happen.
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     public void testSimpleTransform() throws FactoryException, TransformException {
         createCompleteProjection();
         verifyTransform(
-                new double[] {  // (λ,φ) coordinates in degrees to project.
+                new double[] {          // (λ,φ) coordinates in degrees to project.
                     0, 0,
                     2, 0,
                     0, 3
                 },
-                new double[] {  // Expected (x,y) results in metres.
+                new double[] {          // Expected (x,y) results in metres.
                     0,                            0,
                     AUTHALIC_RADIUS*toRadians(2), 0,
                     0, AUTHALIC_RADIUS*toRadians(3)
@@ -113,18 +114,21 @@ public final strictfp class Equirectangu
      * Tests conversion of random points. This test is actually of limited interest since
the Equirectangular
      * projection is implemented by an affine transform, which has been tested elsewhere.
      *
-     * @throws FactoryException should never happen.
-     * @throws TransformException should never happen.
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     public void testRandomPoints() throws FactoryException, TransformException {
-        createCompleteProjection(new Equirectangular(), true,
-                  0.5,  // Central meridian
-                  0,    // Latitude of origin (none)
-                 20,    // Standard parallel
-                  1,    // Scale factor (none)
-                200,    // False easting
-                100);   // False northing
+        createCompleteProjection(new Equirectangular(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0.5,        // Central meridian
+                0,          // Latitude of origin (none)
+                20,         // Standard parallel 1
+                NaN,        // Standard parallel 2
+                NaN,        // Scale factor (none)
+                200,        // False easting
+                100);       // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;  // Not NORMALIZED_TOLERANCE since this is
not a NormalizedProjection.
         derivativeDeltas = new double[] {100, 100};
         verifyInDomain(CoordinateDomain.GEOGRAPHIC, 0);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -49,7 +49,7 @@ import static org.apache.sis.test.Assert
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.6
- * @version 0.7
+ * @version 0.8
  * @module
  */
 @DependsOn(ConformalProjectionTest.class)
@@ -112,12 +112,12 @@ public final strictfp class LambertConic
     /**
      * Tests the projection at some special latitudes (0, ±π/2, NaN and others).
      *
-     * @throws ProjectionException Should never happen.
+     * @throws ProjectionException if an error occurred while projecting a point.
      */
     @Test
     public void testSpecialLatitudes() throws ProjectionException {
-        if (transform == null) {    // May have been initialized by 'testSphericalCase'.
-            createNormalizedProjection(true, 40);  // Elliptical case
+        if (transform == null) {                        // May have been initialized by 'testSphericalCase'.
+            createNormalizedProjection(true, 40);       // Elliptical case
         }
         final double INF = POSITIVE_INFINITY;
         assertEquals ("Not a number",     NaN, transform(NaN),            NORMALIZED_TOLERANCE);
@@ -161,7 +161,7 @@ public final strictfp class LambertConic
      * Tests the derivatives at a few points. This method compares the derivatives computed
by
      * the projection with an estimation of derivatives computed by the finite differences
method.
      *
-     * @throws TransformException Should never happen.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     @DependsOnMethod("testSpecialLatitudes")
@@ -246,28 +246,34 @@ public final strictfp class LambertConic
     @Test
     @DependsOnMethod("testLambertConicConformal1SP")
     public void testLambertConicConformalWestOrientated() throws FactoryException, TransformException
{
-        createCompleteProjection(new LambertConformal1SP(), false,
-                  0.5,    // Central meridian
-                 40,      // Latitude of origin
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new LambertConformal1SP(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0.5,        // Central meridian
+                40,         // Latitude of origin
+                NaN,        // Standard parallel 1
+                NaN,        // Standard parallel 2
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
         final MathTransform reference = transform;
 
-        createCompleteProjection(new LambertConformalWest(), false,
-                  0.5,    // Central meridian
-                 40,      // Latitude of origin
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new LambertConformalWest(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0.5,        // Central meridian
+                40,         // Latitude of origin
+                NaN,        // Standard parallel 1
+                NaN,        // Standard parallel 2
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
 
         final Random random = TestUtilities.createRandomNumberGenerator();
         final double[] sources = new double[20];
         for (int i=0; i<sources.length;) {
-            sources[i++] = 20 * random.nextDouble();      // Longitude
-            sources[i++] = 10 * random.nextDouble() + 35; // Latitude
+            sources[i++] = 20 * random.nextDouble();            // Longitude
+            sources[i++] = 10 * random.nextDouble() + 35;       // Latitude
         }
         final double[] expected = new double[sources.length];
         reference.transform(sources, 0, expected, 0, sources.length/2);
@@ -326,13 +332,16 @@ public final strictfp class LambertConic
     @Test
     @DependsOnMethod("testSphericalCase")
     public void compareEllipticalWithSpherical() throws FactoryException, TransformException
{
-        createCompleteProjection(new LambertConformal1SP(), false,
-                  0.5,    // Central meridian
-                 40,      // Latitude of origin
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new LambertConformal1SP(),
+                6371007,    // Semi-major axis length
+                6371007,    // Semi-minor axis length
+                0.5,        // Central meridian
+                40,         // Latitude of origin
+                NaN,        // Standard parallel 1
+                NaN,        // Standard parallel 2
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         compareEllipticalWithSpherical(CoordinateDomain.GEOGRAPHIC_SAFE, 0);
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.referencing.operation.projection;
 
-import javax.measure.unit.NonSI;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.operation.MathTransform;
@@ -32,6 +31,7 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.datum.GeodeticDatumMock;
 
+import static java.lang.Double.isNaN;
 import static java.lang.StrictMath.*;
 import static org.junit.Assert.*;
 
@@ -44,7 +44,17 @@ import static org.junit.Assert.*;
  * @version 0.8
  * @module
  */
-strictfp class MapProjectionTestCase extends MathTransformTestCase {
+abstract strictfp class MapProjectionTestCase extends MathTransformTestCase {
+    /**
+     * Semi-major axis length of WGS84 ellipsoid.
+     */
+    static final double WGS84_A = 6378137;
+
+    /**
+     * Semi-minor axis length of WGS84 ellipsoid.
+     */
+    static final double WGS84_B = 6356752.314245179;
+
     /**
      * Tolerance level for comparing formulas on the unitary sphere or ellipsoid.
      */
@@ -57,7 +67,18 @@ strictfp class MapProjectionTestCase ext
     }
 
     /**
+     * Instantiates the object to use for running GeoAPI test.
+     *
+     * @param  provider  the provider of the projection to test.
+     * @return the GeoAPI test class using the given provider.
+     */
+    static ParameterizedTransformTest createGeoApiTest(final MapProjection provider) {
+        return new ParameterizedTransformTest(new MathTransformFactoryMock(provider));
+    }
+
+    /**
      * Returns the parameters to use for instantiating the projection to test.
+     * The parameters are initialized with the ellipse semi-axis lengths.
      *
      * @param  provider  the provider of the projection to test.
      * @param  ellipse   {@code false} for a sphere, or {@code true} for WGS84 ellipsoid.
@@ -75,36 +96,33 @@ strictfp class MapProjectionTestCase ext
     }
 
     /**
-     * Instantiates the object to use for running GeoAPI test.
-     *
-     * @param  provider  the provider of the projection to test.
-     * @return the GeoAPI test class using the given provider.
-     */
-    static ParameterizedTransformTest createGeoApiTest(final MapProjection provider) {
-        return new ParameterizedTransformTest(new MathTransformFactoryMock(provider));
-    }
-
-    /**
      * Initializes a complete projection (including conversion from degrees to radians) for
the given provider.
-     * This method uses arbitrary central meridian, scale factor, false easting and false
northing for increasing
-     * the chances to detect a mismatch. The result is stored in the {@link #transform} field.
      */
-    final void createCompleteProjection(final DefaultOperationMethod provider, final boolean
ellipse,
+    final void createCompleteProjection(final DefaultOperationMethod provider,
+            final double semiMajor,
+            final double semiMinor,
             final double centralMeridian,
             final double latitudeOfOrigin,
-            final double standardParallel,
+            final double standardParallel1,
+            final double standardParallel2,
             final double scaleFactor,
             final double falseEasting,
             final double falseNorthing) throws FactoryException
     {
-        final Parameters parameters = parameters(provider, ellipse);
-        if (centralMeridian  != 0) parameters.parameter(Constants.CENTRAL_MERIDIAN)   .setValue(centralMeridian,
NonSI.DEGREE_ANGLE);
-        if (latitudeOfOrigin != 0) parameters.parameter(Constants.LATITUDE_OF_ORIGIN) .setValue(latitudeOfOrigin);
-        if (standardParallel != 0) parameters.parameter(Constants.STANDARD_PARALLEL_1).setValue(standardParallel);
-        if (scaleFactor      != 1) parameters.parameter(Constants.SCALE_FACTOR)       .setValue(scaleFactor);
-        if (falseEasting     != 0) parameters.parameter(Constants.FALSE_EASTING)      .setValue(falseEasting);
-        if (falseNorthing    != 0) parameters.parameter(Constants.FALSE_NORTHING)     .setValue(falseNorthing);
-        transform = new MathTransformFactoryMock(provider).createParameterizedTransform(parameters);
+        final Parameters values = Parameters.castOrWrap(provider.getParameters().createValue());
+        values.parameter(Constants.SEMI_MAJOR).setValue(semiMajor);
+        values.parameter(Constants.SEMI_MINOR).setValue(semiMinor);
+        if (semiMajor == WGS84_A && semiMinor == WGS84_B) {
+            values.parameter(Constants.INVERSE_FLATTENING).setValue(298.257223563);
+        }
+        if (!isNaN(centralMeridian))   values.parameter(Constants.CENTRAL_MERIDIAN)   .setValue(centralMeridian);
+        if (!isNaN(latitudeOfOrigin))  values.parameter(Constants.LATITUDE_OF_ORIGIN) .setValue(latitudeOfOrigin);
+        if (!isNaN(standardParallel1)) values.parameter(Constants.STANDARD_PARALLEL_1).setValue(standardParallel1);
+        if (!isNaN(standardParallel2)) values.parameter(Constants.STANDARD_PARALLEL_2).setValue(standardParallel2);
+        if (!isNaN(scaleFactor))       values.parameter(Constants.SCALE_FACTOR)       .setValue(scaleFactor);
+        if (!isNaN(falseEasting))      values.parameter(Constants.FALSE_EASTING)      .setValue(falseEasting);
+        if (!isNaN(falseNorthing))     values.parameter(Constants.FALSE_NORTHING)     .setValue(falseNorthing);
+        transform = new MathTransformFactoryMock(provider).createParameterizedTransform(values);
         validate();
     }
 
@@ -136,7 +154,7 @@ strictfp class MapProjectionTestCase ext
         coordinate[1] = φ;
         ((NormalizedProjection) transform).transform(coordinate, 0, coordinate, 0, false);
         final double y = coordinate[1];
-        if (!Double.isNaN(y) && !Double.isInfinite(y)) {
+        if (!isNaN(y) && !Double.isInfinite(y)) {
             assertEquals(0, coordinate[0], tolerance);
         }
         return y;
@@ -155,7 +173,7 @@ strictfp class MapProjectionTestCase ext
         coordinate[1] = y;
         ((NormalizedProjection) transform).inverseTransform(coordinate, 0, coordinate, 0);
         final double φ = coordinate[1];
-        if (!Double.isNaN(φ)) {
+        if (!isNaN(φ)) {
             /*
              * Opportunistically verify that the longitude is still zero. However the longitude
value is meaningless
              * at poles. We can not always use coordinate[0] for testing if we are at a pole
because its calculation

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -44,7 +44,7 @@ import static org.apache.sis.referencing
  * @author  Simon Reynard (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.6
- * @version 0.7
+ * @version 0.8
  * @module
  */
 @DependsOn(ConformalProjectionTest.class)
@@ -70,7 +70,7 @@ public final strictfp class MercatorTest
      * the ellipsoid eccentricity. We expect nothing else because all other parameters are
used
      * by the (de)normalization affine transforms instead than the {@link Mercator} class
itself.
      *
-     * @throws NoninvertibleTransformException should never happen.
+     * @throws NoninvertibleTransformException if the transform can not be inverted.
      *
      * @see LambertConicConformalTest#testNormalizedWKT()
      */
@@ -90,18 +90,21 @@ public final strictfp class MercatorTest
      * Tests WKT of a complete map projection.
      *
      * @throws FactoryException if an error occurred while creating the map projection.
-     * @throws NoninvertibleTransformException should never happen.
+     * @throws NoninvertibleTransformException if the transform can not be inverted.
      */
     @Test
     @DependsOnMethod("testNormalizedWKT")
     public void testCompleteWKT() throws FactoryException, NoninvertibleTransformException
{
-        createCompleteProjection(new Mercator1SP(), true,
-                  0.5,    // Central meridian
-                  0,      // Latitude of origin (none)
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new Mercator1SP(),
+                WGS84_A,    // Semi-major axis length
+                WGS84_B,    // Semi-minor axis length
+                0.5,        // Central meridian
+                NaN,        // Latitude of origin (none)
+                NaN,        // Standard parallel 1 (none)
+                NaN,        // Standard parallel 2 (none)
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
 
         assertWktEquals("PARAM_MT[“Mercator_1SP”,\n" +
                         "  PARAMETER[“semi_major”, 6378137.0],\n" +
@@ -289,13 +292,16 @@ public final strictfp class MercatorTest
     @Test
     @DependsOnMethod("testSphericalCase")
     public void compareEllipticalWithSpherical() throws FactoryException, TransformException
{
-        createCompleteProjection(new Mercator1SP(), false,
-                  0.5,    // Central meridian
-                  0,      // Latitude of origin (none)
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new Mercator1SP(),
+                6371007,    // Semi-major axis length
+                6371007,    // Semi-minor axis length
+                0.5,        // Central meridian
+                NaN,        // Latitude of origin (none)
+                NaN,        // Standard parallel 1 (none)
+                NaN,        // Standard parallel 2 (none)
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         compareEllipticalWithSpherical(CoordinateDomain.GEOGRAPHIC_SAFE, 0);
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -32,6 +32,7 @@ import org.apache.sis.test.DependsOnMeth
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
+import static java.lang.Double.NaN;
 import static java.lang.StrictMath.*;
 
 
@@ -40,7 +41,7 @@ import static java.lang.StrictMath.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.8
  * @module
  */
 @DependsOn(NormalizedProjectionTest.class)
@@ -169,11 +170,14 @@ public final strictfp class PolarStereog
     private void compareEllipticalWithSpherical(final CoordinateDomain domain, final double
latitudeOfOrigin,
             final long randomSeed) throws FactoryException, TransformException
     {
-        createCompleteProjection(new PolarStereographicA(), false,
-                  0.5,              // Central meridian
-                 latitudeOfOrigin,  // Latitude of origin
-                  0,                // Standard parallel (none)
-                  0.994,            // Scale factor
+        createCompleteProjection(new PolarStereographicA(),
+                6371007,            // Semi-major axis length
+                6371007,            // Semi-minor axis length
+                0.5,                // Central meridian
+                latitudeOfOrigin,   // Latitude of origin
+                NaN,                // Standard parallel 1 (none)
+                NaN,                // Standard parallel 2 (none)
+                0.994,              // Scale factor
                 200,                // False easting
                 100);               // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java?rev=1753580&r1=1753579&r2=1753580&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
[UTF-8] Wed Jul 20 17:25:25 2016
@@ -27,6 +27,7 @@ import org.apache.sis.test.DependsOnMeth
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
+import static java.lang.Double.NaN;
 import static java.lang.StrictMath.toRadians;
 import static org.apache.sis.test.Assert.*;
 
@@ -96,13 +97,16 @@ public final strictfp class TransverseMe
     @Test
     @DependsOnMethod("testTransverseMercator")
     public void compareEllipticalWithSpherical() throws FactoryException, TransformException
{
-        createCompleteProjection(new org.apache.sis.internal.referencing.provider.TransverseMercator(),
false,
-                  0.5,    // Central meridian
-                  2.5,    // Latitude of origin
-                  0,      // Standard parallel (none)
-                  0.997,  // Scale factor
-                200,      // False easting
-                100);     // False northing
+        createCompleteProjection(new org.apache.sis.internal.referencing.provider.TransverseMercator(),
+                6371007,    // Semi-major axis length
+                6371007,    // Semi-minor axis length
+                0.5,        // Central meridian
+                2.5,        // Latitude of origin
+                NaN,        // Standard parallel 1 (none)
+                NaN,        // Standard parallel 1 (none)
+                0.997,      // Scale factor
+                200,        // False easting
+                100);       // False northing
         tolerance = Formulas.LINEAR_TOLERANCE;
         compareEllipticalWithSpherical(CoordinateDomain.RANGE_10, 0);
     }
@@ -110,7 +114,7 @@ public final strictfp class TransverseMe
     /**
      * Creates a projection and derivates a few points.
      *
-     * @throws TransformException Should never happen.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     public void testSphericalDerivative() throws TransformException {
@@ -127,7 +131,7 @@ public final strictfp class TransverseMe
     /**
      * Creates a projection and derivates a few points.
      *
-     * @throws TransformException Should never happen.
+     * @throws TransformException if an error occurred while projecting a point.
      */
     @Test
     public void testEllipsoidalDerivative() throws TransformException {




Mime
View raw message