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 f4fa0fbdc29c033fe3ec6dfa6d07b618d4676d59
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Jan 28 22:03:57 2022 +0100

    Parameter in traditional order for factory methods.
    The `transform(…)` methods keep the "internal" order.
---
 .../referencing/provider/RotatedNorthPole.java     |  2 +-
 .../referencing/provider/RotatedSouthPole.java     |  2 +-
 .../operation/transform/RotatedPole.java           | 67 +++++++++++-----------
 .../operation/transform/RotatedPoleTest.java       |  7 +--
 4 files changed, 40 insertions(+), 38 deletions(-)

diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedNorthPole.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedNorthPole.java
index 22b2ae9..e338bea 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedNorthPole.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedNorthPole.java
@@ -143,8 +143,8 @@ public final class RotatedNorthPole extends 
AbstractProvider {
     {
         final Parameters p = Parameters.castOrWrap(parameters);
         return RotatedPole.rotateNorthPole(factory,
-                p.getValue(GRID_POLE_LONGITUDE),
                 p.getValue(GRID_POLE_LATITUDE),
+                p.getValue(GRID_POLE_LONGITUDE),
                 p.getValue(GRID_POLE_ANGLE));
     }
 }
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedSouthPole.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedSouthPole.java
index 734e4b2..b485905 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedSouthPole.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RotatedSouthPole.java
@@ -147,8 +147,8 @@ public final class RotatedSouthPole extends 
AbstractProvider {
     {
         final Parameters p = Parameters.castOrWrap(parameters);
         return RotatedPole.rotateSouthPole(factory,
-                p.getValue(GRID_POLE_LONGITUDE),
                 p.getValue(GRID_POLE_LATITUDE),
+                p.getValue(GRID_POLE_LONGITUDE),
                 p.getValue(GRID_POLE_ANGLE));
     }
 }
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/RotatedPole.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/RotatedPole.java
index 5b19036..fb826dd 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/RotatedPole.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/RotatedPole.java
@@ -51,20 +51,22 @@ import static java.lang.Math.*;
  * <a href="https://www.wmo.int/";>World Meteorological Organization</a> (WMO):
  *
  * <ol>
+ *   <li><b>φ<sub>p</sub>:</b> geographic  latitude in degrees of the southern 
pole of the coordinate system.</li>
  *   <li><b>λ<sub>p</sub>:</b> geographic longitude in degrees of the southern 
pole of the coordinate system.</li>
- *   <li><b>θ<sub>p</sub>:</b> geographic  latitude in degrees of the southern 
pole of the coordinate system.</li>
  *   <li>Angle of rotation in degrees about the new polar axis measured 
clockwise when looking from the southern
  *       to the northern pole.</li>
  * </ol>
  *
  * The rotations are applied by first rotating the sphere through 
λ<sub>p</sub> about the geographic polar axis,
- * and then rotating through (θ<sub>p</sub> − (−90°)) degrees so that the 
southern pole moved along the
+ * and then rotating through (φ<sub>p</sub> − (−90°)) degrees so that the 
southern pole moved along the
  * (previously rotated) Greenwich meridian.
  *
- * <p>Source and target axis order is (<var>longitude</var>, 
<var>latitude</var>).
- * This is the usual axis order used by Apache SIS for <em>internal</em> 
calculations.
+ * <h2>Coordinate order</h2>
+ * Source and target axis order in {@code transform(…)} methods is 
(<var>longitude</var>, <var>latitude</var>).
+ * This is the usual axis order used by Apache SIS for <em>internal</em> 
calculations
+ * (but not the <em>parameter</em> order in factory methods).
  * If a different axis order is desired (for example for showing coordinates 
to the user),
- * an affine transform can be concatenated to this transform.</p>
+ * an affine transform can be concatenated to this transform.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.2
@@ -87,25 +89,25 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
 
     /**
      * Sine and cosine of the geographic latitude of the southern pole of the 
coordinate system.
-     * The rotation angle to apply is (θ<sub>p</sub> − (−90°)) degrees for the 
south pole (−90°),
+     * The rotation angle to apply is (φ<sub>p</sub> − (−90°)) degrees for the 
south pole (−90°),
      * but we use the following trigonometric identities:
      *
      * <p>For the south pole:</p>
      * <ul>
-     *   <li>sin(θ + 90°) =  cos(θ)</li>
-     *   <li>cos(θ + 90°) = −sin(θ)</li>
+     *   <li>sin(φ + 90°) =  cos(φ)</li>
+     *   <li>cos(φ + 90°) = −sin(φ)</li>
      * </ul>
      *
      * <p>For the north pole:</p>
      * <ul>
-     *   <li>sin(θ − 90°) = −cos(θ)</li>
-     *   <li>cos(θ − 90°) =  sin(θ)</li>
+     *   <li>sin(φ − 90°) = −cos(φ)</li>
+     *   <li>cos(φ − 90°) =  sin(φ)</li>
      * </ul>
      *
      * By convention those fields contain the sine and cosine for the south 
pole case,
      * and values with opposite sign for the north pole case.
      */
-    private final double sinθp, cosθp;
+    private final double sinφp, cosφp;
 
     /**
      * The inverse of this operation, computed when first needed.
@@ -121,8 +123,8 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
      */
     private RotatedPole(final RotatedPole forward) {
         context =  forward.context.inverse(forward.context.getDescriptor(), 
RotatedPole::inverseParameter);
-        sinθp   =  forward.sinθp;
-        cosθp   = -forward.cosθp;
+        sinφp   =  forward.sinφp;
+        cosφp   = -forward.cosφp;
         inverse =  forward;
     }
 
@@ -162,22 +164,22 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
      * For a complete transform, use one of the static factory methods.
      *
      * @param  south  {@code true} for a south pole rotation, or {@code false} 
for a north pole rotation.
+     * @param  φp     geographic  latitude in degrees of the southern pole of 
the coordinate system.
      * @param  λp     geographic longitude in degrees of the southern pole of 
the coordinate system.
-     * @param  θp     geographic latitude in degrees of the southern pole of 
the coordinate system.
      * @param  pa     angle of rotation in degrees about the new polar axis 
measured clockwise when
      *                looking from the southern to the northern pole.
      */
-    protected RotatedPole(final boolean south, double λp, double θp, double 
pa) {
+    protected RotatedPole(final boolean south, double φp, double λp, double 
pa) {
         context = new ContextualParameters(
                 south ? RotatedSouthPole.PARAMETERS
                       : RotatedNorthPole.PARAMETERS, 2, 2);
-        setValue(0, θp);        // grid_south_pole_latitude   or  
grid_north_pole_latitude
+        setValue(0, φp);        // grid_south_pole_latitude   or  
grid_north_pole_latitude
         setValue(1, λp);        // grid_south_pole_longitude  or  
grid_north_pole_longitude
         setValue(2, pa);        // grid_south_pole_angle      or  
north_pole_grid_longitude
-        final double θ = toRadians(θp);
+        final double φ = toRadians(φp);
         final double sign = south ? 1 : -1;
-        sinθp = sin(θ) * sign;
-        cosθp = cos(θ) * sign;
+        sinφp = sin(φ) * sign;
+        cosφp = cos(φ) * sign;
         context.normalizeGeographicInputs(λp);
         context.denormalizeGeographicOutputs(-pa);
     }
@@ -198,17 +200,17 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
      * Creates a new rotated south pole operation.
      *
      * @param  factory  the factory to use for creating the transform.
+     * @param  φp       geographic  latitude in degrees of the southern pole 
of the coordinate system.
      * @param  λp       geographic longitude in degrees of the southern pole 
of the coordinate system.
-     * @param  θp       geographic latitude in degrees of the southern pole of 
the coordinate system.
      * @param  pa       angle of rotation in degrees about the new polar axis 
measured clockwise when
      *                  looking from the southern to the northern pole.
      * @return the conversion doing a south pole rotation.
      * @throws FactoryException if an error occurred while creating a 
transform.
      */
     public static MathTransform rotateSouthPole(final MathTransformFactory 
factory,
-            final double λp, final double θp, final double pa) throws 
FactoryException
+            final double φp, final double λp, final double pa) throws 
FactoryException
     {
-        final RotatedPole kernel = new RotatedPole(true, λp, θp, pa);
+        final RotatedPole kernel = new RotatedPole(true, φp, λp, pa);
         return kernel.context.completeTransform(factory, kernel);
     }
 
@@ -216,17 +218,17 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
      * Creates a new rotated north pole operation.
      *
      * @param  factory  the factory to use for creating the transform.
+     * @param  φp       geographic  latitude in degrees of the northern pole 
of the coordinate system.
      * @param  λp       geographic longitude in degrees of the northern pole 
of the coordinate system.
-     * @param  θp       geographic latitude in degrees of the northern pole of 
the coordinate system.
      * @param  pa       angle of rotation in degrees about the new polar axis 
measured clockwise when
      *                  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.
      */
     public static MathTransform rotateNorthPole(final MathTransformFactory 
factory,
-            final double λp, final double θp, final double pa) throws 
FactoryException
+            final double φp, final double λp, final double pa) throws 
FactoryException
     {
-        final RotatedPole kernel = new RotatedPole(false, λp, θp, pa);
+        final RotatedPole kernel = new RotatedPole(false, φp, λp, pa);
         return kernel.context.completeTransform(factory, kernel);
     }
 
@@ -279,6 +281,7 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
     /**
      * Transforms a single coordinate point in an array,
      * and optionally computes the transform derivative at that location.
+     * Source and target axis order is (<var>longitude</var>, 
<var>latitude</var>).
      */
     @Override
     public Matrix transform(final double[] srcPts, final int srcOff,
@@ -301,8 +304,8 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
          * Apply the rotation around Y axis (so the y value stay unchanged)
          * and convert back to spherical coordinates.
          */
-        double xr =  cosθp * z - sinθp * x;
-        double zr = -cosθp * x - sinθp * z;
+        double xr =  cosφp * z - sinφp * x;
+        double zr = -cosφp * x - sinφp * z;
         double R  = sqrt(xr*xr + y*y);          // The slower hypot(…) is not 
needed because values are close to 1.
         dstPts[dstOff]   = atan2(y, xr);
         dstPts[dstOff+1] = atan2(zr, R);
@@ -337,11 +340,11 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
         if (super.equals(object, mode)) {
             final RotatedPole other = (RotatedPole) object;
             if (mode.isApproximate()) {
-                return Numerics.epsilonEqual(sinθp, other.sinθp, 
Formulas.ANGULAR_TOLERANCE * (PI/180)) &&
-                       Numerics.epsilonEqual(cosθp, other.cosθp, 
Formulas.ANGULAR_TOLERANCE * (PI/180));
+                return Numerics.epsilonEqual(sinφp, other.sinφp, 
Formulas.ANGULAR_TOLERANCE * (PI/180)) &&
+                       Numerics.epsilonEqual(cosφp, other.cosφp, 
Formulas.ANGULAR_TOLERANCE * (PI/180));
             } else {
-                return Numerics.equals(sinθp, other.sinθp) &&
-                       Numerics.equals(cosθp, other.cosθp);
+                return Numerics.equals(sinφp, other.sinφp) &&
+                       Numerics.equals(cosφp, other.cosφp);
             }
         }
         return false;
@@ -352,6 +355,6 @@ public class RotatedPole extends AbstractMathTransform2D 
implements Serializable
      */
     @Override
     protected int computeHashCode() {
-        return super.computeHashCode() + Double.hashCode(cosθp) + 
Double.hashCode(sinθp);
+        return super.computeHashCode() + Double.hashCode(cosφp) + 
Double.hashCode(sinφp);
     }
 }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RotatedPoleTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RotatedPoleTest.java
index 8cca70c..6764670 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RotatedPoleTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RotatedPoleTest.java
@@ -53,10 +53,9 @@ public final strictfp class RotatedPoleTest extends 
MathTransformTestCase {
     private void inverseSouthPoleTransform() throws FactoryException, 
TransformException {
         final ParameterValueGroup pg = ((Parameterized) 
transform.inverse()).getParameterValues();
         transform = RotatedPole.rotateSouthPole(factory(),
-                pg.parameter("grid_south_pole_longitude").doubleValue(),
                 pg.parameter("grid_south_pole_latitude") .doubleValue(),
+                pg.parameter("grid_south_pole_longitude").doubleValue(),
                 pg.parameter("grid_south_pole_angle")    .doubleValue());
-
     }
 
     /**
@@ -69,7 +68,7 @@ public final strictfp class RotatedPoleTest extends 
MathTransformTestCase {
      */
     @Test
     public void testRotateSouthPoleOnGreenwich() throws FactoryException, 
TransformException {
-        transform = RotatedPole.rotateSouthPole(factory(), 0, -60, 0);
+        transform = RotatedPole.rotateSouthPole(factory(), -60, 0, 0);
         tolerance = Formulas.ANGULAR_TOLERANCE;
         isDerivativeSupported = false;
         final double[] coordinates = {      // (λ,φ) coordinates to convert.
@@ -98,7 +97,7 @@ public final strictfp class RotatedPoleTest extends 
MathTransformTestCase {
     @Test
     @DependsOnMethod("testRotateSouthPoleOnGreenwich")
     public void testRotateSouthPoleWithAngle() throws FactoryException, 
TransformException {
-        transform = RotatedPole.rotateSouthPole(factory(), 20, -50, 10);
+        transform = RotatedPole.rotateSouthPole(factory(), -50, 20, 10);
         tolerance = Formulas.ANGULAR_TOLERANCE;
         isDerivativeSupported = false;
         final double[] coordinates = {      // (λ,φ) coordinates to convert.

Reply via email to