Home Reference Source Repository
import Coverage from 'covjson-reader/lib/Coverage.js'
public class | source

Coverage

Wraps a CoverageJSON Coverage object as a Coverage API object.

See:

Constructor Summary

Public Constructor
public

constructor(covjson: Object, options: Object)

Create a Coverage instance.

Member Summary

Public Members
public

If defined, then the coverage has a domain that follows the given domain type, either a full URI or a namespace-prefixed term.

public

ID of the coverage.

public

JSON-LD document

public

A boolean which indicates whether all coverage data is already loaded in memory.

public

The options object that was passed in to the constructor.

public

parameters: Map<string, Parameter>

A Map from key to Parameter object.

public
public

The constant "Coverage".

Method Summary

Public Methods
public

loadDomain(): Promise<Domain>

Returns a Promise succeeding with a Domain object.

public

loadRange(paramKey: string): Promise<Range>

Returns a Promise succeeding with a Range object.

public

loadRanges(paramKeys: iterable<string>): Promise<Map<string, Range>>

Returns the requested range data as a Promise.

public

Returns a Promise object which provides a copy of this Coverage object with the domain subsetted by the given indices specification.

public

Returns a Promise object which provides a copy of this Coverage object with the domain subsetted by the given value specification.

Public Constructors

public constructor(covjson: Object, options: Object) source

Create a Coverage instance.

Params:

NameTypeAttributeDescription
covjson Object

A CoverageJSON Coverage object.

options Object
  • optional
options.cacheRanges boolean
  • optional

If true, then any range that was loaded remotely is cached. (The domain is always cached.)

options.referencing Array
  • optional

Referencing info to use (e.g. from containing collection).

Public Members

public domainType: string | undefined source

If defined, then the coverage has a domain that follows the given domain type, either a full URI or a namespace-prefixed term. (See .prefixes)

public id: string | undefined source

ID of the coverage.

public ld: Object source

JSON-LD document

public loaded: boolean source

A boolean which indicates whether all coverage data is already loaded in memory. If true then this typically means that calls to .loadDomain(), .loadRange(), .loadRanges(), .subsetByIndex(), and .subsetByValue() will not invoke a network request.

public options: Object source

The options object that was passed in to the constructor.

public parameters: Map<string, Parameter> source

A Map from key to Parameter object. The key is a short alias of a Parameter, typically what is called a "variable name" or similar.

public prefixes: * source

public type: string source

The constant "Coverage".

Public Methods

public loadDomain(): Promise<Domain> source

Returns a Promise succeeding with a Domain object.

Return:

Promise<Domain>

public loadRange(paramKey: string): Promise<Range> source

Returns a Promise succeeding with a Range object.

Note that this method implicitly loads the domain as well.

Params:

NameTypeAttributeDescription
paramKey string

The key of the Parameter for which to load the range.

Return:

Promise<Range>

A Promise object which loads the requested range data and succeeds with a Range object.

Example:

cov.loadRange('salinity').then(function (sal) {
  // work with Range object
}).catch(function (e) {
  // there was an error when loading the range
  console.log(e.message)
})

public loadRanges(paramKeys: iterable<string>): Promise<Map<string, Range>> source

Returns the requested range data as a Promise.

Note that this method implicitly loads the domain as well.

Params:

NameTypeAttributeDescription
paramKeys iterable<string>
  • optional

An iterable of parameter keys for which to load the range data. If not given, loads all range data.

Return:

Promise<Map<string, Range>>

A Promise object which loads the requested range data and succeeds with a Map object.

Example:

cov.loadRanges(['salinity','temp']).then(function (ranges) {
  // work with Map object
  console.log(ranges.get('salinity').values)
}).catch(function (e) {
  // there was an error when loading the range data
  console.log(e)
})

public subsetByIndex(constraints: Object): Promise<Coverage> source

Returns a Promise object which provides a copy of this Coverage object with the domain subsetted by the given indices specification.

Note that the coverage type and/or domain type of the resulting coverage may be different than in the original coverage.

Note that the subsetted ranges are a view over the original ranges, meaning that no copying is done but also no memory is released if the original coverage is garbage collected.

Params:

NameTypeAttributeDescription
constraints Object

An object which describes the subsetting constraints. Every property of it refers to an axis name as defined in Domain.names, and its value must either be an integer or an object with start, stop, and optionally step (defaults to 1) properties whose values are integers. Properties that have the values undefined or null are ignored. All integers must be non-negative, step must not be zero. An integer constrains the axis to the given index, a start/stop/step object to a range of indices: If step=1, this includes all indices starting at start and ending at stop (exclusive); if step>1, all indices start, start + step, ..., start + (q + r - 1) step where q and r are the quotient and remainder obtained by dividing stop - start by step.

Return:

Promise<Coverage>

A Promise object with the subsetted coverage object as result.

Example:

cov.subsetByIndex({t: 4, z: {start: 10, stop: 20} }).then(function(subsetCov) {
  // work with subsetted coverage
})

public subsetByValue(constraints: Object): Promise<Coverage> source

Returns a Promise object which provides a copy of this Coverage object with the domain subsetted by the given value specification.

Note that the coverage type and/or domain type of the resulting coverage may be different than in the original coverage.

Note that the subsetted ranges are a view over the original ranges, meaning that no copying is done but also no memory is released if the original coverage is garbage collected.

Params:

NameTypeAttributeDescription
constraints Object

An object which describes the subsetting constraints. Every property of it refers to an axis name as defined in Domain.names, and its value must either be a number or string, or, if the axis has an ordering relation, an object with start and stop properties whose values are numbers or strings, or an object with a target property whose value is a number or string. Properties that have the values undefined or null are ignored. A number or string constrains the axis to exactly the given value, a start/stop object to the values intersecting the extent, and a target object to the value closest to the given value.

Return:

Promise<Coverage>

A Promise object with the subsetted coverage object as result.

Example:

cov.subsetByValue({
  t: '2015-01-01T01:00:00',
  z: {start: -10, stop: -5}
}).then(function(subsetCov) {
  // work with subsetted coverage
})
cov.subsetByValue({z: {target: -10} }).then(function(subsetCov) {
  // work with subsetted coverage
}