Home Reference Source Repository

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

read(input: Object | string): Promise

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:

NameTypeAttributeDescription
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.

Params:

NameTypeAttributeDescription
input Object | string

Either a URL pointing to a CoverageJSON Coverage or Coverage Collection document or a CoverageJSON Coverage or Coverage Collection object.

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:

ES6 module
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)
})
ES5 global
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)
})