import { MapLibreOverlay as DeckOverlay } from '@deck.gl/maplibre'; import { COGLayer } from '@developmentseed/deck.gl-geotiff'; import type { DecoderPool, GeoTIFF } from '@developmentseed/geotiff'; import type { AddLayerObject, LngLatBoundsLike, MapLibreMap } from 'maplibre-gl'; import MapPreviewer from './map'; import { type ScalarRange, type ScalarTileData } from '../cog-pipeline'; import type CogResource from '../resources/cog'; import { type LayerState, type PreviewStyleLayer } from '../layers'; import type { MapLibreStyle } from '../themes/maplibre'; export default class CogPreviewer extends MapPreviewer { protected resource: CogResource; readonly reportsDrawing = true; protected deckOverlay: DeckOverlay | undefined; protected decoderPool: DecoderPool | undefined; protected drawnState: LayerState | undefined; protected geotiffBoundsLoaded: Promise | undefined; private resolveGeotiffBounds; protected geotiff: GeoTIFF | undefined; protected valueRange: ScalarRange | undefined; protected anyTileDrawn: boolean; attach(map: MapLibreMap, style: MapLibreStyle): this; /** * Tell the overlay the map's projection changed, because MapLibre doesn't tell it in a way it * hears. * * @deck.gl/maplibre decides between a MapView and a GlobeView by asking the map which projection * it is in, and it asks in two places: whenever its own props are set, and on 'styledata'. * setProjection() announces itself as 'projectiontransition' and raises no 'styledata' at all, so * a reader pressing the globe button off leaves the overlay drawing through the GlobeView it was * built with while MapLibre has gone back to drawing flat. The COG is then drawn in the wrong * place - 12px out at zoom 4, 80px at zoom 3 - and stays there: no pan, zoom or later frame puts * it back, because none of them is a style change either. * * Handing the overlay its layers again is the nudge, since setProps is one of the two places it * re-reads the projection. Cheap: deck.gl matches the layer by id and updates props in place, so * the tiles already decoded are kept. * * Remove this when @deck.gl/maplibre watches 'projectiontransition' itself. * * Taken off first for the same reason EsriFeatureLayerPreviewer does it: a theme change draws * this preview again into a rebuilt style document with no clearPreview between, and that must * leave one listener rather than two. */ protected watchProjection(): void; private stopWatchingProjection; private handleProjectionTransition; protected createSources(): Promise<[]>; protected createLayers(): Promise; protected getLayerId(): string; preview(): Promise; protected loadGeoTIFF(): Promise; clearPreview(): Promise; protected applyStyleLayerState(_styleLayer: PreviewStyleLayer, state: LayerState): void; protected drawDeckLayer(): void; protected createDeckLayer(geotiff: GeoTIFF, state: LayerState): COGLayer | COGLayer; protected reportTileDrawn(): void; protected reportTileError(error: unknown): void; protected createDecoderPool(): DecoderPool; getBounds(): Promise; protected getDeckOverlay(): DeckOverlay; }