ViewportRefreshDriver

class ViewportRefreshDriver(scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Shared machinery for layers that re-fetch their renderables for the current viewport during render — used by earth.worldwind.ogc.wfs.WfsLayer (network) and BulkFeatureLayer (cache). Encapsulates the subtle parts: padded-sector hysteresis, debounce, the optimistic-sector + cancellation ordering, and the off-thread-build / render-thread-swap handoff.

Threading: onRender runs on the render thread; fetch runs on scope and only writes the volatile pending holder, which the render thread applies — the renderables list is never mutated off-thread while being iterated.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Properties

Link copied to clipboard

Debounce after the viewport settles before fetching, so a continuous pan/zoom collapses to one fetch instead of one per frame.

Link copied to clipboard

Fraction the visible sector is padded by on each side — hysteresis so small pans stay inside the last fetched sector and skip a re-fetch.

Functions

Link copied to clipboard
fun cancel()

Cancel any in-flight fetch and tear down the owned scope.

Link copied to clipboard
fun onRender(visible: Sector, apply: (List<Renderable>) -> Unit, fetch: suspend (Sector) -> List<Renderable>)

Render-thread entry point: apply any completed fetch via apply, then — if visible has left the last fetched (padded) sector — schedule a fresh debounced fetch. apply swaps renderables on the render thread; fetch builds them on scope.