WebContentManager

class WebContentManager(databaseName: String = DEFAULT_DATABASE_NAME) : ContentManager

IndexedDB-backed ContentManager for the JS target. Implements every method of the ContentManager contract — image / vector / coverage tile stores, feature stores (bulk + tile-addressed), and web-service metadata.

Schema (one IDB database per WebContentManager, named pathName):

  • image_tiles, vector_tiles, coverage_tiles — tile blob stores keyed by [contentKey, z, x, y]. One store per data type covers every layer; no per-content-key store proliferation.

  • features — feature rows with auto-increment id; indexes byTile [contentKey, z, x, y] (tile-addressed reads) and byContent contentKey (bulk reads + per-content cleanup).

  • metadata — WebServiceInfo records keyed by content key. Walked by listEntries.

The cached-layer dispatcher (see OpenCachedLayer.kt in commonMain — reified openLayer / openElevationCoverage plus CachedLayerRegistry). The WFS arm currently depends on mil.nga.sf). JS callers can still inspect listEntries / findEntry and construct their own layers per service type.

Constructors

Link copied to clipboard
constructor(databaseName: String = DEFAULT_DATABASE_NAME)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val isClosed: Boolean

True after close has been called. Subsequent suspend calls on a closed manager throw — the underlying connection is gone.

Link copied to clipboard
open override val isReadOnly: Boolean = false

When true, every write throws.

Link copied to clipboard
open override val pathName: String

Filesystem path / database file of the underlying cache.

Functions

Link copied to clipboard
suspend fun ContentManager.attachCache(layer: TiledImageLayer, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED)

Register a tiled image layer (WMS / WMTS / WebMercator).

suspend fun ContentManager.attachCache(layer: VectorLayer, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED)

Register a vector layer. Dispatches by concrete subtype to record the right service-identity row:

suspend fun ContentManager.attachCache(coverage: TiledElevationCoverage, contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, isFloat: Boolean = false)

Register a tiled elevation coverage.

Link copied to clipboard
open suspend override fun clearEntry(contentKey: String)

Truncate one content entry's tile / feature payload while keeping its registration intact — the WebServiceInfo row, the persisted level-set / tile-matrix-set, the display name, the isFloat choice, and any other per-content metadata stay so the caller can re-download tiles without re-configuring the layer.

Link copied to clipboard
open suspend override fun close()

Release the underlying connection (SQLite handle on JVM, IDB on JS, no-op on iOS). Idempotent. After close returns, isClosed is true and every other suspend method on this manager throws.

Link copied to clipboard

Wrap one contentKey inside this ContentManager as a ContentEntry. Mirrors findEntry(key) for read-only inspection plus clearEntry / deleteEntry for lifecycle, behind one uniform surface.

Link copied to clipboard
open suspend override fun contentSize(): Long

Total on-disk size of the cache database.

Link copied to clipboard
open suspend override fun createElevationSourceFactory(contentKey: String, tileMatrixSet: TileMatrixSet, networkSource: TileSource?, outputFormat: String, isFloat: Boolean = false, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, displayName: String? = null): ElevationSourceFactory

Build an ElevationSourceFactory backed by this content manager's elevation cache. The factory owns the source-format → storage-format transcoding for every tile — callers just supply the network source (or null for offline replay) and the desired storage layout via isFloat.

Link copied to clipboard
open suspend override fun deleteEntry(contentKey: String)

Delete one content entry — drops the table(s), the web-service row, and the contents-table row. Use clearEntry instead when the caller wants to keep the layer registered for a re-download.

Link copied to clipboard
open suspend override fun findEntry(contentKey: String): CacheEntry?

Look up a single content entry by contentKey, or null if absent. Lightweight — same shape as one element of listEntries.

Link copied to clipboard
open suspend override fun lastModifiedDate(): Instant?

Most-recent registerWebService timestamp across all content keys. Per-content timestamps live on the WebServiceInfo records and are surfaced via listEntries / findEntry.

Link copied to clipboard
open suspend override fun listEntries(): List<CacheEntry>

Enumerate every cached content entry. Lightweight — does not construct layers or read row data, only metadata.

Link copied to clipboard
suspend fun <T : Any> ContentManager.open(category: CacheCategory<T>, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED): List<T>

Bulk-open every cached entry whose CacheEntry.dataType matches category. Return type follows the category's phantom witness:

Link copied to clipboard
open suspend override fun openBlobStore(contentKey: String, evictionPolicy: CachePolicy = CachePolicy.UNBOUNDED, displayName: String? = null): BlobStore

IndexedDB-backed BlobStore for 3D Tiles payloads. Shares the BLOB_STORE_OGC3D object store across every dataset; records are namespaced by contentKey via the composite key [contentKey, uri].

Link copied to clipboard
inline suspend fun <T : ElevationCoverage> ContentManager.openElevationCoverage(contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED): T?

Open contentKey as an elevation coverage narrowed to T. Returns null when the key is absent, registered as a layer (use openLayer), or the materialized type doesn't match T. Bound is the broad ElevationCoverage interface for symmetry with openLayer's Layer bound; today only TiledElevationCoverage subtypes are reachable from cache, so non-tiled-typed callers always get null.

Link copied to clipboard
open suspend override fun openFeatureStore(contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, displayName: String? = null): FeatureStore

Open (or create) a FeatureStore for vector-feature data — backed by data_type='features' in the GPKG schema. Used by WFS, Shapefile (bulk rows) and OsmBuildings (tile-addressed rows) in the same store shape.

Link copied to clipboard
open suspend override fun openImageTileStore(contentKey: String, levelSet: LevelSet, imageFormat: String = "image/png", isTransparent: Boolean = false, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, displayName: String? = null): TileStore

Open (or create) a TileStore for image-tile data — backed by data_type='tiles' in the GPKG schema. Used by WMS/WMTS/WebMercator and any other raster layer that fetches PNG/JPEG/WebP bytes. Re-opening the same contentKey returns a store compatible with the previously persisted LevelSet (validates compatibility).

Link copied to clipboard
inline suspend fun <T : Layer> ContentManager.openLayer(contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED): T?

Open contentKey as a layer narrowed to T. Returns null when the key is absent, unregistered, backed by an elevation coverage (use openElevationCoverage), or the materialized type doesn't match T.

Link copied to clipboard
suspend fun ContentManager.openOgc3dTilesLayer(contentKey: String, authOverride: TilesetAuthProvider? = null, evictionPolicy: CachePolicy = CachePolicy.UNBOUNDED): Ogc3dTilesLayer?

Reopen an Ogc3dTilesLayer from a ContentManager entry registered by an earlier openBlobStore(...) + registerWebService(...) pair. Reads the persisted earth.worldwind.layer.cache.WebServiceInfo (root URI in .address, auth-provider class name in .layerName, credentials JSON in .metadata) and rebuilds the layer end-to-end so the caller only has to do engine.layers.addLayer(layer).

Link copied to clipboard
open suspend override fun openVectorTileStore(contentKey: String, levelSet: LevelSet, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED, displayName: String? = null): TileStore

Open (or create) a TileStore for vector-tile data — backed by data_type='vector-tiles' (im_vector_tiles_mapbox extension). Used by MVT layers that store raw protobuf bytes per tile.

Link copied to clipboard
open suspend override fun registerWebService(contentKey: String, info: WebServiceInfo)

Persist web-service metadata for contentKey in the GPKG gpkg_web_service extension table. Capabilities XML/JSON in WebServiceInfo.metadata survives across launches so the layer can be reconstructed without an online capabilities request.

Link copied to clipboard
open suspend override fun setDisplayName(contentKey: String, displayName: String)

Overwrite the user-visible display name for contentKey. No-op when the content key doesn't exist or the manager is read-only.

Link copied to clipboard
open suspend override fun sizeBytesOf(contentKey: String): Long

Per-content size by data type: walks the right IDB object store via the same impls the public stores expose, so the result matches what the per-store TileStore.sizeBytes / FeatureStore.sizeBytes would report.

Link copied to clipboard
open suspend fun tryOpenNativeContent(entry: CacheEntry): Any?

Open a cached layer/coverage for a CacheEntry that has no registered web service — i.e. the content was imported directly into the cache (e.g. a standalone .gpkg file with no gpkg_web_service row). Returns null when the backend can't construct a layer in this mode.

Link copied to clipboard
open suspend fun tryRecoverLevelSet(contentKey: String): LevelSet?

Recover the pyramid LevelSet for an image / vector-tile cache, or null when the backend can't reconstruct one (e.g. JS / iOS where the schema doesn't persist the level-set descriptors). Used by the cross-platform reopen dispatcher to rebuild a layer's level-set after restart; callers fall back to a sensible default (slippy-map 0..21) when this returns null.

Link copied to clipboard
open suspend fun tryRecoverTileMatrixSet(contentKey: String): TileMatrixSet?

Recover the TileMatrixSet for a coverage cache, or null when the backend can't reconstruct one. Mirrors tryRecoverLevelSet for elevation coverages.