This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits 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 c6cd7789c8 Add a self-consistency test for GeoHEIF, similar to the
existing self-consistency check of GeoTIFF.
c6cd7789c8 is described below
commit c6cd7789c8c734dd4538cb3f77866aeaf296f9c1
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed Jul 15 14:43:46 2026 +0200
Add a self-consistency test for GeoHEIF, similar to the existing
self-consistency check of GeoTIFF.
---
endorsed/build.gradle.kts | 1 +
.../sis/storage/geoheif}/SelfConsistencyTest.java | 39 ++++------------------
.../sis/storage/geotiff/SelfConsistencyTest.java | 2 ++
.../apache/sis/storage/test/SubsampledImage.java | 21 ++++++++++--
.../test/org/apache/sis/test/OptionalTestData.java | 8 ++++-
netbeans-project/nbproject/project.properties | 2 ++
6 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/endorsed/build.gradle.kts b/endorsed/build.gradle.kts
index 6612e5dc7f..e0fd9f3ec9 100644
--- a/endorsed/build.gradle.kts
+++ b/endorsed/build.gradle.kts
@@ -159,6 +159,7 @@ fun addExportForTests(args : MutableList<String>) {
addExport(args, "org.apache.sis.storage",
"org.apache.sis.storage.test",
"org.apache.sis.storage.geotiff," +
+ "org.apache.sis.storage.geoheif," +
"org.apache.sis.storage.netcdf")
/*
* Some test classes need access to more internal packages than requested
by the main classes.
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
b/endorsed/src/org.apache.sis.storage.geoheif/test/org/apache/sis/storage/geoheif/SelfConsistencyTest.java
similarity index 58%
copy from
endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
copy to
endorsed/src/org.apache.sis.storage.geoheif/test/org/apache/sis/storage/geoheif/SelfConsistencyTest.java
index 4c53c1e0ee..cbf02d64cb 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
+++
b/endorsed/src/org.apache.sis.storage.geoheif/test/org/apache/sis/storage/geoheif/SelfConsistencyTest.java
@@ -14,19 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.storage.geotiff;
+package org.apache.sis.storage.geoheif;
-import java.util.List;
-import org.opengis.util.GenericName;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.GridCoverageResource;
-import org.apache.sis.storage.IllegalNameException;
import org.apache.sis.storage.StorageConnector;
// Test dependencies
-import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.OptionalTestData;
import org.apache.sis.storage.test.CoverageReadConsistency;
@@ -39,48 +34,26 @@ import org.apache.sis.storage.test.CoverageReadConsistency;
* a subset of data.
*
* @author Martin Desruisseaux (Geomatys)
- * @author Alexis Manin (Geomatys)
*/
@SuppressWarnings("exports")
-public final class SelfConsistencyTest extends
CoverageReadConsistency<GeoTiffStore> {
+public final class SelfConsistencyTest extends
CoverageReadConsistency<GeoHeifStore> {
/**
* Opens the test file to be used for all tests.
*
* @throws DataStoreException if an error occurred while opening the file.
*/
public SelfConsistencyTest() throws DataStoreException {
- super(new GeoTiffStore(null, new
StorageConnector(OptionalTestData.GEOTIFF.path())));
+ super(new GeoHeifStore(null, new
StorageConnector(OptionalTestData.GEOHEIF.path())));
}
/**
* Work around for RFE #4093999 in Sun's bug database
* ("Relax constraint on placement of this()/super() call in
constructors").
- */
- @Override
- protected GridCoverageResource resource() throws DataStoreException {
- return store.components().iterator().next();
- }
-
- /**
- * Verifies that {@link GeoTiffStore#findResource(String)} returns the
resource when using
- * either the full name or only its tip.
*
* @throws DataStoreException if an error occurred while reading the file.
*/
- @Test
- public void findResourceByName() throws DataStoreException {
- final List<GridCoverageResource> datasets = store.components();
- assertFalse(datasets.isEmpty());
- for (GridCoverageResource dataset : datasets) {
- final GenericName name = dataset.getIdentifier()
- .orElseThrow(() -> new AssertionError("A component of the
GeoTIFF datastore is unnamed"));
- GridCoverageResource foundResource =
store.findResource(name.toString());
- assertSame(dataset, foundResource);
- foundResource = store.findResource(name.tip().toString());
- assertSame(dataset, foundResource);
- }
- var e = assertThrows(IllegalNameException.class, () ->
store.findResource("a_wrong_namespace:1"),
- "No dataset should be returned when user specifies the wrong
namespace.");
- assertMessageContains(e, "a_wrong_namespace:1");
+ @Override
+ protected GridCoverageResource resource() throws DataStoreException {
+ return assertInstanceOf(GridCoverageResource.class,
store.components().iterator().next());
}
}
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
index 4c53c1e0ee..b52720fb64 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
@@ -55,6 +55,8 @@ public final class SelfConsistencyTest extends
CoverageReadConsistency<GeoTiffSt
/**
* Work around for RFE #4093999 in Sun's bug database
* ("Relax constraint on placement of this()/super() call in
constructors").
+ *
+ * @throws DataStoreException if an error occurred while reading the file.
*/
@Override
protected GridCoverageResource resource() throws DataStoreException {
diff --git
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/SubsampledImage.java
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/SubsampledImage.java
index 710ce252e1..98fb33af4a 100644
---
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/SubsampledImage.java
+++
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/test/SubsampledImage.java
@@ -23,6 +23,7 @@ import java.util.Objects;
import java.awt.image.Raster;
import java.awt.image.ColorModel;
import java.awt.image.SampleModel;
+import java.awt.image.BandedSampleModel;
import java.awt.image.MultiPixelPackedSampleModel;
import java.awt.image.PixelInterleavedSampleModel;
import java.awt.image.RenderedImage;
@@ -124,6 +125,12 @@ final class SubsampledImage extends PlanarImage {
sm.getPixelBitStride(),
sm.getScanlineStride() * subY,
sm.getDataBitOffset());
+ } else if (sourceModel instanceof BandedSampleModel sm) {
+ assertEquals(1, sm.getNumBands(), "Banded image with more than 1
band is not supported.");
+ model = new PixelInterleavedSampleModel(sm.getDataType(),
+ divExclusive(sm.getWidth(), subX),
+ divExclusive(sm.getHeight(), subY),
+ subX, sm.getScanlineStride()*subY, sm.getBandOffsets());
} else {
throw new AssertionError("Unsupported sample model: " +
sourceModel);
}
@@ -202,14 +209,24 @@ final class SubsampledImage extends PlanarImage {
}
final String warning = image.verify();
if (warning != null && (source instanceof PlanarImage planar)) {
+ final String message = Strings.orEmpty(planar.verify());
// Source warning may be "source.height", which we replace by
"height".
- final String s = Strings.orEmpty(planar.verify());
- assertEquals(s.substring(s.lastIndexOf('.') + 1), warning, s);
+ final String fromSource =
message.substring(message.lastIndexOf('.') + 1);
+ if (!(isIgnoreableWarning(fromSource)) &&
isIgnoreableWarning(warning)) {
+ assertEquals(fromSource, warning, message);
+ }
}
return image;
}
}
+ /**
+ * Returns whether the given return value of {@link PlanarImage#verify()}
can be ignored.
+ */
+ private static boolean isIgnoreableWarning(final String warning) {
+ return "width".equals(warning) || "height".equals(warning);
+ }
+
/**
* Returns the image at full resolution.
*/
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
index c8a49eaa78..0cad156627 100644
---
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
+++
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
@@ -101,7 +101,13 @@ public enum OptionalTestData {
* Any GeoTIFF image supported by Apache SIS, without any particular
expectation on data.
* This is used for self-consistency tests.
*/
- GEOTIFF("AnyGeoTIFF.tiff");
+ GEOTIFF("AnyGeoTIFF.tiff"),
+
+ /**
+ * Any GeoHEIF image supported by Apache SIS, without any particular
expectation on data.
+ * This is used for self-consistency tests.
+ */
+ GEOHEIF("AnyGeoHEIF.heif");
/**
* The filename in {@code $SIS_DATA/Tests} directory.
diff --git a/netbeans-project/nbproject/project.properties
b/netbeans-project/nbproject/project.properties
index a14465049c..df2d3a4a66 100644
--- a/netbeans-project/nbproject/project.properties
+++ b/netbeans-project/nbproject/project.properties
@@ -75,6 +75,7 @@ modules.list = org.apache.sis.cloud.aws,\
org.apache.sis.storage,\
org.apache.sis.storage.earthobservation,\
org.apache.sis.storage.geotiff,\
+ org.apache.sis.storage.geoheif,\
org.apache.sis.storage.netcdf,\
org.apache.sis.storage.sql,\
org.apache.sis.storage.xml,\
@@ -99,6 +100,7 @@ read.options = --add-reads
org.apache.sis.cloud.aws=org.junit.jupiter.api,junit
--add-reads
org.apache.sis.storage.coveragejson=org.junit.jupiter.api,junit \
--add-reads
org.apache.sis.storage.earthobservation=org.junit.jupiter.api,junit \
--add-reads
org.apache.sis.storage.geotiff=org.junit.jupiter.api,junit \
+ --add-reads
org.apache.sis.storage.geoheif=org.junit.jupiter.api,junit \
--add-reads
org.apache.sis.storage.netcdf=org.junit.jupiter.api,junit \
--add-reads
org.apache.sis.storage.sql=org.junit.jupiter.api,junit \
--add-reads
org.apache.sis.storage.xml=org.junit.jupiter.api,junit \