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 372de6b8ce5a7d291b275a3fbe8a7e2e176489d5
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Tue Feb 25 19:47:54 2025 +0100

    Make possible to handle tiles that are not created by 
`TiledGridCoverage.Iterator` itself.
---
 .../apache/sis/storage/base/TiledGridCoverage.java  | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
index 2a1ec30e29..f5604cfb34 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
@@ -746,6 +746,27 @@ public abstract class TiledGridCoverage extends 
GridCoverage {
             return Raster.createWritableRaster(getCoverage().model, new 
Point(x, y));
         }
 
+        /**
+         * Returns the given raster relocated at the current <abbr>AOI</abbr> 
position.
+         * This method does not need to be invoked for tiles created by {@link 
#createRaster()},
+         * but may need to be invoked for tiles created in a different way.
+         * If the given raster is already at the current <abbr>AOI</abbr> 
position,
+         * then this method returns that raster directly.
+         *
+         * @param  raster  the raster to move at the current <abbr>AOI</abbr> 
position.
+         * @return the relocated raster (may be {@code raster} itself).
+         *
+         * @see Raster#createTranslatedChild(int, int)
+         */
+        public Raster moveRaster(final Raster raster) {
+            final int x = getTileOrigin(X_DIMENSION);
+            final int y = getTileOrigin(Y_DIMENSION);
+            if (raster.getMinX() == x && raster.getMinY() == y) {
+                return raster;
+            }
+            return raster.createTranslatedChild(x, y);
+        }
+
         /**
          * Returns the location (relative to the cropped tile) of the 
upper-left corner of the uncropped tile.
          * This value should be present only when reading an image made of a 
single potentially huge tile,

Reply via email to