Home Identifier Source Repository

Function

Static Public Summary
public

LayerFactory(options: {}): *

public

asSciJSndarray(arr: *): *

Wraps an object with get(i,j,k,...) method and .shape property

public

directPalette(colors: *): *

Converts an array of CSS colors to a palette of the same size.

public

indexOfNearest(a: *, x: *): *

Return the index in a of the value closest to x.

public

indicesOfNearest(a: *, x: *): *

Return the indices of the two neighbors in the a array closest to x.

public

inject(html: *, css: *)

Inject HTML and CSS into the DOM.

public

linearPalette(colors: Array, steps: number): *

Calculates a linear palette of the given size (default 256) from the given

public

scale(val: *, palette: *, extent: *): *

Static Public

public LayerFactory(options: {}): * source

import LayerFactory from 'leaflet-coverage'

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

*

public asSciJSndarray(arr: *): * source

import {asSciJSndarray} from 'leaflet-coverage/util/utils.js'

Wraps an object with get(i,j,k,...) method and .shape property as a SciJS ndarray object (https://github.com/scijs/ndarray).

If the object happens to be a SciJS ndarray object already, then this function just returns the same object.

Note that ndarray only accepts 1D-storage in its constructor, which means we have to map our multi-dim indices to 1D, and get back to multi-dim again afterwards. TODO do benchmarks

Params:

NameTypeAttributeDescription
arr *

Return:

*

public directPalette(colors: *): * source

import {directPalette} from 'leaflet-coverage/renderers/palettes.js'

Converts an array of CSS colors to a palette of the same size.

Params:

NameTypeAttributeDescription
colors *

Return:

*

public indexOfNearest(a: *, x: *): * source

import {indexOfNearest} from 'leaflet-coverage/util/utils.js'

Return the index in a of the value closest to x. The array a must be sorted, either ascending or descending. If x happens to be exactly between two values, the one that appears first is returned.

Params:

NameTypeAttributeDescription
a *
x *

Return:

*

public indicesOfNearest(a: *, x: *): * source

import {indicesOfNearest} from 'leaflet-coverage/util/utils.js'

Return the indices of the two neighbors in the a array closest to x. The array must be sorted (strictly monotone), either ascending or descending.

If x exists in the array, both neighbors point to x. If x is lower (greated if descending) than the first value, both neighbors point to 0. If x is greater (lower if descending) than the last value, both neighbors point to the last index.

Adapted from https://stackoverflow.com/a/4431347

Params:

NameTypeAttributeDescription
a *
x *

Return:

*

public inject(html: *, css: *) source

import {inject} from 'leaflet-coverage/controls/utils.js'

Inject HTML and CSS into the DOM.

Params:

NameTypeAttributeDescription
html *

The html to inject at the end of the body element.

css *

The CSS styles to inject at the end of the head element.

public linearPalette(colors: Array, steps: number): * source

import {linearPalette} from 'leaflet-coverage/renderers/palettes.js'

Calculates a linear palette of the given size (default 256) from the given CSS color specifications.

Example:


var grayscale = linearPalette(['#FFFFFF', '#000000'], 10) // 10-step palette
var rainbow = linearPalette(['#0000FF', '#00FFFF', '#00FF00', '#FFFF00', '#FF0000'])

Params:

NameTypeAttributeDescription
colors Array

An array of CSS color specifications

steps number

The number of palette colors to calculate

Return:

*

An object with members ncolors, red, green, blue, usable with the PaletteManager class.

public scale(val: *, palette: *, extent: *): * source

Params:

NameTypeAttributeDescription
val *
palette *
extent *

Return:

*