public final class TLfnTileStoreUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Future<?> |
copyCoverage(ALfnCoverage aSourceCoverage,
ALfnTileStore aTargetTileStore,
ILfnImportHandler aHandler)
Copies the given source coverage to the given target Tile Store.
|
static Future<?> |
copyCoverage(ALfnCoverage aSourceCoverage,
ALfnTileStore aTargetTileStore,
String aTargetCoverageId,
ILfnProgressCallback<ALfnTileStore.WriteResult> aCallback)
Copies a given source coverage to a the given target Tile Store with a new ID.
|
static Future<?> |
copyCoverageTileData(ALfnCoverage aSourceCoverage,
ALfnCoverage aTargetCoverage,
ILfnImportHandler aHandler)
Deprecated.
|
static void |
createTileStore(File aTileStoreDir,
ALfnEnvironment aEnvironment)
Creates a new, empty Tile Store at the given path.
|
static double |
getAssetPartPixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata,
TLfnRasterAssetMetadata aAssetMetadata,
TLfnRasterAssetMetadata.RasterAssetPart aAssetPart)
Gets the asset part pixel density expressed in the coverage's georeference.
|
static double |
getMaxAssetPartPixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata,
ALfnTileStore aTileStore)
Gets the maximum pixel density of all the asset parts of all the assets of a coverage,
expressed in the coverage's georeference.
|
static double |
getMaxCoveragePixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata,
ALfnTileStore aTileStore)
Gets the maximum coverage pixel density for a given coverage.
|
static TLfnRasterAssetMetadata.Builder |
newCoverageAsAssetMetadataBuilder(TLfnRasterCoverageMetadata aCoverageMetadata,
ALfnTileStore aTileStore)
Creates a new asset metadata builder for a given coverage metadata.
|
static TLfnRasterAssetMetadata.Builder |
newCoverageAsAssetMetadataBuilder(TLfnRasterCoverageMetadata aCoverageMetadata,
double aPixelDensity,
ALfnTileStore aTileStore)
Deprecated.
|
static void |
optimizeTileLayout(ALfnCoverageMetadata aSource,
ALfnCoverageMetadata.Builder<?> aTarget)
Optimizes the tile layout of the target coverage, using the tile size of the source coverage
and the bounding box of the target coverage as a given.
|
static void |
optimizeTileSize(TLfnRasterCoverageMetadata aSource,
TLfnRasterCoverageMetadata.Builder aTarget)
Optimizes the tile size of the target coverage, using the tile size of the source coverage and
the tile layout of the target coverage as a given.
|
public static void createTileStore(File aTileStoreDir, ALfnEnvironment aEnvironment) throws IOException
Creates a new, empty Tile Store at the given path.
UUID
aTileStoreDir
- The root of the new Tile StoreaEnvironment
- The environmentIOException
- If the Tile Store could not be createdpublic static Future<?> copyCoverage(ALfnCoverage aSourceCoverage, ALfnTileStore aTargetTileStore, ILfnImportHandler aHandler)
copyCoverage(ALfnCoverage, ALfnTileStore, String, ILfnProgressCallback)
.aSourceCoverage
- the source coverage to be copiedaTargetTileStore
- the Tile Store to which the source coverage should be copiedaHandler
- a handler for progress and error reportingpublic static Future<?> copyCoverage(ALfnCoverage aSourceCoverage, ALfnTileStore aTargetTileStore, String aTargetCoverageId, ILfnProgressCallback<ALfnTileStore.WriteResult> aCallback)
ALfnCoverageMetadata.AssetInfo.STATUS_INCOMPLETE
, and when
the operation completes successfully they will be set to ALfnCoverageMetadata.AssetInfo.STATUS_COMPLETE
.
aSourceCoverage
- the source coverage, never null
aTargetTileStore
- the target Tile Store, which may be the same as the source coverage's Tile Store, but never null
aTargetCoverageId
- the target coverage ID, or null
to indicate that the target coverage ID must be the same as the source coverage IDaCallback
- a callback for progress and error reportingpublic static Future<?> copyCoverageTileData(ALfnCoverage aSourceCoverage, ALfnCoverage aTargetCoverage, ILfnImportHandler aHandler)
copyCoverage(ALfnCoverage, ALfnTileStore, String, ILfnProgressCallback)
insteadcopyCoverage(ALfnCoverage, ALfnTileStore, String, ILfnProgressCallback)
because it not user-friendly:
ALfnCoverageMetadata.AssetInfo.STATUS_INCOMPLETE
before calling this method.
If not, the tile data on the target coverage will not become visible afterwards.
ALfnCoverageMetadata.AssetInfo.STATUS_COMPLETE
when the future of this method completed successfully.
If not, the tile data on the target coverage will not become visible afterwards.
ALfnTileStore tileStore;
ALfnCoverage source = tileStore.getCoverage("id");
ALfnCoverageMetadata sourceMetadata = source.getMetadata();
List<AssetInfo> assetInfos = sourceMetadata.getAssetInfos();
// You'll have to implement copyAllAssetInfosAndSetTo yourself.
List<AssetInfo> incompleteAssetInfos = copyAllAssetInfosAndSetTo(assetInfos, STATUS_INCOMPLETE);
ALfnCoverageMetadata incompleteTargetMetadata = source.getMetadata().asBuilder().id("newId")
.assetInfos(incompleteAssetInfos).build();
tileStore.putResourceMetadata(incompleteTargetMetadata);
ALfnCoverage target = tileStore.getCoverage(targetMetadata.getId());
copyCoverageTileData(source, target, handler).get();
List<AssetInfo> completeAssetInfos = copyAllAssetInfosAndSetTo(assetInfos, STATUS_COMPLETE);
ALfnCoverageMetadata completeTargetMetadata = target.getMetadata().asBuilder()
.assetInfos(completeAssetInfos).build()
tileStore.putResourceMetadata(completeTargetMetadata);
aSourceCoverage
- the source coverage to be copiedaTargetCoverage
- the target coverage to copy the data toaHandler
- a handler for progress and error reportingpublic static double getMaxAssetPartPixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata, ALfnTileStore aTileStore) throws IOException, TLfnServiceException
0.0
. In case there
are no asset parts, the result of this method will be NEGATIVE_INFINITY
.aCoverageMetadata
- the coverage metadata linking to the assets to get the asset parts
fromaTileStore
- a Tile Store where the asset metadata will be retrieved fromNEGATIVE_INFINITY
in case there are no asset parts, and possibly 0.0
in case
no asset parts have a pixel density that can be expressed in the coverage's
georeference.IOException
- indicates something went wrong retrieving the asset metadata from
the Tile StoreTLfnServiceException
- indicates something went wrong retrieving the asset metadata from
the Tile Storepublic static double getAssetPartPixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata, TLfnRasterAssetMetadata aAssetMetadata, TLfnRasterAssetMetadata.RasterAssetPart aAssetPart)
TLfnRasterAssetMetadata.RasterAssetPart.getPixelDensity()
. In case the asset part's pixel density could not be
expressed in the coverage's georeference, this method returns 0.0
.aCoverageMetadata
- the coverage metadata defining the georeference to express pixel
densities in (target georeference)aAssetMetadata
- the asset metadata defining the georeference the asset parts' pixel
densities are expressed in (source georeference). The coverage
metadata should have an asset info about this asset, although this
method does not enforce this.aAssetPart
- the asset part to get the pixel density of. This asset part should be
part of the asset metadata, although this method does not enforce
this.0.0
in case the asset part's pixel density could not be expressed in the
coverage's georeferencepublic static double getMaxCoveragePixelDensity(TLfnRasterCoverageMetadata aCoverageMetadata, ALfnTileStore aTileStore) throws IOException, TLfnServiceException
maxCoveragePixelDensity > maxAssetPartPixelDensity
. This means that the pixel densities of all
asset parts are lower than the coverage pixel density at level 0. In this case, level 0 is the
maximum level and the coverage pixel density is the pixel density at level 0. All other
cases are considered non-degenerate, and for those cases the following is true:
maxAssetPartPixelDensity <= maxCoveragePixelDensity < (4 *
maxAssetPartPixelDensity)
.aCoverageMetadata
- the metadata describing the coverage to get the maximum coverage pixel
density ofaTileStore
- the Tile Store to get the asset metadata fromIOException
- indicates something went wrong retrieving the asset metadata from
the Tile StoreTLfnServiceException
- indicates something went wrong retrieving the asset metadata from
the Tile Storepublic static void optimizeTileLayout(ALfnCoverageMetadata aSource, ALfnCoverageMetadata.Builder<?> aTarget)
The intended use of this method is to prepare a coverage for cropping. The new bounding box is expected to have already been set on the target coverage metadata builder, for it will be used for the optimization.
aSource
- the source coverage metadataaTarget
- the target coverage metadata (cropped) of which the level-0 row- and column
counts will be optimizedpublic static void optimizeTileSize(TLfnRasterCoverageMetadata aSource, TLfnRasterCoverageMetadata.Builder aTarget)
The intended use of this method is to prepare a coverage for cropping. The new bounding box and tile layout are expected to have already been set on the target coverage metadata builder, for they will be used as input for the optimization.
aSource
- the source coverage, of which the bounding box, level-0 row- and column count,
tile width and height are used as inputsaTarget
- the target coverage, of which the bounding box, level-0 row- and column count
are used as inputs, and on which the optimized tile width and height will be
written as outputpublic static TLfnRasterAssetMetadata.Builder newCoverageAsAssetMetadataBuilder(TLfnRasterCoverageMetadata aCoverageMetadata, double aPixelDensity, ALfnTileStore aTileStore)
newCoverageAsAssetMetadataBuilder(TLfnRasterCoverageMetadata,
ALfnTileStore)
insteadaCoverageMetadata
- the coverage metadata to be used as input for the asset. Currently,
only TLfnRasterCoverageMetadata
is supported.aPixelDensity
- unusedaTileStore
- a Tile Store to build the asset's location (URI) from, and to retrieve
the original asset metadata frompublic static TLfnRasterAssetMetadata.Builder newCoverageAsAssetMetadataBuilder(TLfnRasterCoverageMetadata aCoverageMetadata, ALfnTileStore aTileStore) throws IOException, TLfnServiceException
aCoverageMetadata
- the original coverage metadataaTileStore
- a Tile Store to build the asset's location (URI) from, and to retrieve
the original asset metadata fromIOException
- if there was a failure retrieving the metadata of one of the
original assets from the Tile StoreTLfnServiceException
- if there was a failure retrieving the metadata of one of the
original assets from the Tile Store