Home Reference Source Repository

Function

Static Public Summary
public

load(url: string, options: Object): Promise

Loads a CoverageJSON document from a given URL and returns a Promise object that succeeds with the unmodified CoverageJSON object.

public

read(input: Object | string, options: Object): Promise

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:

NameTypeAttributeDescription
url string

The URL to load the CoverageJSON document from.

options Object
  • optional

An options object.

options.headers Object
  • optional

Additional HTTP headers to send if input is a URL.

options.eagerload Object
  • optional

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 {data, headers} where data is the CoverageJSON object and headers are the HTTP response headers with lower-cased header names as object keys. The promise fails if the resource at the given URL is not a valid JSON or CBOR document.

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:

NameTypeAttributeDescription
input Object | string

A CoverageJSON Domain, Coverage, or Coverage Collection document, as URL or object.

options Object
  • optional

An options object.

options.headers Object
  • optional

Additional HTTP headers to send if input is a URL.

options.eagerload Object
  • optional

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)
})