Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.5 KB

ogc-client.md

File metadata and controls

52 lines (38 loc) · 1.5 KB

ogc-client

ogc-client is a Typescript library that offers useful APIs on top of various OGC protocols, including OGC API.

Supported protocols are:

  • WMS - Web Map Service
  • WFS - Web Feature Service
  • WMTS - Web Map Tile Service
  • OGC API (Records and Features)

How to use it

The OgcApiEndpoint class lets us interact with an OGC API compliant endpoint in various ways. Since most operations in an OGC API endpoint revolves around doing requests to various linked addresses, this class offers an abstraction based on simple promises.

For instance, to get a list of collections:

const endpoint = new OgcApiEndpoint('https://my.endpoint.org/ogcapi');
console.log(await endpoint.allCollections);

More detailed information on a single collection can be fetched like so:

const collection = await endpoint.getCollectionInfo('city-roads');
console.log(collection.itemCount);

To read items in a collection, the /items endpoint can be exploited like so:

const itemsUrl = await endpoint.getCollectionItemsUrl(
  'city-roads',
  {
    asJson: true,
    limit: 10,
    offset: 30
  }
);
fetch(itemsUrl).then(resp => resp.json()).then(...)

Items can also be fetched in bulk, often using more diverse formats:

const flatgeobufUrl = collection.bulkDownloadLinks['application/flatgeobuf'];
fetch(flatgeobufUrl).then(resp => resp.arrayBuffer()).then(...)

See https://camptocamp.github.io/ogc-client/#/api for more details on the API of ogc-client.