sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: GridGeometry.createTransformTo(…) was not concatenating the right transform.
Date Mon, 14 Sep 2020 11:12:35 GMT
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 da1d008  GridGeometry.createTransformTo(…) was not concatenating the right transform.
da1d008 is described below

commit da1d0081ae4e34ecc54a8603ac1015bf060e72b1
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Sep 14 13:10:54 2020 +0200

    GridGeometry.createTransformTo(…) was not concatenating the right transform.
---
 .../org/apache/sis/coverage/grid/GridGeometry.java |  2 +-
 .../apache/sis/coverage/grid/GridGeometryTest.java | 32 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
index f632c4c..0823ead 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
@@ -1224,7 +1224,7 @@ public class GridGeometry implements LenientComparable, Serializable
{
         } catch (FactoryException e) {
             throw new TransformException(e);
         }
-        return MathTransforms.concatenate(tr, target.getGridToCRS(anchor).inverse());
+        return MathTransforms.concatenate(getGridToCRS(anchor), tr);
     }
 
     /**
diff --git a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
index f650086..b44427e 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
@@ -348,4 +348,36 @@ public final strictfp class GridGeometryTest extends TestCase {
         //              0,   0,     3,  // All scale coefficients set to 0.
                         0,   0,     1), MathTransforms.getMatrix(tr), STRICT);
     }
+
+    /**
+     * Tests {@link GridGeometry#createTransformTo(GridGeometry, PixelInCell)}.
+     *
+     * @throws TransformException if the transform can not be computed.
+     */
+    @Test
+    public void testCreateTransformTo() throws TransformException {
+        final GridGeometry source = new GridGeometry(
+                new GridExtent(17, 10),
+                PixelInCell.CELL_CENTER,
+                MathTransforms.linear(new Matrix3(
+                    1,   0,  -7.0,
+                    0,  -1,  50.0,
+                    0,   0,   1)),
+                HardCodedCRS.WGS84);
+
+        final GridGeometry target = new GridGeometry(
+                new GridExtent(200, 300),
+                PixelInCell.CELL_CENTER,
+                MathTransforms.linear(new Matrix3(
+                   -0.05,  0,    53.0,
+                    0,     0.1,  -8.0,
+                    0,     0,     1)),
+                HardCodedCRS.WGS84_φλ);
+
+        final MathTransform tr = source.createTransformTo(target, PixelInCell.CELL_CENTER);
+        assertMatrixEquals("createTransformTo", new Matrix3(
+                    0,  20,  60,
+                   10,   0,  10,
+                    0,   0,   1), MathTransforms.getMatrix(tr), STRICT);
+    }
 }


Mime
View raw message