This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new c69d648 Define ModifiedAzimuthalEquidistant as a subtype of
AzimuthalEquidistant.
c69d648 is described below
commit c69d6488a2c4bf4bf12ba2735d1f15ebc7bb7e30
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Mar 19 23:54:01 2020 +0100
Define ModifiedAzimuthalEquidistant as a subtype of AzimuthalEquidistant.
---
.../apache/sis/internal/referencing/Formulas.java | 2 +-
.../operation/projection/AzimuthalEquidistant.java | 10 ++---
.../projection/ModifiedAzimuthalEquidistant.java | 14 ++-----
.../projection/AzimuthalEquidistantTest.java | 34 ++++++++++++-----
.../ModifiedAzimuthalEquidistantTest.java | 44 ++++++++++++++++++++--
5 files changed, 73 insertions(+), 31 deletions(-)
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
index c1d38d2..f0012a5 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
@@ -161,7 +161,7 @@ public final class Formulas extends Static {
}
/**
- * Returns the radius of the conformal sphere (assuming a semi-major axis
length of 1) at a given latitude.
+ * Returns the radius of the conformal sphere at a given latitude.
* The radius of conformal sphere is computed as below:
*
* <blockquote>Rc = √(1 – ℯ²) / (1 – ℯ²sin²φ) where ℯ² = 1 -
(b/a)²</blockquote>
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
index b860114..c613410 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
@@ -57,7 +57,7 @@ public class AzimuthalEquidistant extends
NormalizedProjection {
/**
* Sine and cosine of the latitude of origin φ₀.
*/
- private final double sinφ0, cosφ0;
+ final double sinφ0, cosφ0;
/**
* Work around for RFE #4093999 in Sun's bug database
@@ -89,11 +89,11 @@ public class AzimuthalEquidistant extends
NormalizedProjection {
}
/**
- * Work around for RFE #4093999 in Sun's bug database
- * ("Relax constraint on placement of this()/super() call in
constructors").
+ * Creates a new normalized projection from the parameters computed by the
given initializer.
+ *
+ * @param initializer the initializer for computing map projection
internal parameters.
*/
- @Workaround(library="JDK", version="1.8")
- private AzimuthalEquidistant(final Initializer initializer) {
+ AzimuthalEquidistant(final Initializer initializer) {
super(initializer);
final double φ0 =
toRadians(initializer.getAndStore(LATITUDE_OF_ORIGIN));
cosφ0 = cos(φ0);
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
index daf94fd..b957554 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
@@ -51,16 +51,11 @@ import static
org.apache.sis.internal.referencing.provider.ModifiedAzimuthalEqui
* @since 1.1
* @module
*/
-public class ModifiedAzimuthalEquidistant extends NormalizedProjection {
+public class ModifiedAzimuthalEquidistant extends AzimuthalEquidistant {
/**
* For compatibility with different versions during deserialization.
*/
- private static final long serialVersionUID = -5394894530514589924L;
-
- /**
- * Sine and cosine of the latitude of origin φ₀.
- */
- private final double sinφ0, cosφ0;
+ private static final long serialVersionUID = 96569177715708509L;
/**
* A term involving radius of curvature ν₀, the latitude of origin φ₀ and
the eccentricity.
@@ -123,10 +118,7 @@ public class ModifiedAzimuthalEquidistant extends
NormalizedProjection {
@Workaround(library="JDK", version="1.8")
private ModifiedAzimuthalEquidistant(final Initializer initializer) {
super(initializer);
- final double φ0, ν0, f;
- φ0 = toRadians(initializer.getAndStore(LATITUDE_OF_ORIGIN));
- cosφ0 = cos(φ0);
- sinφ0 = sin(φ0);
+ final double ν0, f;
ν0 = initializer.radiusOfCurvature(sinφ0);
ℯ2_ν0_sinφ0 = eccentricitySquared * ν0 * sinφ0;
f = eccentricity / sqrt(1 - eccentricitySquared);
diff --git
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistantTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistantTest.java
index b2f071f..717eb29 100644
---
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistantTest.java
+++
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistantTest.java
@@ -41,7 +41,7 @@ public strictfp class AzimuthalEquidistantTest extends
MapProjectionTestCase {
}
/**
- * Tests the forward projection using test point given in Snyder page 337.
+ * Tests the forward and inverse projection using test point given in
Snyder page 337.
* The Snyder's test uses a sphere of radius R=3 and a center at 40°N and
100°W.
* The test in this class modify the longitude to 10°W for avoiding to mix
wraparound
* considerations in this test.
@@ -73,16 +73,34 @@ public strictfp class AzimuthalEquidistantTest extends
MapProjectionTestCase {
}
/**
- * Tests the point published in EPSG guidance note.
+ * Tests with the point published in EPSG guidance note.
*
* @throws FactoryException if an error occurred while creating the
projection.
* @throws TransformException if an error occurred while projecting the
test point.
*/
@Test
- public void testEPSGPoint() throws FactoryException, TransformException {
+ public void testWithEPSG() throws FactoryException, TransformException {
+ /*
+ * Since we are testing spherical formulas with a sample point
calculated
+ * for ellipsoidal formulas, we have to use a high tolerance threshold.
+ */
+ tolerance = 20;
+ testWithEPSG(CLARKE_A, CLARKE_B);
+ }
+
+ /**
+ * Tests with the point published in EPSG guidance note.
+ * Callers must set {@link #tolerance} before to invoke this method.
+ *
+ * @param semiMajor {@link #CLARKE_A}, or an alternative value if desired.
+ * @param semiMinor {@link #CLARKE_B}, or an alternative value if desired.
+ * @throws FactoryException if an error occurred while creating the
projection.
+ * @throws TransformException if an error occurred while projecting the
test point.
+ */
+ final void testWithEPSG(final double semiMajor, final double semiMinor)
throws FactoryException, TransformException {
createCompleteProjection(method(),
- CLARKE_A, // Semi-major axis (Clarke
1866)
- CLARKE_B, // Semi-minor axis
+ semiMajor,
+ semiMinor,
138 + (10 + 7.48/60)/60, // Longitude of natural origin
(central-meridian)
9 + (32 + 48.15/60)/60, // Latitude of natural origin
Double.NaN, // Standard parallel 1
@@ -90,11 +108,7 @@ public strictfp class AzimuthalEquidistantTest extends
MapProjectionTestCase {
Double.NaN, // Scale factor
40000, // False easting
60000); // False Northing
- /*
- * Since we are testing spherical formulas with a sample point
calculated
- * for ellipsoidal formulas, we have to use a high tolerance threshold.
- */
- tolerance = 20;
+
verifyTransform(new double[] {
138 + (11 + 34.908/60)/60, // 138°11'34.908"E
9 + (35 + 47.493/60)/60 // 9°35'47.493"N
diff --git
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
index f131653..1001168 100644
---
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
+++
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistantTest.java
@@ -16,8 +16,9 @@
*/
package org.apache.sis.referencing.operation.projection;
-import org.opengis.referencing.operation.TransformException;
import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.referencing.provider.MapProjection;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -31,7 +32,43 @@ import org.junit.Test;
* @module
*/
@DependsOn(NormalizedProjectionTest.class)
-public final strictfp class ModifiedAzimuthalEquidistantTest extends
MapProjectionTestCase {
+public final strictfp class ModifiedAzimuthalEquidistantTest extends
AzimuthalEquidistantTest {
+ /**
+ * Returns the method to be tested.
+ */
+ @Override
+ MapProjection method() {
+ return new
org.apache.sis.internal.referencing.provider.ModifiedAzimuthalEquidistant();
+ }
+
+ /**
+ * Tests the projection on a sphere. We override the method provides in
parent class
+ * because the point provided in Snyder is too far from projection centre.
+ *
+ * @throws FactoryException if an error occurred while creating the
projection.
+ * @throws TransformException if an error occurred while projecting the
test point.
+ */
+ @Test
+ @Override
+ public void testSpherical() throws FactoryException, TransformException {
+ tolerance = 20; // Same tolerance than in parent
class.
+ final double r = 6357767.51; // Conformal sphere radius at the
latitude being tested.
+ testWithEPSG(r, r);
+ }
+
+ /**
+ * Tests with the point published in EPSG guidance note.
+ *
+ * @throws FactoryException if an error occurred while creating the
projection.
+ * @throws TransformException if an error occurred while projecting the
test point.
+ */
+ @Test
+ @Override
+ public void testWithEPSG() throws FactoryException, TransformException {
+ tolerance = 0.01;
+ testWithEPSG(CLARKE_A, CLARKE_B);
+ }
+
/**
* Tests the <cite>"Modified Azimuthal Equidistant"</cite> (EPSG:9832)
projection method.
* This test is defined in GeoAPI conformance test suite.
@@ -44,7 +81,6 @@ public final strictfp class ModifiedAzimuthalEquidistantTest
extends MapProjecti
@Test
@org.junit.Ignore("Implementation not yet completed")
public void runGeoapiTest() throws FactoryException, TransformException {
- createGeoApiTest(new
org.apache.sis.internal.referencing.provider.ModifiedAzimuthalEquidistant())
- .testModifiedAzimuthalEquidistant();
+ createGeoApiTest(method()).testModifiedAzimuthalEquidistant();
}
}