Coverage
Wraps a CoverageJSON Coverage object as a Coverage API object.
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 |
prefixes: * |
|
public |
The constant "Coverage". |
Method Summary
Public Methods | ||
public |
loadDomain(): Promise<Domain> Returns a Promise succeeding with a Domain object. |
|
public |
Returns a Promise succeeding with a Range object. |
|
public |
Returns the requested range data as a Promise. |
|
public |
subsetByIndex(constraints: Object): Promise<Coverage> Returns a Promise object which provides a copy of this Coverage object with the domain subsetted by the given indices specification. |
|
public |
subsetByValue(constraints: Object): Promise<Coverage> 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:
Name | Type | Attribute | Description |
covjson | Object | A CoverageJSON Coverage object. |
|
options | Object |
|
|
options.cacheRanges | boolean |
|
If true, then any range that was loaded remotely is cached. (The domain is always cached.) |
options.referencing | Array |
|
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 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 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 Methods
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
paramKeys | iterable<string> |
|
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:
Name | Type | Attribute | Description |
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. |
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:
Name | Type | Attribute | Description |
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. |
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
}