HttpTileSource

abstract class HttpTileSource(val headers: Map<String, String> = emptyMap(), connectTimeoutMs: Long = 5.seconds.inWholeMilliseconds, requestTimeoutMs: Long = 30.seconds.inWholeMilliseconds, clientConfig: HttpClientConfig<*>.() -> Unit = {}) : TileSource

Base for TileSource implementations that fetch bytes over HTTP. Owns one lazily-built HttpClient so subclasses only have to provide a URL for (z, x, y).

The status interpretation is the contract all WorldWind tile sources share:

  • 2xx non-empty body → TileBlob with ETag / Last-Modified captured.

  • 2xx empty body → TileBlob.EMPTY (server explicitly returned no bytes).

  • 304 → null so the caller keeps its cached copy.

  • 404 → TileBlob.EMPTY (negative-cache sentinel).

  • Anything else → error() so the surrounding decorator's backoff loop fires.

Subclasses translate (z, x, y) into a URL and call fetchTileBlob. They never need to touch the client directly.

Inheritors

Constructors

Link copied to clipboard
constructor(headers: Map<String, String> = emptyMap(), connectTimeoutMs: Long = 5.seconds.inWholeMilliseconds, requestTimeoutMs: Long = 30.seconds.inWholeMilliseconds, clientConfig: HttpClientConfig<*>.() -> Unit = {})

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override 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.