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

jsorel 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 aefe5d2936 Add getContentPath() method on Tile to allow access to the 
raw tile content without opening a resource
aefe5d2936 is described below

commit aefe5d29369623af9bd6992250d7c0986c53238b
Author: jsorel <johann.so...@geomatys.com>
AuthorDate: Thu Apr 24 11:52:48 2025 +0200

    Add getContentPath() method on Tile to allow access to the raw tile content 
without opening a resource
---
 .../main/org/apache/sis/storage/tiling/Tile.java   | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/tiling/Tile.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/tiling/Tile.java
index b63b4888f0..0b3f8cdd23 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/tiling/Tile.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/tiling/Tile.java
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.storage.tiling;
 
+import java.nio.file.Path;
+import java.util.Collection;
 import java.util.Optional;
 import org.opengis.metadata.Metadata;
 import org.apache.sis.coverage.grid.GridExtent;
@@ -108,4 +110,26 @@ public interface Tile {
      * @throws DataStoreException if an error occurred while reading the 
content.
      */
     Resource getResource() throws DataStoreException;
+
+    /**
+     * Returns the tile content as a {@link Path} instance.
+     * Tiles are usually small chunks of raw data which are forwarded to a 
displaying
+     * device or processing unit.
+     * Unlike the {@linkplain #getResource()} method this method
+     * should return the unprocessed data quickly.
+     *
+     * <p>Default implementation fallback on the  {@linkplain #getResource()} 
method
+     * and returns the first path from the  {@linkplain #getFileSet()} 
method</p>
+     *
+     * @return tile content or empty
+     * @throws DataStoreException if an error occurred while returning the 
content.
+     */
+    default Optional<Path> getContentPath() throws DataStoreException {
+        final Resource resource = getResource();
+        final Optional<Resource.FileSet> opt = resource.getFileSet();
+        if (opt.isEmpty()) return Optional.empty();
+        final Collection<Path> paths = opt.get().getPaths();
+        if (paths.isEmpty()) return Optional.empty();
+        return Optional.of(paths.iterator().next());
+    }
 }

Reply via email to