FIMViz.jsAPI
    Preparing search index...

    Class RasterLayer

    Hierarchy (View Summary)

    Index
    _dirty: boolean
    _emitter: any
    _map: FimMap
    _name: any
    _onScaleChange: () => void
    _origin: Dataset[]
    _removed: boolean
    _teardown: any
    colorScale: ColorScale
    exclusive: any
    id: string
    loadSeq: number
    meta: {
        be: any;
        bn: any;
        bs: any;
        bw: any;
        height: any;
        noData: any;
        unit: any;
        width: any;
    }
    moveListener: () => void
    noData: any
    opacity: any
    overlay: any
    raster: any
    rasterData: any
    result: any
    sources: Dataset[]
    type: string
    visible: boolean
    • get _providerHandle(): any

      Returns any

      the raster-image overlay handle.

    • get dirty(): boolean

      Has an op been applied that the last render() has not drawn yet?

      Returns boolean

    • get settings(): LayerSettings

      This layer's settings knobs. Lazily built; subclasses override _makeSettings() to supply Raster/Vector knobs. Mutating a knob (layer.set({...})) emits the effect event (restyle/recomputed) and re-renders when live.

      Returns LayerSettings

    • Adopt a handle the provider REPLACED (Google recreates ground overlays to restack them).

      Parameters

      • handle: any

      Returns void

    • The geographic footprint { north, south, east, west } (from meta, else the grid).

      Returns any

    • Strict CRS precondition: every source Dataset whose native CRS the active provider CANNOT render blocks the render with an actionable error, AND emits a host event so the app can react (toast, or auto-reproject as an app-tier policy). Mechanism here; policy in the host — the engine never silently reprojects.

      Returns void

    • Draw this raster on the map: resolve a ColorScale (see _resolveColorScale) if none is attached yet, colorize the materialized grid with it → a canvas data URL → position it over the grid's bounds through the map provider. mode === 'in-place' swaps the existing overlay's image (no flicker); otherwise it removes-and-re-adds. Provider-neutral — the SDK-specific work is all behind addRasterImage/setRasterImageUrl. Populates rasterData/meta (hover read-model) from the grid and installs a teardown that removes the overlay. Fires rendered with the grid + data URL.

      Parameters

      • Optionalopts: any = {}

        { mode?: 'in-place'|'recreate', raster?: Object } — raster overrides this layer's projection/budget options for one draw (see RasterLayer#raster)

      Returns void

    • Does this layer have at least one listener for evt? Lets the map dispatch skip uninterested layers.

      Parameters

      • evt: string

      Returns boolean

    • Apply one Dataset op across every source, immediately. Invalidates the memoized compute and marks the layer dirty; draws nothing until render().

      Parameters

      Returns Layer

    • Resolve the ColorScale to colorize with, in precedence order — (1) EXPLICIT: already attached (a host called set({ colorScale }), or passed { colorScale } to the "raster" factory) — untouched; (2) GDAL-EMBEDDED: a GDAL_METADATA legend in the file, auto-detected via ColorScale's registered parser (layers/depthMap.js supplies it — see registerGdalLegendParser); (3) DEFAULT: a continuous scale (ColorScale's own default palette) ranged to the grid's own min/max. Whichever is chosen is attached to the layer, so getLegend()/getStats() reflect what's actually drawn in EVERY case — never a silently-discarded fallback. This runs synchronously within the current render pass (before the image is drawn), not reactively after — so there is no window where a generic default draws first and a correct GDAL legend never gets applied because nothing repaints on its own.

      Parameters

      Returns any[]

      the raw parsed GDAL legend, if one was detected (for the 'rendered' event's originalLegend) — null in the explicit or default cases.

    • Resolve the render update mode. An explicit 'in-place'/'recreate' wins; 'auto' asks provider CAPABILITY (does it expose setRasterImageUrl?) + layer TYPE (does this layer render a swappable raster image?). Vector layers and providers without in-place swap fall back to recreate.

      Parameters

      • requested: string

      Returns "in-place" | "recreate"

    • Crop to a bbox.

      Parameters

      • bbox: { east: number; north: number; south: number; west: number }

      Returns Layer

    • Compute this layer's render-ready result. Default: force the primary source Dataset into its decoded grid/features and memoize it on this.result. Subclasses override to align+reduce.

      Parameters

      • Optionalopts: any = {}

      Returns Promise<any>

    • "Hot-modify": derive new sources FROM the current ones and swap them in. Because the derived Dataset shares memoized ancestors with the old, only the changed tail recomputes — a cheap live tweak (e.g. re-classify with a new threshold) versus a cold source swap. Sugar over setSources.

      Parameters

      Returns Promise<Layer>

    • Fire evt. Listeners receive { ...payload, layer: this }.

      The event goes to TWO places, so these two subscriptions see the same event:

      layer.on('rendered') — this ONE layer's lifecycle (per-object subscription) fim.on('userRaster:rendered') — ANY layer of that type on this map (per-map subscription)

      The per-map form is derived from the per-layer one by forwarding under ${type}:${evt}, so a new layer type gets it with no extra wiring.

      Forwarding is skipped when the layer has no type (nothing to namespace with) or no owning map. Subsystems that emit on the map bus directly (velocity/ensemble/depth emit their own *:activated names) are unaffected — those are distinct event names, so nothing double-fires.

      Parameters

      • evt: string
      • Optionalpayload: any = {}

      Returns Layer

    • Wire a live hover readout: subscribes to the map provider's mouse-move, looks up valueAt() on every move, and emits 'hover' with a ready-to-display {lat, lng, value, text}. Idempotent — calling again replaces the previous subscription rather than stacking listeners. Opt-in, not wired automatically on render — a layer nobody hovers shouldn't pay for a mousemove listener. Torn down automatically on remove() (see _draw()'s _teardown).

      Standardizes what layers/depthMap.js's DepthLayer used to hand-roll inline — its own copy of the bounds/row/col lookup this method now shares via valueAt(). The one thing this does NOT generalize: treating an otherwise-valid VALUE as "nothing to report" (depth's v === 0 domain rule — zero depth reads as no flooding) is a caller concern, not the mechanism's — pass isEmpty for that.

      Parameters

      • Optionalopts: {
            formatValue?: (v: number) => string;
            isEmpty?: (v: number) => boolean;
            noDataTolerance?: number;
        } = {}
        • OptionalformatValue?: (v: number) => string

          value → display text. Defaults to String(v).

        • OptionalisEmpty?: (v: number) => boolean

          an in-range value to ALSO treat as absent (event.value becomes null, same as outside the footprint) — e.g. a domain "zero means nothing" rule that isn't really about noData.

        • OptionalnoDataTolerance?: number

          forwarded to valueAt().

      Returns RasterLayer

    • Statistics over this raster's pixels, classified by the attached ColorScale when present (so the histogram buckets line up with the legend). Null until pixels are loaded.

      Parameters

      • Optionalopts: any = {}

      Returns Promise<Stats>

    • Hide the overlay on the map (opacity → 0 via the provider; the overlay itself is NOT torn down, so show() is instant). The base Layer.hide() only flips .visible — that alone doesn't touch anything the provider drew, so a raster overlay stayed visible on the map through it. Chainable.

      Returns RasterLayer

    • PIXEL-LEVEL hit-test (PACKAGE_ROADMAP §1): true only where a real (non-noData) pixel sits under the point. A click over a transparent/noData part of the footprint therefore falls THROUGH to the layers below, instead of the whole bounding rectangle absorbing it.

      Parameters

      • lat: number
      • lng: number

      Returns boolean

    • Pixels outside polygon (or inside, with {invert:true}) become noData.

      Parameters

      • polygon: any
      • Optionalopts: any

      Returns Layer

    • Parameters

      • evt: string
      • fn: (payload: any) => void

      Returns void

    • NOT chainable, on purpose. rasterize changes a Dataset's kind (vector → raster), and this layer draws the kind it was built for — returning this would leave a VectorLayer pointing at a raster it cannot draw. Do it on the Dataset and add the result as its own layer.

      Returns never

    • Remap pixel values by rules or a callback.

      Parameters

      • rules: Function | any[]
      • Optionalopts: any

      Returns Layer

    • Tear down render, emit 'removed', then unregister from the owning FimMap. Subclasses super.remove() last. If a _teardown hook was assigned (transitional: user-file Layers built inline in floodExtent carry their google.maps teardown here instead of in a dedicated subclass), it runs once before the event. 'removed' fires SYNCHRONOUSLY here — a subscriber (the tools panel) reacts now, not on google.maps' later onRemove() frame, which is what makes layer switches deterministic instead of racing.

      Parameters

      • __namedParameters: { purgeSource?: boolean } = {}

      Returns void

    • Render this layer: compute if needed, enforce the provider CRS precondition, then draw. opts.render picks the update mechanism — 'in-place' (swap the overlay's image, no flicker, keeps z-order/ identity), 'recreate' (teardown + redraw), or 'auto' (default: in-place when the provider + this layer's render type support it, else recreate). Claims the exclusive display slot on success when this.exclusive.

      Parameters

      • Optionalopts: any = {}

        { render?: 'auto'|'in-place'|'recreate' }

      Returns Promise<Layer>

    • Point the layer back at the sources it held before its first op. Async and atomic, like any source swap — a live layer re-renders. A no-op if nothing has been applied.

      Parameters

      • Optionalopts: any = {}

        { render?: 'auto'|'in-place'|'recreate' }

      Returns Promise<Layer>

    • Resolve one selection-axis entry (the scenario-slider op).

      Parameters

      • coord: string | number
      • Optionalopts: any

      Returns Layer

    • THE way to change how this layer looks. Sync and chainable — returns the layer.

      layer.set({ palette: 'viridis', continuous: true, opacity: 0.8 });

      Raster knobs: palette, continuous, colorScale, noData, opacity, hover. Vector knobs: color, opacity, useFileColors, hover.

      This is the single path for changing a layer's appearance. layer.colorScale stays readable, and ColorScale keeps its own set() for building a scale before you hand it over.

      A knob that needs a redraw (only noData) redraws; await layer.settled() if you need to know it finished.

      Parameters

      • partial: any

      Returns Layer

    • Replace this layer's source Datasets and, if the layer is already live, re-render. Immutable data means "the data changed" == "point at a new Dataset" — never mutate. Drives the FimMap's Dataset ref-count (acquire the new before releasing the old, so a Dataset shared with another layer is not evicted mid-swap). opts.render chooses the update mechanism (see render()).

      ATOMIC: if the re-render throws (e.g. the new sources have an unrenderable CRS, or a materializer fetch fails), the swap is rolled back — sources/result revert to their previous values, the new sources' ref-count acquire is undone, and the error rethrows. What's actually on screen never changed either way (a failed render draws nothing new), so this keeps the layer's own state truthful to that: either the swap fully succeeded, or the layer is left exactly as it was before the call — never pointing at broken new sources with the working old ones already let go.

      Parameters

      • sources: Dataset | Dataset[]
      • Optionalopts: any = {}

        { render?: 'auto'|'in-place'|'recreate' }

      Returns Promise<Layer>

    • Returns { id: string; sources: string[]; type: string; visible: boolean }

    • A plain, structured-cloneable DESCRIPTION of this layer — its type, its sources, and the display state needed to rebuild an equivalent one, e.g. on a different map or provider:

      map2.addLayer(layer1.toSpec());

      This is deliberately a COPY, not a handle. addLayer(spec) builds a NEW ColorScale from the description, so the two layers diverge rather than silently sharing mutable colour state — which is exactly the question a clone() API cannot answer for the caller. The layer's id and its event subscribers are not carried either.

      sources are the live Dataset objects (free values, safe to share and already decoded). To persist a spec instead of transferring it in-page, swap them for ds.toRecord().

      Returns {
          colorScale: any;
          settings: any;
          sources: any[];
          type: string;
          visible: boolean;
      }

    • The pixel value at a lat/lng (nearest cell), or null when outside the footprint / no data / no pixels loaded. The hover read-model a tooltip (or enableHover(), below) consumes.

      Parameters

      • lat: number
      • lng: number
      • Optionalopts: { noDataTolerance?: number } = {}

        widen the noData check to |v - noData| <= tolerance instead of exact equality — for a raster whose sentinel can drift slightly after resampling (e.g. a GDAL bilinear warp blending a real value with an adjacent nodata pixel near an edge). Default 0 = exact match, this method's original behavior; hitTest() always uses the default, so widening this does not change what a click resolves to unless you call valueAt() directly.

      Returns number

    • Every type addLayer can currently construct — built-ins plus anything a host registered. REGISTRY KEYS, not layer.type values (see getLayerTypes).

      Returns string[]