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 c25766bdff4714df6d4cd9a639fb1b43ae711d2f
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Nov 24 12:50:24 2023 +0100

    Move `getEnvelope()` default implementation from 
`AbstractGridCoverageResource` class to `GridCoverageResource` interface.
---
 .../sis/storage/AbstractGridCoverageResource.java  | 21 +-------------------
 .../apache/sis/storage/GridCoverageResource.java   | 23 +++++++++++++++++++++-
 .../org/apache/sis/storage/esri/RasterStore.java   | 14 -------------
 3 files changed, 23 insertions(+), 35 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractGridCoverageResource.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractGridCoverageResource.java
index 33e5bb4e49..862133bc4f 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractGridCoverageResource.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/AbstractGridCoverageResource.java
@@ -17,7 +17,6 @@
 package org.apache.sis.storage;
 
 import java.util.Locale;
-import java.util.Optional;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.LogRecord;
@@ -60,7 +59,7 @@ import org.apache.sis.storage.internal.Resources;
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   1.2
  */
 public abstract class AbstractGridCoverageResource extends AbstractResource 
implements GridCoverageResource {
@@ -97,24 +96,6 @@ public abstract class AbstractGridCoverageResource extends 
AbstractResource impl
         super(parentListeners, hidden);
     }
 
-    /**
-     * Returns the envelope of the grid geometry if known.
-     * The envelope is absent if the grid geometry does not provide this 
information.
-     *
-     * @return the grid geometry envelope.
-     * @throws DataStoreException if an error occurred while computing the 
grid geometry.
-     *
-     * @see GridGeometry#getEnvelope()
-     */
-    @Override
-    public Optional<Envelope> getEnvelope() throws DataStoreException {
-        final GridGeometry gg = getGridGeometry();
-        if (gg != null && gg.isDefined(GridGeometry.ENVELOPE)) {
-            return Optional.of(gg.getEnvelope());
-        }
-        return Optional.empty();
-    }
-
     /**
      * Invoked in a synchronized block the first time that {@code 
getMetadata()} is invoked.
      * The default implementation populates metadata based on information 
provided by
diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java
index caeb0b193d..8921547408 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java
@@ -17,6 +17,8 @@
 package org.apache.sis.storage;
 
 import java.util.List;
+import java.util.Optional;
+import org.opengis.geometry.Envelope;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridCoverage;
@@ -40,10 +42,29 @@ import org.apache.sis.util.ArraysExt;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Johann Sorel (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   1.0
  */
 public interface GridCoverageResource extends DataSet {
+    /**
+     * Returns the spatiotemporal extent of this resource in its most natural 
coordinate reference system.
+     * The default implementation fetches this information from the 
{@linkplain #getGridGeometry() grid geometry},
+     * if presents.
+     *
+     * @return the spatiotemporal resource extent. May be absent if none or 
too costly to compute.
+     * @throws DataStoreException if an error occurred while reading or 
computing the envelope.
+     *
+     * @see GridGeometry#getEnvelope()
+     */
+    @Override
+    default Optional<Envelope> getEnvelope() throws DataStoreException {
+        final GridGeometry gg = getGridGeometry();
+        if (gg != null && gg.isDefined(GridGeometry.ENVELOPE)) {
+            return Optional.of(gg.getEnvelope());
+        }
+        return Optional.empty();
+    }
+
     /**
      * Returns the valid extent of grid coordinates together with the 
conversion from those grid
      * coordinates to real world coordinates. A grid geometry contains the 
following information:
diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
index 4d22dfe327..9b8f3cc9dd 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/RasterStore.java
@@ -18,7 +18,6 @@ package org.apache.sis.storage.esri;
 
 import java.util.List;
 import java.util.Arrays;
-import java.util.Optional;
 import java.util.Hashtable;
 import java.util.Locale;
 import java.util.logging.Level;
@@ -30,7 +29,6 @@ import java.awt.image.ColorModel;
 import java.awt.image.DataBuffer;
 import java.awt.image.SampleModel;
 import java.awt.image.WritableRaster;
-import org.opengis.geometry.Envelope;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.maintenance.ScopeCode;
 import org.apache.sis.metadata.sql.MetadataStoreException;
@@ -143,18 +141,6 @@ abstract class RasterStore extends PRJDataStore implements 
GridCoverageResource
         return listComponentFiles(PRJ, STX, CLR);
     }
 
-    /**
-     * Returns the spatiotemporal extent of the raster file.
-     *
-     * @return the spatiotemporal resource extent.
-     * @throws DataStoreException if an error occurred while computing the 
envelope.
-     * @hidden
-     */
-    @Override
-    public Optional<Envelope> getEnvelope() throws DataStoreException {
-        return Optional.ofNullable(getGridGeometry().getEnvelope());
-    }
-
     /**
      * Builds metadata and assigns the result to the {@link #metadata} field.
      *

Reply via email to