TileSource

interface TileSource

A source of byte-encoded tiles indexed by slippy-map (z, x, y). Implementations:

  • HTTP — wraps a URL template, performs conditional GET when previousEtag / previousLastModified are supplied (so a follow-up replay through a cache decorator can revalidate cheaply).

  • Cache-decorated — wraps a network source plus a TileStore. Returns cached blobs on hit; on miss falls back to the inner network source.

  • Cache-only — returns null for any tile the cache doesn't have. Useful for replaying a GPKG offline.

Returns null when the tile is unavailable (network error, out-of-bounds, cache miss). Use TileBlob.EMPTY to encode "definitely no tile" so callers can cache the negative answer without confusing it with a transient miss.

Inheritors

Functions

Link copied to clipboard
open fun close()

Release any resources held by the source (HTTP client, etc.). Idempotent default no-op.

Link copied to clipboard
abstract suspend fun fetchTile(z: Int, x: Int, y: Int, previousEtag: String? = null, previousLastModified: String? = null): TileBlob?
Link copied to clipboard
fun TileSource.launchBulkRetrieval(levelSet: LevelSet, sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job

Download every tile that intersects sector across every level whose resolution falls in resolution — typically used by "save a region for offline use" flows. Returns the launched Job so the caller can cancel mid-download.

Link copied to clipboard
open suspend fun tryReadCachedTile(z: Int, x: Int, y: Int): TileBlob?

Cache-only fast-path read for (z, x, y). Default returns null — a plain network source has no cache to consult. Cache-backed sources override to read their store without going through the network-fetch concurrency budget.