npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libcoverage

v0.1.10

Published

A WCS (Web Coverage Service) client library for JavaScript.

Downloads

32

Readme

libcoverage.js

Libcoverage.js is an extensible client library for the Open Geospatial Constortium (OGC) Web Coverage Service 2.0+ interface standard using a MIT style license.

It features means to create requests from parameters and parse the results returned from a WCS service.

Installation

You can use libcoverage.js either via npm:

npm install libcoverage

Or as a pre-bundled package:

<script src="path/to/libcoverage.min.js"></script>

Usage

Loading the modules (When not using the pre-bundled Version)

var parse = require("libcoverage/src/parse");
var kvp = require("libcoverage/src/kvp");
var eoParse = require("libcoverage/src/eowcs/parse");
var eoKvp = require("libcoverage/src/eowcs/parse");

Installing EO-WCS parsing extensions

parse.pushParseFunctions(eoPparse.parseFunctions);

Creating a GetCapabilities KVP request

var url = kvp.getCapabilitiesURL(baseUrl, {
  updatesequence: "someupdatesequence",
  sections: ["ServiceIdentification", "Contents"]
});

Creating a DescribeCoverage KVP request

var url = kvp.describeCoverageURL(baseUrl, [
  "coverageA", "coverageB"
]);

Creating a GetCoverage KVP request

var url = kvp.getCoverageURL(baseUrl, "coverageId", {
  format: "image/tiff",
  subsetX: [3.15, 3.25],
  subsetY: [22.28, 23.00],
  size: [100, 700],
  interpolation: "nearest"
});

Full GetCapabilities round-trip

var xhr = new XMLHttpRequest();
xhr.open('GET', kvp.getCapabilitiesURL(baseUrl), true);
xhr.onload = function(e) {
  var capabilities = parse.parse(this.response);
  console.log(capabilities);
}
xhr.send();

For compatibility reasons, the pre-bundled version of libcoverage.js exports a WCS object object in the global scope (the window) with the following sub-elements, mapping to the respective modules:

  • WCS.Util -> utils.js
  • WCS.Core.Parse -> parse.js
  • WCS.Core.KVP -> kvp.js
  • WCS.EO.Parse -> eowcs/parse.js
  • WCS.EO.KVP -> eowcs/kvp.js

To get a complete picture of all available functions and parameters, please refer to the API docs.

Note: libcoverage.js does not have any further dependency but relies on the XPath API, and thus needs a browser that correctly supports it.

Extending libcoverage.js

Since WCS 2.0 uses a Core/Extension approach it is vital for a client library to be extensible to easily adapt new extensions. This is mostly important for parsing service responses.

Libcoverage.js allows the registration of new parsing functions for the node name of the elements it shall parse. The results of all registered functions for the same tag are deep-merged together, so the extending parse functions should only parse information not yet included in the main parsing result.

To extend the core parsing capabilities with some specific functionality, one first has to design the parsing function which always takes the XML DOM node as parameter:

var parseExtendedCapabilities = function(node) {
    return {
        // parse data and insert it here
        specialData: someFinder(node, "SomePath").text
    }
}

Then, the function has to be registered for the node name (without the namespace prefix):

WCS.Core.Parse.pushParseFunction("Capabilities", parseExtendedCapabilities);

Example extension: EO-WCS

Libcoverage.js ships with a client extension for Earth Observation (EO-WCS). It provides a new function for generating requests (WCS.EO.KVP.describeEOCoverageSetURL) and new element parsing functions for Capabilities, CoverageDescriptions and EOCoverageSetDescriptions which are registered once the module is loaded.

The extended Capabilities parse function extends the parsed object with additional information about advertised dataset series. The CoverageDescriptions objects, on the other hand, are extended by the time interval and the footprint.

Integrations

Currently there is only one integration, namely for the MVC framework Backbone. The integration provides the models Service and Coverage and the collection CoverageSet. If the EO-WCS extension for libcoverage.js is also available, then the EOCoverageSet is included aswell. The models integrate seamlessly within Backbone and can be used alongside other models and object synchronization.

Unfortunately, as with the current status of Web Coverage Service - Transactional (WCS-T) it is not possible to integrate creation or modification of coverages within backbone and thus all related function calls will fail. This may change once the transactional interface extension for WCS 2.0 is specified.

References