Module: ol/source/Raster

ol/source/Raster


Classes

RasterSourceEvent
RasterSource

Type Definitions

FauxMessageEvent{Object}

Properties:
Name Type Description
data Object

Message data.

Input{Object}

Properties:
Name Type Description
data TypedArray

Interleaved band data.

width number

Width in pixels.

height number

Height in pixels.

bandCount number

Number of bands per pixel.

Job{Object}

Properties:
Name Type Description
meta Object

Job metadata.

inputs Array<Input>

Array of input data, normalized by toInput so every input carries a band count.

callback JobCallback

Called when the job is complete.

JobCallback()

MinionData{Object}

Properties:
Name Type Description
buffers Array.<ArrayBuffer>

Array of buffers.

meta Object

Operation metadata.

imageOps boolean

The operation is an image operation.

width number

The width of the image.

height number

The height of the image.

bandCounts Array.<number>

The number of bands in each input.

dtypes Array.<string>

The typed array constructor name of each input.

Operation()

A function that takes an array of input data, performs some operation, and returns an array of output data. For pixel type operations, the function will be called with an array of pixels, one per input source, and should return a single pixel as an array of four numbers ([r, g, b, a]) in the range of 0 - 255. For sources rendered as images, each input pixel is an [r, g, b, a] array; for data tile sources (see sources), each input pixel is an array of that source's band values in their native type (e.g. floating point). For 'image' type operations, functions will be called with an array of ImageData and should return a single ImageData. The operations are called with a second "data" argument, which can be used for storage. The data object is accessible from raster events, where it can be initialized in "beforeoperations" and accessed again in "afteroperations".

Options{Object}

Properties:
Name Type Description
sources Array.<(module:ol/source/Source~Source|module:ol/layer/Layer~Layer)>

Input sources or layers. Most sources and layers are rendered to an image and read back as RGBA pixels. A DataTileSource (such as a GeoTIFFSource) provided directly as a source preserves the data type and precision of the tiles (e.g. Float32Array values are passed to the operation unchanged rather than clamped to bytes), and the operation receives all of the source's bands per pixel. To render a data tile source through a layer instead (for example a WebGLTileLayer that styles it to RGBA), pass the layer rather than the source. For data tile inputs, there are some limitations: only 'pixel' operations are supported (an 'image' operation requires image inputs); resampling to the view resolution uses nearest neighbor regardless of the interpolate option; the tile data must match the tile grid pixel for pixel, so sources with a gutter are not supported.

operation Operation | undefined

Raster operation. The operation will be called with data from input sources and the output will be assigned to the raster source.

interpolate boolean
(defaults to true)

Use interpolated values when resampling. By default, linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.

lib Object | undefined

Functions that will be made available to operations run in a worker.

threads number | undefined

By default, operations will be run in a single worker thread. To avoid using workers altogether, set threads: 0. For pixel operations, operations can be run in multiple worker threads. Note that there is additional overhead in transferring data to multiple workers, and that depending on the user's system, it may not be possible to parallelize the work.

operationType RasterOperationType
(defaults to 'pixel')

Operation type. Supported values are 'pixel' and 'image'. By default, 'pixel' operations are assumed, and operations will be called with an array of pixels from input sources. If set to 'image', operations will be called with an array of ImageData objects from input sources.

resolutions Array.<number> | null | undefined

Resolutions. If specified, raster operations will only be run at the given resolutions. By default, the resolutions of the first source with resolutions specified will be used, if any. Set to null to use any view resolution instead.

ProcessorOptions{Object}

Properties:
Name Type Description
threads number

Number of workers to spawn.

operation Operation

The operation.

lib Object.<string, function()> | undefined

Functions that will be made available to operations run in a worker.

queue number

The number of queued jobs to allow.

imageOps boolean
(defaults to false)

Pass all the image data to the operation instead of a single pixel.

RasterOperationType{'pixel'} {'image'}

Raster operation type. Supported values are 'pixel' and 'image'.

RasterSourceEventTypes{ImageSourceEventTypes} {'beforeoperations'} {'afteroperations'}

TypedArray{Uint8Array} {Uint8ClampedArray} {Int8Array} {Uint16Array} {Int16Array} {Uint32Array} {Int32Array} {Float32Array} {Float64Array}

A single input to an operation. All inputs for a job share the same width and height (the output pixel dimensions); they may differ in band count and array type. For image inputs, the data is Uint8ClampedArray RGBA (four bands); for data tile inputs, the data is the native interleaved array.