Class TLcdEarthTileRepositoryPreprocessor

java.lang.Object
com.luciad.earth.metadata.preprocessor.TLcdEarthTileRepositoryPreprocessor

public class TLcdEarthTileRepositoryPreprocessor extends Object
Generates or updates an ILcdEarthEditableTileSet based on its corresponding ILcdEarthAssets. This implementation uses multiple threads to increase the preprocessing performance.
Since:
8.2
  • Constructor Details

    • TLcdEarthTileRepositoryPreprocessor

      public TLcdEarthTileRepositoryPreprocessor()
      Constructs a multithreaded preprocessor that uses a single thread and the default commit frequency.
    • TLcdEarthTileRepositoryPreprocessor

      public TLcdEarthTileRepositoryPreprocessor(int aNumThreads)
      Constructs a multithreaded preprocessor that uses the specified number of threads and the default commit frequency.
      Parameters:
      aNumThreads - the number of threads to use for preprocessing
    • TLcdEarthTileRepositoryPreprocessor

      public TLcdEarthTileRepositoryPreprocessor(int aNumThreads, int aCommitFrequency)
      Constructs a multithreaded preprocessor that uses the specified number of threads and commit frequency. A larger commit frequency typically increases efficiency due to less disk access but increases the number of tiles that are lost if the preprocessor is cancelled or aborted.
      Parameters:
      aNumThreads - the number of threads to use for preprocessing
      aCommitFrequency - the number of tiles to produce before committing
  • Method Details

    • addTileCombiner

      public void addTileCombiner(ILcdEarthTileCombiner aCombiner)
      Registers a tile combiner to be used during preprocessing. Whenever a tile at level N is to be generated, the preprocessor will first check if the four corresponding tiles on level N+1 are available. If so, and if an appropriate tile combiner can be found, the combiner is used to generate the new tile. Otherwise, the tile is requested from the source tileset.
      Parameters:
      aCombiner - a tile combiner
      Throws:
      IllegalStateException - if this preprocessor is preprocessing
    • addAssetCodec

      public void addAssetCodec(ILcdEarthAssetCodec aCodec)
      Registers a codec for the preprocessed assets. Asset codecs are required to store the progress for the asset.
      Parameters:
      aCodec - an asset codec to use for storing the progress
      Throws:
      IllegalStateException - if this preprocessor is preprocessing
    • getNumberOfThreads

      public int getNumberOfThreads()
      Returns the number of threads used for preprocessing.
      Returns:
      the number of threads used for preprocessing.
    • setNumberOfThreads

      public void setNumberOfThreads(int aNumThreads)
      Sets the number of threads used for preprocessing.
      Parameters:
      aNumThreads - the number of threads used for preprocessing.
      Throws:
      IllegalStateException - if this preprocessor is preprocessing
    • getThreadPriority

      public int getThreadPriority()
      Returns the priority of the preprocessing threads.
      Returns:
      the priority of the preprocessing threads.
      See Also:
    • setThreadPriority

      public void setThreadPriority(int aThreadPriority)
      sets the priority of the preprocessing threads.
      Parameters:
      aThreadPriority - the priority of the preprocessing threads.
      Throws:
      IllegalStateException - if this preprocessor is preprocessing
      See Also:
    • getCommitFrequency

      public int getCommitFrequency()
      Returns the number of tiles to produce before committing.
      Returns:
      the number of tiles to produce before committing.
    • setCommitFrequency

      public void setCommitFrequency(int aCommitFrequency)
      Sets the number of tiles to produce before committing. A larger commit frequency typically increases efficiency due to less disk access but increases the number of tiles that are lost if the preprocessor is cancelled or aborted.
      Parameters:
      aCommitFrequency - the number of tiles to produce before committing.
      Throws:
      IllegalStateException - if this preprocessor is preprocessing
    • isPreprocessing

      public boolean isPreprocessing()
      Returns whether this preprocessor is currently preprocessing.
      Returns:
      whether this preprocessor is currently preprocessing.
    • synchronizeRepository

      public void synchronizeRepository(ILcdModel aAssetModel, ILcdEarthTileSet aSourceTileSet, ILcdEarthTileSetCoverage[] aSourceCoverages, String[] aTargetCoverageNames, ILcdGeoReference[] aTargetReferences, TLcdEarthTileFormat[] aTargetFormats, ILcdEarthEditableTileSet aTargetTileSet, String aTargetDirectory, ILcdEarthPreprocessorProgressListener aProgressListener) throws IOException
      Synchronizes a repository with the specified metadata. This method will check for each asset whether or not that asset has already been fully processed. If the asset has not been completed yet, preprocessing resumes from the last created tile. If the asset has been modified since the last time it was preprocessed (i.e. if its modification date has changed), it is preprocessed entirely from scratch and any corresponding tiles in the repository are replaced with new ones.
      It is assumed that the given source and target tileset are thread-safe.
      Parameters:
      aAssetModel - the metadata to synchronize the repository with
      aSourceTileSet - the tileset whose tiles are being preprocessed. Its bounds must be in the same reference as aAssetModel.
      aSourceCoverages - the coverages in the source tile set that must bepreprocessed. The coverages must include an ILcdEarthRasterTileSetCoverage to compare the asset's pixel density with.
      aTargetCoverageNames - the names of the source coverages in the target tileset. It must contain 1 entry for each element of aSourceCoverages.
      aTargetReferences - the georeferences in which to generate tiles for each of the coverages. It must contain 1 entry for each element of aSourceCoverages.
      aTargetFormats - the formats in which to generate tiles for each of the coverages. It must contain 1 entry for each element of aSourceCoverages.
      aTargetTileSet - the tileset to be updated. It must have the same grid structure, bounds and reference as aSourceTileSet.
      aTargetDirectory - the directory where the preprocessor can be store data to support resuming. This directory should be unique for each preprocessing session. Normally the directory where the target tileset stores its data is a good choice.
      aProgressListener - a listener that receives progress notifications
      Throws:
      IOException - if the tiles cannot be written to the repository
      IllegalStateException - if this preprocessor is already preprocessing
    • getCombinableTilesSFCT

      protected boolean getCombinableTilesSFCT(ILcdEarthEditableTileSet aTargetTileSet, ILcdEarthTileSetCoverage aTargetCoverage, int aLevel, long aTileX, long aTileY, TLcdEarthTileFormat aTargetFormat, ALcdEarthTile[][] aTilesSFCT) throws IOException
      Collects four tiles to be used with an ILcdEarthTileCombiner. This method is called during preprocessing and determines whether the tile specified by aLevel, aTileX and aTileY can be generated by a combiner or not. To do so, this method attempts to retrieve the 2x2 block of tiles from the next higher level (i.e. aLevel + 1) that corresponds to the desired tile. If all four of these tiles are available, the method returns true and the tiles themselves are stored in aTilesSFCT. The preprocessor will subsequently pass the tiles to a combiner and store the resulting combined tile in the target terrain repository. If any of the four tiles are missing, this method returns false and the preprocessor will request the tile from the source tileset rather than creating it with a combiner.

      Note that this method is only invoked if a suitable combiner for the required tile format has been registered. If this is not the case, all tiles are retrieved from the source tileset.

      Parameters:
      aTargetTileSet - the target tile repository
      aTargetCoverage - the target coverage
      aLevel - the level of the tile that is to be generated
      aTileX - the column index of the tile that is to be generated
      aTileY - the row index of the tile that is to be generated
      aTargetFormat - the format of the tile that is to be generated
      aTilesSFCT - the four tiles that can be used as input to the combiner that will generate the requested tile
      Returns:
      true if it is okay to proceed with the combiner approach, or false if a combiner should not be used and the tile should be requested from the source tileset instead
      Throws:
      IOException - if an error occurs while retrieving the tiles