Function
Static Public Summary | ||
public |
Loads a CoverageJSON document from a given URL and returns a Promise object that succeeds with the unmodified CoverageJSON object. |
|
public |
Reads a CoverageJSON document and returns a Promise that succeeds with a Domain, Coverage, or CoverageCollection object. |
Static Public
public load(url: string, options: Object): 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 | The URL to load the CoverageJSON document from. |
|
options | Object |
|
An options object. |
options.headers | Object |
|
Additional HTTP headers to send if input is a URL. |
options.eagerload | Object |
|
Request a stand-alone CoverageJSON document (with domain and ranges embedded) if input is a URL. Note that the server may ignore that preference. |
Return:
Promise | A Promise succeeding with an object |
public read(input: Object | string, options: Object): Promise source
import {read} from 'covjson-reader'
Reads a CoverageJSON document and returns a Promise that succeeds with a Domain, Coverage, or CoverageCollection object.
Note that if the document references external domain or range documents, then these are not loaded immediately.
Params:
Name | Type | Attribute | Description |
input | Object | string | A CoverageJSON Domain, Coverage, or Coverage Collection document, as URL or object. |
|
options | Object |
|
An options object. |
options.headers | Object |
|
Additional HTTP headers to send if input is a URL. |
options.eagerload | Object |
|
Request a stand-alone CoverageJSON document (with domain and ranges embedded) if input is a URL. Note that the server may ignore that preference. |
Return:
Promise | A promise object succeeding with a Domain, Coverage, or CoverageCollection object, and failing with an Error object. |
Example:
CovJSON.read('http://example.com/coverage.covjson').then(function (cov) {
// work with Coverage data object
}).catch(function (e) {
// there was an error when loading the coverage data
console.log(e)
})