CachedElevationSourceFactory

class CachedElevationSourceFactory(backend: ElevationStoreBackend, networkSource: TileSource?, networkDecoder: NetworkBytesDecoder, val outputFormat: String, val isFloat: Boolean, tileMatrixSet: TileMatrixSet, staleAfter: Duration = Duration.INFINITE, revalidationScope: CoroutineScope = GlobalScope) : ElevationSourceFactory, OfflineToggleable, CachedSourceInfoProvider, BulkRetrievableElevationSourceFactory, CacheReadableElevationSourceFactory, RevalidatingSource

Cross-platform ElevationSourceFactory backed by an ElevationStoreBackend + an optional upstream TileSource. Owns the source-format → storage-format transcoding pipeline (encode/decode via ElevationStorageCodec) so platforms (JS, iOS) don't have to reimplement it.

Platform-specific bits are deliberately small:

  • backend handles "where do the bytes live" (IDB / filesystem / etc.).

  • networkDecoder handles "how to decode the wire format" (each platform has its own BIL/TIFF/DTED decode path). The factory itself stays in commonMain.

Used by WebContentManager.createElevationSourceFactory (JS) and IosContentManager.createElevationSourceFactory (iOS). JVM keeps its own gpkg-bound factory (GpkgCachedElevationSourceFactory) because the GeoPackage ancillary-table layout doesn't fit the simple (scale, offset) shape the backend interface exposes.

Constructors

Link copied to clipboard
constructor(backend: ElevationStoreBackend, networkSource: TileSource?, networkDecoder: NetworkBytesDecoder, outputFormat: String, isFloat: Boolean, tileMatrixSet: TileMatrixSet, staleAfter: Duration = Duration.INFINITE, revalidationScope: 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
Link copied to clipboard
Link copied to clipboard
open override var onTileRevalidated: (z: Int, x: Int, y: Int) -> Unit?

Invoked (off the render thread, with (matrix ordinal, column, row)) after a stale tile is re-downloaded; the coverage wires this to drop the cached array + redraw.

Link copied to clipboard

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: by default skip already-cached tiles, otherwise force a network fetch and persist. Bypasses isCacheOnly — bulk is user-initiated and orthogonal to the renderer's offline toggle. Returns true on cache hit / successful fetch + write, false on cache miss + (no network / fetch failure / decode failure). When overrideCache is true, the cache hit short-circuit is skipped and every tile is re-downloaded.

Link copied to clipboard
suspend fun fetchTile(z: Int, x: Int, y: Int): ShortArray?

Fetch one tile through the cache. Reads the encoded blob from backend; on cache miss falls through to networkSource, decodes via networkDecoder, transcodes via ElevationStorageCodec, persists to backend, returns the rendered ShortArray.

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