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 ed1a0e5c2e398a0c757b5323c5e5c366519e0fc5
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Mon Aug 22 10:08:58 2022 +0200

    Add a test case provided by Michael about wraparound issue.
---
 .../test/integration/CoordinateOperationTest.java  | 32 +++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/CoordinateOperationTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/CoordinateOperationTest.java
index faa7d6c7e8..2f8698a24e 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/CoordinateOperationTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/CoordinateOperationTest.java
@@ -50,7 +50,8 @@ import static org.apache.sis.test.Assert.*;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Olivier Lhemann (OSDU)
- * @version 1.1
+ * @author  Michael Arneson (OSDU)
+ * @version 1.3
  * @since   0.8
  * @module
  */
@@ -227,4 +228,33 @@ public final strictfp class CoordinateOperationTest 
extends MathTransformTestCas
         assertEquals("x", expectedX, coordinate[0], 0.01);
         assertEquals("y", expectedY, coordinate[1], 0.01);
     }
+
+    /**
+     * Tests a Mercator projection that require wraparound of longitude values.
+     *
+     * @throws FactoryException if an error occurred while creating a test CRS.
+     * @throws TransformException if an error occurred while testing a 
coordinate conversion.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-547";>SIS-547 on 
issue tracker</a>
+     */
+    @Test
+    public void testMercatorWraparound() throws FactoryException, 
TransformException {
+        CRSAuthorityFactory crsFactory = CRS.getAuthorityFactory("EPSG");
+        assumeTrue("EPSG authority factory is required for this test.",
+                   crsFactory instanceof CoordinateOperationAuthorityFactory);
+
+        CoordinateReferenceSystem sourceCRS = 
crsFactory.createCoordinateReferenceSystem("3001");
+        CoordinateReferenceSystem targetCRS = 
crsFactory.createCoordinateReferenceSystem("4211");
+
+        CoordinateOperation operation = opFactory.createOperation(sourceCRS, 
targetCRS);
+        MathTransform transform = operation.getMathTransform();
+
+        double[] expectedXyValues = new double[] {-2.0, -71.0};
+        double[] sourceXyValues   = new double[] {23764105.84, 679490.646};
+        double[] actualXyValues   = new double[2];
+
+        transform.transform(sourceXyValues, 0, actualXyValues, 0, 1);
+        assertEquals("x", expectedXyValues[0], actualXyValues[0], 6E-7);
+        assertEquals("y", expectedXyValues[1], actualXyValues[1], 6E-7);
+    }
 }

Reply via email to