Function
Static Public Summary | ||
public |
Loads a CoverageJSON document from a given URL and returns a {@link Promise} object
that succeeds with the unmodified CoverageJSON object.
|
|
public |
Reads a CoverageJSON document and returns a {@link Promise} that succeeds with
a {@link Coverage} object or an array of such.
|
Static Public
public load(url: string): Promise source
import {load} from 'covjson-reader'
Loads a CoverageJSON document from a given URL and returns a Promise object that succeeds with the unmodified CoverageJSON object.
Params:
Name | Type | Attribute | Description |
url | string |
Return:
Promise | The data is the CoverageJSON object. The promise fails if the resource at the given URL is not a valid JSON or CBOR document. |
public read(input: Object | string): Promise source
import {read} from 'covjson-reader'
Reads a CoverageJSON document and returns a Promise that succeeds with a Coverage object or an array of such.
Note that if the document references external domain or range documents, then these are not loaded immediately.
Return:
Promise | A promise object having a Coverage object or, for CoverageJSON Coverage Collections, an array of Coverage objects as data. In the error case, an Error object is supplied from the Promise. |
Example:
read('http://example.com/coverage.covjson').then(cov => {
// work with Coverage object
}).catch(e => {
// there was an error when loading the coverage
console.log(e)
})
CovJSON.read('http://example.com/coverage.covjson').then(function (cov) {
// work with Coverage object
}).catch(function (e) {
// there was an error when loading the coverage
console.log(e)
})