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

commit fa203febfbdea627bf58a55285633c18cb700226
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Tue Feb 1 18:40:09 2022 +0100

    Temporary disallow non-zero axis rotation for the "North pole rotation" 
case,
    until we resolved an ambiguity about the sign of this rotation angle.
---
 .../sis/referencing/operation/transform/PoleRotation.java |  8 ++++++++
 .../referencing/operation/transform/PoleRotationTest.java | 15 ++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java
index d147032..0674050 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java
@@ -233,10 +233,18 @@ public class PoleRotation extends AbstractMathTransform2D 
implements Serializabl
      *                  looking from the northern to the southern pole.
      * @return the conversion doing a north pole rotation.
      * @throws FactoryException if an error occurred while creating a 
transform.
+     *
+     * @todo Current implementation does not accept non-zero {@code pa} 
argument value,
+     *       because we have not yet resolved an ambiguity about the sign of 
this parameter.
+     *       Should it be a rotation clockwise or anti-clockwise? Looking from 
northern to
+     *       southern pole or the opposite direction?
      */
     public static MathTransform rotateNorthPole(final MathTransformFactory 
factory,
             final double φp, final double λp, final double pa) throws 
FactoryException
     {
+        if (pa != 0) {
+            throw new IllegalArgumentException("Non-zero axis rotation not yet 
accepted.");
+        }
         final PoleRotation kernel = new PoleRotation(false, φp, λp, pa);
         return kernel.context.completeTransform(factory, kernel);
     }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java
index 62f1894..15bb190 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java
@@ -72,7 +72,7 @@ public final strictfp class PoleRotationTest extends 
MathTransformTestCase {
      */
     private void inverseNorthPoleTransform() throws FactoryException, 
TransformException {
         final ParameterValueGroup pg = ((Parameterized) 
transform.inverse()).getParameterValues();
-        transform = PoleRotation.rotateNorthPole(factory(),
+        rotateNorthPole(
                 pg.parameter("grid_north_pole_latitude") .doubleValue(),
                 pg.parameter("grid_north_pole_longitude").doubleValue(),
                 pg.parameter("north_pole_grid_longitude").doubleValue());
@@ -187,6 +187,15 @@ public final strictfp class PoleRotationTest extends 
MathTransformTestCase {
     }
 
     /**
+     * Temporary workaround for {@code PoleRotation.rotateNorthPole(…)} which 
does not accept
+     * non-zero {@code pa} argument. To be deleted after we resolved the sign 
ambiguity.
+     */
+    private void rotateNorthPole(final double φp, final double λp, final 
double pa) throws FactoryException {
+        final PoleRotation kernel = new PoleRotation(false, φp, λp, pa);
+        transform = 
kernel.getContextualParameters().completeTransform(factory(), kernel);
+    }
+
+    /**
      * Tests a rotation of north pole with the pole on arbitrary meridian.
      * Result can be compared with PROJ using the following command, where
      * {@code coords.txt} is a file containing input coordinates in (λ,φ)
@@ -203,7 +212,7 @@ public final strictfp class PoleRotationTest extends 
MathTransformTestCase {
     @Test
     @DependsOnMethod("testRotateNorthPoleOnGreenwich")
     public void testRotateNorthPole() throws FactoryException, 
TransformException {
-        transform = PoleRotation.rotateNorthPole(factory(), 70, 40, 10);
+        rotateNorthPole(70, 40, 10);
         final double[] coordinates = {      // (λ,φ) coordinates to convert.
              0, 54,
             20, 62,
@@ -227,7 +236,7 @@ public final strictfp class PoleRotationTest extends 
MathTransformTestCase {
      */
     @Test
     public void testRotateNorthToOppositeHemisphere() throws FactoryException, 
TransformException {
-        transform = PoleRotation.rotateNorthPole(factory(), -50, 20, -10);
+        rotateNorthPole(-50, 20, -10);
         final double[] coordinates = {      // (λ,φ) coordinates to convert.
              20, -51,
              80, -44,

Reply via email to