You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/09/07 14:23:28 UTC

[sis] branch geoapi-4.0 updated (866e380 -> 4fbf175)

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.


 discard 866e380  Add a `GridGeometry.createTransformTo(GridGeometry target)` method.
     new 4fbf175  Add a `GridGeometry.createTransformTo(GridGeometry target)` method.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (866e380)
            \
             N -- N -- N   refs/heads/geoapi-4.0 (4fbf175)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/java/org/apache/sis/coverage/grid/GridGeometry.java        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[sis] 01/01: Add a `GridGeometry.createTransformTo(GridGeometry target)` method.

Posted by de...@apache.org.
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 4fbf17573db815cddca706bdf354e2a70f2a7eab
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Sep 7 16:17:16 2020 +0200

    Add a `GridGeometry.createTransformTo(GridGeometry target)` method.
---
 .../org/apache/sis/coverage/grid/GridGeometry.java | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

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 bd89b61..f632c4c 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
@@ -1199,6 +1199,35 @@ public class GridGeometry implements LenientComparable, Serializable {
     }
 
     /**
+     * Creates a transform from cell coordinates in this grid to cell coordinates in the given grid.
+     * The returned transform handles change of Coordinate Reference System and wraparound axes
+     * (e.g. longitude axis crossing the ±180° meridian) if applicable.
+     *
+     * <p><b>Note:</b> the transform created by this method may be non-invertible.</p>
+     *
+     * @param  target  the grid which will be the target of returned transform.
+     * @param  anchor  {@linkplain PixelInCell#CELL_CENTER Cell center} for OGC conventions or
+     *                 {@linkplain PixelInCell#CELL_CORNER cell corner} for Java2D/JAI conventions.
+     * @return transform from cell coordinates in this grid to cell coordinates in the given grid.
+     * @throws TransformException if the math transform can not be created.
+     *
+     * @since 1.1
+     */
+    public MathTransform createTransformTo(final GridGeometry target, final PixelInCell anchor) throws TransformException {
+        ArgumentChecks.ensureNonNull("target", target);
+        ArgumentChecks.ensureNonNull("anchor", anchor);
+        final CoordinateOperationFinder finder = new CoordinateOperationFinder(target, this);
+        MathTransform tr;
+        try {
+            tr = finder.gridToCRS(anchor);
+            tr = finder.inverse(tr);
+        } catch (FactoryException e) {
+            throw new TransformException(e);
+        }
+        return MathTransforms.concatenate(tr, target.getGridToCRS(anchor).inverse());
+    }
+
+    /**
      * Returns a hash value for this grid geometry. This value needs not to remain
      * consistent between different implementations of the same class.
      */