Tests consolidation.
git-svn-id: https://svn.apache.org/repos/asf/sis/branches/JDK8@1753580 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
index 75265e2..ea3ab2b 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
@@ -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 @@
@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 @@
*/
@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 @@
/*
* 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 @@
@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 @@
/*
* 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 @@
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());
+ }
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
index ae35374..4bf5a5b 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java
@@ -175,7 +175,7 @@
/**
* 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 @@
* 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")
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
index f71db67..3e9267b 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
@@ -22,10 +22,12 @@
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 @@
*/
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 @@
*/
@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 @@
@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 @@
@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 @@
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);
+ }
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
index 3b03f5e..3a0da83 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
@@ -27,6 +27,7 @@
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 @@
*
* @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 @@
* 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 @@
/**
* 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 @@
* 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);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
index 51918c4..67e69a8 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/LambertConicConformalTest.java
@@ -49,7 +49,7 @@
* @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 @@
/**
* 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 @@
* 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 @@
@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 @@
@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);
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
index 8ee3fbb..619a8e8 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
@@ -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.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 @@
* @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 @@
}
/**
+ * 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 @@
}
/**
- * 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 @@
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 @@
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
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
index 002a8e7..0f15fe5 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
@@ -44,7 +44,7 @@
* @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 @@
* 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 @@
* 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 @@
@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);
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
index 66ea07a..d415658 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
@@ -32,6 +32,7 @@
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 @@
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.8
* @module
*/
@DependsOn(NormalizedProjectionTest.class)
@@ -169,11 +170,14 @@
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;
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
index bf09139..5952a8a 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
@@ -27,6 +27,7 @@
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 @@
@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 @@
/**
* 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 @@
/**
* 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 {