Refactor ImageMosaic - STEMLab/geotools GitHub Wiki

Description

The goal is to make it possible to use imagemosaic as a base to extend upon to make stores that do similar things, to replace certain implementations with alternative implementations and use only that which we want to use. For this we want to introduce a new API existing out of interfaces and default implementations. The main principle is "separation of concerns" so we can easily choose which parts to reuse and which to reimplement when we want to make a new store.

The following interfaces and its default implementations will take take functionality that is currently inside ImageMosaicConfigHandler, CatalogManager, CatalogBuilderConfiguration, Indexer and even RasterLayerResponse (creation of SortBy) and ImageMosaicWalker (creation of the reader). The idea is to completely encapsulate the current Indexer class (inside the default implementation of MosaicIndexConfiguration) so that an alternative way of creating the index schema and content can be provided through a different implementation of these interfaces.

/**
 * Configuration that tells us how to index a mosaic store.
 */
public interface MosaicIndexConfiguration {
      /**
       * Create a schema given a coverage name and CRS
       */
      SimpleFeatureType createSchema(String name, CoordinateReferenceSystem crs);

      /**
       * Get all Property Collectors
       */       
      List<PropertiesCollector> getPropertiesCollectors();

      /** 
       * Create a reader from a granule.
       */
      GridCoverage2DReader getReader(SimpleFeature reader);

      /**
       * Return the order of the granules
       */
      SortBy[] getOrder(String name);

      /**
       * Retrieve parameter (see Prop)
       */
      String getParameter(Prop prop);

}

/**
 * Manages GranuleCatalogs. Create them and update them with new information.
 */
public interface GranuleCatalogManager {
      public void setCoverageName(String coverageName);
      public void setMosaicIndexer(MosaicIndexer indexer);

      GranuleCatalog loadGranuleCatalog(String coverageName, boolean create)
      GranuleCatalog loadGranuleCatalogFromDataStore(String coverageName, Properties properties, boolean create, Hints hints);
      void updateCatalog(GranuleStore store, File file, String coverageName, GridCoverageReader reader, Transaction transaction);
}

The following interfaces and classes will take over functionality that is currently inside the ImageMosaicReader. We want to separate the harvesting process from the mosaic creation logic. Instead of passing on the ImageMosaicReader as 'parent' to several other classes (such as RasterManager), which is only done to retrieve data but thereby forcing the use of the ImageMosaicReader (and all its specifics about harvesting etc), we will instead pass on the ImageMosaic class, keeping the reader out of all other classes needed to produce the mosaic.

/**
 * Stores rastermanagers (includes GranuleStores)
 */
public class ImageMosaic {
    GranuleCatalogManager catalogManager;
    String defaultName = null;
    Map<String, RasterManager> rasterManagers = new ConcurrentHashMap<String, RasterManager>();

    public String getDefaultRasterManagerName();

    public RasterManager getRasterManager(String name);
    public void removeRasterManager(String name, boolean forceDelete, boolean checkForReferences);
    public RasterManager addRasterManager(final MosaicConfigurationBean configuration, final boolean init);


}

/**
 * Decides how to harvest a new file into the store
 */
public interface MosaicHarvester {
     public void harvest(ImageMosaic mosaic, String defaultCoverage, Object source, Hints hints);
}

/**
 * Reader. Implements the proper interfaces and delegates different tasks to other classes
 */
public class ImageMosaicReader() extends AbstractGridCoverage2DReader implements StructuredGridCoverage2DReader {
     private MosaicHarvester harvester;
     private ImageMosaic mosaic;
     
     ...
}

References:

Status

Choose one of:

  • Under Discussion
  • In Progress
  • Completed
  • Rejected,
  • Deferred

Voting:

  • Andrea Aime
  • Ben Caradoc-Davies
  • Christian Mueller
  • Ian Turton
  • Justin Deoliveira
  • Jody Garnett
  • Simone Giannecchini

Tasks

This section is used to make sure your proposal is complete (did you remember documentation?) and has enough paid or volunteer time lined up to be a success. Use initials to indicate volunteer, or :warning: where volunteer is neededs. Proposals that lack resources to be successful are unlikely to be approved.

  1. Update implementation
  2. Verify with test case
  3. Remove deprecated code
  4. Documentation changes
    • API change make a note upgrading page.
    • Update the user guide with code example

API Change

There is currently little or no API available in imagemosaic. Everything is new as described above.