GpkgCachedElevationSourceFactory

class GpkgCachedElevationSourceFactory(geoPackage: GeoPackage, content: GpkgContent, networkSource: TileSource?, outputFormat: String, isFloat: Boolean, tileMatrixSet: TileMatrixSet, elevationDecoder: ElevationDecoder = ElevationDecoder(), staleAfter: ERROR CLASS: Symbol not found for Duration = Duration.INFINITE, revalidationScope: ERROR CLASS: Symbol not found for CoroutineScope = GlobalScope) : ElevationSourceFactory, OfflineToggleable, CachedSourceInfoProvider, BulkRetrievableElevationSourceFactory, CacheReadableElevationSourceFactory, RevalidatingSource

Elevation source factory that pairs a GeoPackage cache with an optional upstream TileSource. Owns the source-format → storage-format transcoding end-to-end.

On cache miss the factory fetches bytes from networkSource (decoded via outputFormat) and writes them into the gpkg in the storage layout dictated by isFloat:

  • isFloat = true → TIFF-Float32 blob, gpkg_2d_gridded_tile_ancillary.scale = 1, offset = 0. Lossless for Float32 sources; widening for Int16 sources.

  • isFloat = false → PNG-Int16 blob with per-tile (scale, offset) packed from the in-memory FloatBuffer directly — the lossy step is the 16-bit quantization ((max - min) / 65535 per code), never a WorldWind ShortArray rounding step. Int16 sources are written as-is with scale = 1, offset = 0.

Read path is the inverse: PNG with non-trivial scale/offset decodes to a FloatBuffer preserving the storage precision; PNG with (1, 0) decodes to a ShortBuffer; TIFF-Float32 decodes to a FloatBuffer. The single ShortArray conversion that WorldWind's render pipeline requires happens downstream in ElevationDecoder.decodeBuffer, not inside this factory.

Set networkSource = null for offline replay (cache hits served, misses return null).

Constructors

Link copied to clipboard
constructor(geoPackage: GeoPackage, content: GpkgContent, networkSource: TileSource?, outputFormat: String, isFloat: Boolean, tileMatrixSet: TileMatrixSet, elevationDecoder: ElevationDecoder = ElevationDecoder(), staleAfter: ERROR CLASS: Symbol not found for Duration = Duration.INFINITE, revalidationScope: ERROR CLASS: Symbol not found for CoroutineScope = GlobalScope)

Properties

Link copied to clipboard
open override val cacheInfo: CachedSourceInfo
Link copied to clipboard
open override val contentType: String

Unique elevation source factory content type name

Link copied to clipboard
open override var isCacheOnly: Boolean

When true, the factory never calls networkSource — cache hits are served as usual; cache misses return null from fetchElevationData. Toggleable at runtime so a single layer can flip between online and offline modes without re-wiring its source factory. Shares the earth.worldwind.layer.cache.OfflineToggleable interface with earth.worldwind.layer.cache.CachedTileSource so app-level offline toggles dispatch generically.

Link copied to clipboard
open override var onTileRevalidated: (z: Int, x: Int, y: Int) -> Unit?

Invoked (off the render thread, with the tile's (matrix ordinal, column, row)) after a stale tile is re-downloaded; the coverage wires this to drop the tile's cached array, bump its timestamp, and request a redraw so the tessellator re-pulls the fresh tile.

Functions

Link copied to clipboard
open override fun createElevationSource(tileMatrix: TileMatrix, row: Int, column: Int): ElevationSource
Link copied to clipboard
open suspend override fun fetchAndCacheTile(z: Int, x: Int, y: Int, overrideCache: Boolean = false): Boolean

Bulk-download path: bypass isCacheOnly and force a network fetch + persist on cache miss. When overrideCache is true, also skip the cache hit short-circuit so every tile is re-downloaded. See earth.worldwind.layer.cache.CachedElevationSourceFactory.fetchAndCacheTile for the motivating contract.

Link copied to clipboard
open suspend override fun readCachedTileImage(tileMatrix: TileMatrix, row: Int, column: Int): ElevationImage?