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 2021/09/22 16:26:06 UTC

[sis] 01/07: Move `RasterLoadingStrategy` to public API.

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 7485605ecd9697c4e80d4c0ecdb5741cc3053746
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Sep 22 13:56:57 2021 +0200

    Move `RasterLoadingStrategy` to public API.
---
 .../sis/internal/storage/AbstractGridResource.java | 28 -------------------
 .../sis/internal/storage/TiledGridResource.java    |  1 +
 .../apache/sis/storage/GridCoverageResource.java   | 32 ++++++++++++++++++++++
 .../storage/RasterLoadingStrategy.java             |  6 +---
 .../sis/test/storage/CoverageReadConsistency.java  |  2 +-
 5 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
index 4bbf543..0e60107 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
@@ -484,34 +484,6 @@ public abstract class AbstractGridResource extends AbstractResource implements G
     }
 
     /**
-     * Returns an indication about when the "physical" loading of raster data will happen.
-     * This is the strategy actually applied by this resource implementation, not necessarily
-     * the strategy given in the last call to {@link #setLoadingStrategy(RasterLoadingStrategy)
-     * setLoadingStrategy(…)}.
-     *
-     * <p>The default strategy is to load raster data at {@link #read read(…)} method invocation time.</p>
-     *
-     * @return current raster data loading strategy for this resource.
-     */
-    public RasterLoadingStrategy getLoadingStrategy() {
-        return RasterLoadingStrategy.AT_READ_TIME;
-    }
-
-    /**
-     * Sets the preferred strategy about when to do the "physical" loading of raster data.
-     * Implementations are free to ignore this parameter or to replace the given strategy
-     * by the closest alternative that this resource can support.
-     *
-     * @param  strategy  the desired strategy for loading raster data.
-     * @return {@code true} if the given strategy has been accepted, or {@code false}
-     *         if this implementation replaced the given strategy by an alternative.
-     */
-    public boolean setLoadingStrategy(final RasterLoadingStrategy strategy) {
-        ArgumentChecks.ensureNonNull("strategy", strategy);
-        return strategy == getLoadingStrategy();
-    }
-
-    /**
      * Logs the execution of a {@link #read(GridGeometry, int...)} operation.
      * The log level will be {@link Level#FINE} if the operation was quick enough,
      * or {@link PerformanceLevel#SLOW} or higher level otherwise.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java
index 0a2bad4..bb67d36 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TiledGridResource.java
@@ -36,6 +36,7 @@ import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridRoundingMode;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.RasterLoadingStrategy;
 import org.apache.sis.storage.event.StoreListeners;
 import org.apache.sis.util.collection.WeakValueHashMap;
 import org.apache.sis.util.ArraysExt;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
index e30cf6b..ce2fe89 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
@@ -160,4 +160,36 @@ public interface GridCoverageResource extends DataSet {
      * @throws DataStoreException if an error occurred while reading the grid coverage data.
      */
     GridCoverage read(GridGeometry domain, int... range) throws DataStoreException;
+
+    /**
+     * Returns an indication about when the "physical" loading of raster data will happen.
+     * This is the strategy actually applied by this resource implementation, not necessarily
+     * the strategy given in the last call to {@link #setLoadingStrategy(RasterLoadingStrategy)
+     * setLoadingStrategy(…)}.
+     *
+     * <p>The default strategy is to load raster data at {@link #read read(…)} method invocation time.</p>
+     *
+     * @return current raster data loading strategy for this resource.
+     *
+     * @since 1.1
+     */
+    default RasterLoadingStrategy getLoadingStrategy() {
+        return RasterLoadingStrategy.AT_READ_TIME;
+    }
+
+    /**
+     * Sets the preferred strategy about when to do the "physical" loading of raster data.
+     * Implementations are free to ignore this parameter or to replace the given strategy
+     * by the closest alternative that this resource can support.
+     *
+     * @param  strategy  the desired strategy for loading raster data.
+     * @return {@code true} if the given strategy has been accepted, or {@code false}
+     *         if this implementation replaced the given strategy by an alternative.
+     *
+     * @since 1.1
+     */
+    default boolean setLoadingStrategy(final RasterLoadingStrategy strategy) {
+        ArgumentChecks.ensureNonNull("strategy", strategy);
+        return strategy == getLoadingStrategy();
+    }
 }
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/RasterLoadingStrategy.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/RasterLoadingStrategy.java
similarity index 95%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/RasterLoadingStrategy.java
rename to storage/sis-storage/src/main/java/org/apache/sis/storage/RasterLoadingStrategy.java
index 7d674c2..3c1a16e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/RasterLoadingStrategy.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/RasterLoadingStrategy.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage;
+package org.apache.sis.storage;
 
 import java.lang.ref.SoftReference;
 import java.awt.image.RenderedImage;
@@ -23,8 +23,6 @@ import org.opengis.coverage.CannotEvaluateException;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridCoverage;
-import org.apache.sis.storage.GridCoverageResource;
-import org.apache.sis.storage.DataStoreException;
 
 
 /**
@@ -40,8 +38,6 @@ import org.apache.sis.storage.DataStoreException;
  * The lazy strategy is more efficient when only a few tiles will be used and those tiles are not known in advance.
  * The lazy strategy is also the only applicable one if the image is too large for holding in memory.</p>
  *
- * @todo This enumeration is internal for now, but may move to public API in a future version.
- *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
  * @since   1.1
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/test/storage/CoverageReadConsistency.java b/storage/sis-storage/src/test/java/org/apache/sis/test/storage/CoverageReadConsistency.java
index 6c2fe68..a15d7a1 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/test/storage/CoverageReadConsistency.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/test/storage/CoverageReadConsistency.java
@@ -29,8 +29,8 @@ import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.GridCoverageResource;
+import org.apache.sis.storage.RasterLoadingStrategy;
 import org.apache.sis.internal.storage.AbstractGridResource;
-import org.apache.sis.internal.storage.RasterLoadingStrategy;
 import org.apache.sis.internal.util.StandardDateFormat;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.image.PixelIterator;