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

desruisseaux pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 81e91adb6b8f4b7feeffcd488c2f2e31f36eaf31
Merge: 0a0451285d 470783640d
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Wed Feb 26 18:55:29 2025 +0100

    Merge branch 'geoapi-3.1': refactoring of GeoHEIF reader.

 .../apache/sis/buildtools/gradle/Dependency.java   |   2 +-
 .../org.apache.sis.feature/main/module-info.java   |   5 +-
 .../main/org/apache/sis/metadata/sql/Contents.sql  |   2 +
 .../main/module-info.java                          |   6 +-
 .../org.apache.sis.storage/main/module-info.java   |   4 +-
 .../src/org.apache.sis.util/main/module-info.java  |   9 +-
 .../main/org/apache/sis/util/ArraysExt.java        |  24 +-
 incubator/build.gradle.kts                         |   8 +-
 ....apache.sis.storage.geoheif.isobmff.BoxRegistry |   8 -
 .../main/module-info.java                          |  25 +-
 .../sis/storage/geoheif/CoverageBuilder.java       | 687 +++++++++++++++++++++
 .../apache/sis/storage/geoheif/FromImageIO.java    | 157 ++++-
 .../apache/sis/storage/geoheif/GeoHeifStore.java   | 446 +++++++------
 .../sis/storage/geoheif/GeoHeifStoreProvider.java  | 100 +--
 .../org/apache/sis/storage/geoheif/GimiTile.java   |  67 --
 .../apache/sis/storage/geoheif/GimiTileMatrix.java | 116 ----
 .../sis/storage/geoheif/GimiTileMatrixSet.java     |  72 ---
 .../main/org/apache/sis/storage/geoheif/Group.java |  64 +-
 .../main/org/apache/sis/storage/geoheif/Image.java | 254 ++------
 .../apache/sis/storage/geoheif/ImageResource.java  | 460 ++++++++++----
 .../sis/storage/geoheif/MatrixGridRessource.java   | 154 -----
 .../org/apache/sis/storage/geoheif/Pyramid.java    | 195 +-----
 .../sis/storage/geoheif/ResourceBuilder.java       | 467 ++++++++++++++
 .../sis/storage/geoheif/ResourceUnknown.java       |  62 --
 .../apache/sis/storage/geoheif/ScaleSortedMap.java | 105 ----
 .../apache/sis/storage/geoheif/TileMatrices.java   |  65 --
 .../sis/storage/geoheif/UncompressedImage.java     | 361 +++--------
 .../apache/sis/storage/geoheif/package-info.java   |   7 +-
 .../main/org/apache/sis/storage/isobmff/Box.java   | 278 ++-------
 .../apache/sis/storage/isobmff/BoxRegistry.java    |  87 ++-
 .../org/apache/sis/storage/isobmff/ByteReader.java |  92 +++
 .../apache/sis/storage/isobmff/ContainerBox.java   |  76 +++
 .../org/apache/sis/storage/isobmff/Extension.java  |  64 +-
 .../org/apache/sis/storage/isobmff/FullBox.java    |  86 ++-
 .../sis/storage/isobmff/MainBoxRegistry.java       | 189 ++++++
 .../org/apache/sis/storage/isobmff/Reader.java     | 448 ++++++++++----
 .../main/org/apache/sis/storage/isobmff/Root.java  |  53 ++
 .../org/apache/sis/storage/isobmff/TreeNode.java   | 372 ++++++++++-
 ...llBox.java => UnsupportedVersionException.java} |  25 +-
 .../apache/sis/storage/isobmff/VectorReader.java   | 134 ++++
 .../storage/isobmff/base/ColourInformation.java    | 112 +++-
 .../sis/storage/isobmff/base/CombinaisonType.java  |  34 +-
 .../apache/sis/storage/isobmff/base/Copyright.java |  92 +++
 .../sis/storage/isobmff/base/EntityToGroup.java    |  40 +-
 .../sis/storage/isobmff/base/ExtendedType.java     |  51 +-
 .../storage/isobmff/base/FDItemInfoExtension.java  |  80 ++-
 .../apache/sis/storage/isobmff/base/FileType.java  |  58 +-
 .../apache/sis/storage/isobmff/base/FreeSpace.java |  32 +-
 .../sis/storage/isobmff/base/GeneralType.java      |  53 --
 .../apache/sis/storage/isobmff/base/GroupList.java |  40 +-
 .../sis/storage/isobmff/base/HandlerReference.java |  58 +-
 .../apache/sis/storage/isobmff/base/HeaderBox.java | 102 +++
 .../sis/storage/isobmff/base/ISO14496_12.java      | 115 ----
 .../storage/isobmff/base/IdentifiedMediaData.java  |  60 +-
 .../apache/sis/storage/isobmff/base/ItemData.java  |  70 ++-
 .../sis/storage/isobmff/base/ItemFullProperty.java |  28 -
 .../apache/sis/storage/isobmff/base/ItemInfo.java  |  86 ++-
 .../sis/storage/isobmff/base/ItemInfoEntry.java    | 184 +++++-
 .../sis/storage/isobmff/base/ItemLocation.java     | 332 +++++++---
 .../sis/storage/isobmff/base/ItemProperties.java   | 182 +++++-
 .../sis/storage/isobmff/base/ItemProperty.java     |  28 -
 .../isobmff/base/ItemPropertyAssociation.java      | 171 ++++-
 .../isobmff/base/ItemPropertyContainer.java        |  41 +-
 .../sis/storage/isobmff/base/ItemReference.java    |  61 +-
 .../apache/sis/storage/isobmff/base/MediaData.java |  59 +-
 .../org/apache/sis/storage/isobmff/base/Meta.java  |  76 ++-
 .../org/apache/sis/storage/isobmff/base/Movie.java |  37 +-
 .../sis/storage/isobmff/base/MovieHeader.java      |  55 +-
 .../sis/storage/isobmff/base/OriginalFileType.java |  40 +-
 .../sis/storage/isobmff/base/PrimaryItem.java      |  48 +-
 .../isobmff/base/ProgressiveDownloadInfo.java      |  36 +-
 .../isobmff/base/SingleItemTypeReference.java      |  55 +-
 .../isobmff/base/SingleItemTypeReferenceLarge.java |  38 --
 .../org/apache/sis/storage/isobmff/base/Track.java |  39 +-
 .../sis/storage/isobmff/base/TrackHeader.java      | 100 ++-
 .../apache/sis/storage/isobmff/base/UserData.java  |  59 ++
 .../sis/storage/isobmff/base/package-info.java     |  11 +
 .../org/apache/sis/storage/isobmff/gimi/GIMI.java  |  70 ---
 .../apache/sis/storage/isobmff/gimi/ModelCRS.java  |  94 ++-
 .../sis/storage/isobmff/gimi/ModelTiePoint.java    |  87 ++-
 .../storage/isobmff/gimi/ModelTransformation.java  |  74 ++-
 .../isobmff/gimi/TiledImageConfiguration.java      |  28 +-
 .../sis/storage/isobmff/gimi/UnknownProperty.java  |  63 ++
 .../sis/storage/isobmff/gimi/package-info.java     |   7 +
 .../sis/storage/isobmff/image/CreationTime.java    |  69 +++
 .../isobmff/image/DerivedImageReference.java       |  27 +-
 .../sis/storage/isobmff/image/ISO23008_12.java     |  72 ---
 .../sis/storage/isobmff/image/ImagePyramid.java    | 105 +++-
 .../storage/isobmff/image/ImageSpatialExtents.java |  64 +-
 .../storage/isobmff/image/ModificationTime.java    |  69 +++
 .../storage/isobmff/image/PixelInformation.java    |  50 +-
 .../sis/storage/isobmff/image/UserDescription.java |  83 ++-
 .../sis/storage/isobmff/image/package-info.java    |  10 +
 .../sis/storage/isobmff/mpeg/ChromaLocation.java   |  34 +-
 .../apache/sis/storage/isobmff/mpeg/Component.java | 138 +++++
 .../storage/isobmff/mpeg/ComponentDefinition.java  |  96 ++-
 .../sis/storage/isobmff/mpeg/ComponentPalette.java | 146 ++++-
 .../isobmff/mpeg/ComponentPatternDefinition.java   |  71 ++-
 .../isobmff/mpeg/ComponentReferenceLevel.java      |  34 +-
 .../sis/storage/isobmff/mpeg/ComponentType.java    | 188 ++++++
 .../isobmff/mpeg/DepthMappingInformation.java      |  34 +-
 .../storage/isobmff/mpeg/DisparityInformation.java |  34 +-
 .../sis/storage/isobmff/mpeg/FieldInterlace.java   |  34 +-
 .../storage/isobmff/mpeg/FieldInterlaceType.java   |  31 +-
 .../isobmff/mpeg/FramePackingInformation.java      |  34 +-
 .../sis/storage/isobmff/mpeg/ISO23001_17.java      |  93 ---
 .../sis/storage/isobmff/mpeg/InterleavingMode.java | 101 +++
 .../mpeg/PolarizationPatternDefinition.java        |  34 +-
 .../storage/isobmff/mpeg/SensorBadPixelsMap.java   |  34 +-
 .../mpeg/SensorNonUniformityCorrection.java        |  34 +-
 .../sis/storage/isobmff/mpeg/TAIClockInfo.java     |  69 ++-
 .../sis/storage/isobmff/mpeg/TAITimeStamp.java     |  55 +-
 .../isobmff/mpeg/UncompressedFrameConfig.java      | 278 +++++++--
 .../sis/storage/isobmff/mpeg/package-info.java     |  10 +
 .../apache/sis/storage/isobmff/package-info.java   |  30 +
 .../storage/isobmff/video/ContentDescribes.java    |  31 +-
 .../sis/storage/isobmff/video/ISO14496_10.java     |  61 --
 .../sis/storage/isobmff/video/package-info.java    |  10 +
 .../org/apache/sis/storage/geoheif/StoreTest.java  |  21 -
 .../org/apache/sis/storage/isobmff/BoxTest.java}   |  36 +-
 .../sis/storage/isobmff/gimi/ExtensionTest.java}   |  33 +-
 .../storage/isobmff/mpeg/ComponentTypeTest.java    |  60 ++
 netbeans-project/nbproject/project.properties      |   2 +-
 netbeans-project/nbproject/project.xml             |   1 +
 124 files changed, 7955 insertions(+), 3483 deletions(-)

diff --cc endorsed/src/org.apache.sis.feature/main/module-info.java
index 1b5b4cf258,86a5451ee6..d962a55798
--- a/endorsed/src/org.apache.sis.feature/main/module-info.java
+++ b/endorsed/src/org.apache.sis.feature/main/module-info.java
@@@ -57,8 -53,9 +57,8 @@@ module org.apache.sis.feature 
              org.apache.sis.storage.xml,
              org.apache.sis.storage.netcdf,
              org.apache.sis.storage.shapefile,       // In the "incubator" 
sub-project.
-             org.apache.sis.portrayal,
              org.apache.sis.storage.gdal,            // In the "optional" 
sub-project.
+             org.apache.sis.portrayal,
 -            org.apache.sis.portrayal.map,           // In the "incubator" 
sub-project.
              org.apache.sis.gui;                     // In the "optional" 
sub-project.
  
      exports org.apache.sis.geometry.wrapper to
diff --cc endorsed/src/org.apache.sis.util/main/module-info.java
index 1f2e17af3c,ed37b3f029..ddc371da79
--- a/endorsed/src/org.apache.sis.util/main/module-info.java
+++ b/endorsed/src/org.apache.sis.util/main/module-info.java
@@@ -129,10 -130,13 +130,11 @@@ module org.apache.sis.util 
              org.apache.sis.storage.xml,
              org.apache.sis.storage.sql,
              org.apache.sis.storage.netcdf,
+             org.apache.sis.storage.geoheif,             // In the "incubator" 
sub-project.
              org.apache.sis.storage.geotiff,
              org.apache.sis.storage.earthobservation,
 -            org.apache.sis.cql,                         // In the "incubator" 
sub-project.
 -            org.apache.sis.portrayal.map,               // In the "incubator" 
sub-project.
              org.apache.sis.portrayal,
-             org.apache.sis.storage.gdal,                // In the "incubator" 
sub-project.
+             org.apache.sis.storage.gdal,                // In the "optional" 
sub-project.
              org.apache.sis.storage.gsf,                 // In the "incubator" 
sub-project.
              org.apache.sis.cloud.aws,
              org.apache.sis.console,
diff --cc 
incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
index cb0935898e,1bba479a9f..f555447698
--- 
a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
+++ 
b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/GeoHeifStore.java
@@@ -122,84 -231,76 +231,76 @@@ public class GeoHeifStore extends DataS
          return root;
      }
  
+     /**
+      * Returns information about the dataset as a whole. The returned 
metadata object can contain information
+      * such as the spatiotemporal extent of the dataset, contact information 
about the creator or distributor,
+      * data quality, usage constraints and more.
+      *
+      * @return information about the dataset.
+      * @throws DataStoreException if an error occurred while reading the data.
+      */
      @Override
-     public synchronized Collection<? extends Resource> components() throws 
DataStoreException {
-         if (components != null) return components;
- 
-         components = new ArrayList<>();
-         itemIndex = new HashMap<>();
-         componentIndex = new HashMap<>();
- 
-         /*
-          * Collect elements which should not be displayed since they are part 
of a larger image (grid or pyramid)
-          */
-         final Set<Integer> includedInParents = new HashSet<>();
- 
-         try {
-             final Box root = getRootBox();
-             final Meta meta = (Meta) root.getChild(Meta.FCC, null);
-             final Box groups = meta.getChild(GroupList.FCC, null);
-             final ItemInfo iinf = (ItemInfo) meta.getChild(ItemInfo.FCC, 
null);
- 
-             /*
-              * Build item index.
-              * Create GridImages and collect used items.
-              */
-             for (ItemInfoEntry iie : iinf.entries) {
-                 final Image item = new Image(this, iie);
-                 itemIndex.put(iie.itemId, item);
- 
-                 if (ImageResource.TYPE.equals(iie.itemType)) {
-                     for (SingleItemTypeReference refs : item.getReferences()) 
{
-                         final ImageResource resource = new 
ImageResource(item);
-                         componentIndex.put(iie.itemId, resource);
-                         for (int i :refs.toItemId) {
-                             includedInParents.add(i);
-                         }
-                     }
-                 }
-             }
- 
-             /*
-              * Read groups.
-              * Create pyramids and groups and collect used items.
-              */
-             if (groups != null) {
-                 for (Box b : groups.getChildren()) {
-                     if (b instanceof ImagePyramid) {
-                         final ImagePyramid img = (ImagePyramid) b;
-                         final Pyramid pyramid = new Pyramid(this, img);
-                         components.add(pyramid);
- 
-                         for (int i :img.entitiesId) {
-                             includedInParents.add(i);
-                         }
-                     } else if (b instanceof EntityToGroup) {
-                         final EntityToGroup grp = (EntityToGroup) b;
-                         final Group group = new Group(this, grp);
-                         components.add(group);
- 
-                         for (int i :grp.entitiesId) {
-                             includedInParents.add(i);
-                         }
-                     }
-                 }
-             }
+     public synchronized Metadata getMetadata() throws DataStoreException {
+         if (metadata == null) {
+             final var builder = new MetadataBuilder();
+             root().metadata(builder);
+             builder.setISOStandards(true);
+             builder.setPredefinedFormat(GeoHeifStoreProvider.NAME, listeners, 
true);
+             builder.addFormatReaderSIS(GeoHeifStoreProvider.NAME);
 -            builder.addResourceScope(ScopeCode.COVERAGE, null);
++            builder.addResourceScope(ScopeCode.valueOf("COVERAGE"), null);
+             getIdentifier().ifPresent((id) -> builder.addIdentifier(id, 
MetadataBuilder.Scope.ALL));
+             metadata = builder.buildAndFreeze();
+         }
+         return metadata;
+     }
  
-             /*
-              * Add all items not used by groups and grids.
-              */
-             final Set<Integer> keys = new HashSet<>(itemIndex.keySet());
-             keys.removeAll(includedInParents);
-             for (Integer k : keys) {
-                 components.add(getComponent(k));
-             }
+     /**
+      * Returns <abbr>HEIF</abbr> boxes and their fields as a tree for 
debugging purpose.
+      * The boxes appear in the order they are declared in the file.
+      * Only the boxes and fields recognized by this <abbr>HEIF</abbr> store 
implementation are shown.
+      * The table contains the following columns:
+      *
+      * <ul>
+      *   <li>{@linkplain TableColumn#NAME}</li>
+      *   <li>{@linkplain TableColumn#VALUE}</li>
+      *   <li>{@linkplain TableColumn#VALUE_AS_TEXT}</li>
+      * </ul>
+      *
+      * <h4>Usage and performance note</h4>
+      * This method should not be invoked during normal operations. The 
{@linkplain #getMetadata() standard metadata}
+      * are preferred because they allow abstraction of data format details. 
Native metadata should be used only when
+      * an information does not appear in standard metadata, or for debugging 
purposes.
+      *
+      * <p>Since this method should not be invoked in normal operations, it 
has not been tuned for performance.
+      * Invoking this method may cause a lot of {@linkplain 
java.nio.channels.SeekableByteChannel#position(long)
+      * seek operations}.</p>
+      *
+      * @return resources information structured in an implementation-specific 
way.
+      * @throws DataStoreException if an error occurred while reading the 
metadata.
+      *
+      * @todo It is sometime possible, through the tree cell values, to modify 
the content of internal arrays.
+      *       This is unsafe, we should makes this implementation safer before 
this module is released.
+      */
+     @Override
+     public synchronized Optional<TreeTable> getNativeMetadata() throws 
DataStoreException {
+         return Optional.of(root().toTree(getDisplayName(), true));
+     }
  
-         } catch (IOException ex) {
-             throw new DataStoreException(ex.getMessage(), ex);
+     /**
+      * Returns the children resources of this aggregate.
+      *
+      * @return all children resources that are components of this aggregate.
+      * @throws DataStoreException if an error occurred while fetching the 
components.
+      */
+     @Override
+     public synchronized Collection<? extends Resource> components() throws 
DataStoreException {
+         if (content == null) try {
+             final var builder = new ResourceBuilder(this, root());
+             content = builder.build();
+         } catch (IOException e) {
+             throw new DataStoreException(e);
          }
- 
-         return components;
+         return UnmodifiableArrayList.wrap(content);
      }
  
      /**

Reply via email to