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 f537ce2 Fix an error in the determination of parameter values for inverse of "Rotated North Pole". f537ce2 is described below commit f537ce2961ac0d350b6dc4ad1aa7fa8cae458645 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sat Jan 29 23:19:51 2022 +0100 Fix an error in the determination of parameter values for inverse of "Rotated North Pole". --- .../operation/transform/RotatedPole.java | 2 +- .../operation/transform/RotatedPoleTest.java | 30 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) 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 cd5a385..9a39db9 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 @@ -154,7 +154,7 @@ public class RotatedPole extends AbstractMathTransform2D implements Serializable i = 3 - i; } double value = -((Number) ((ParameterValue<?>) values.get(i)).getValue()).doubleValue(); - if (i == 0 && RotatedSouthPole.PARAMETERS.equals(forward.getDescriptor())) { + if (i == 0) { value = IEEEremainder(value + 180, 360); } target.setValue(value); 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 7072333..8320148 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 @@ -65,7 +65,7 @@ public final strictfp class RotatedPoleTest extends MathTransformTestCase { */ private void inverseNorthPoleTransform() throws FactoryException, TransformException { final ParameterValueGroup pg = ((Parameterized) transform.inverse()).getParameterValues(); - transform = RotatedPole.rotateSouthPole(factory(), + transform = RotatedPole.rotateNorthPole(factory(), pg.parameter("grid_north_pole_latitude") .doubleValue(), pg.parameter("grid_north_pole_longitude").doubleValue(), pg.parameter("north_pole_grid_longitude").doubleValue()); @@ -135,7 +135,7 @@ public final strictfp class RotatedPoleTest extends MathTransformTestCase { * @throws TransformException if an error occurred while transforming a point. */ @Test - public void testRotateToOppositeHemisphere() throws FactoryException, TransformException { + public void testRotateSouthToOppositeHemisphere() throws FactoryException, TransformException { transform = RotatedPole.rotateSouthPole(factory(), 50, 20, 10); tolerance = Formulas.ANGULAR_TOLERANCE; isDerivativeSupported = false; @@ -221,4 +221,30 @@ public final strictfp class RotatedPoleTest extends MathTransformTestCase { inverseNorthPoleTransform(); verifyTransform(expected, coordinates); } + + /** + * Tries rotating a pole to opposite hemisphere. + * + * @throws FactoryException if the transform can not be created. + * @throws TransformException if an error occurred while transforming a point. + */ + @Test + public void testRotateNorthToOppositeHemisphere() throws FactoryException, TransformException { + transform = RotatedPole.rotateNorthPole(factory(), -50, 20, 10); + tolerance = Formulas.ANGULAR_TOLERANCE; + isDerivativeSupported = false; + final double[] coordinates = { // (λ,φ) coordinates to convert. + 20, -51, + 80, -44, + -30, -89 + }; + final double[] expected = { // (λ,φ) coordinates after conversion. + -10.000000000, 89.000000000, + 64.651211252, 49.758697265, + -11.207848626, 50.636582758 + }; + verifyTransform(coordinates, expected); + inverseNorthPoleTransform(); + verifyTransform(expected, coordinates); + } }