Git Product home page Git Product logo

libcoverage.js's Introduction

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

libcoverage.js's People

Contributors

constantinius avatar mlocher avatar santilland avatar

Stargazers

Sam Huang avatar Anders Barfod avatar Michael Cohen avatar Rowan Winsemius avatar Lubomír Doležal avatar Christophe Nouguier avatar Víctor Velarde avatar Joan Arnaldich avatar ilya avatar Stefan Keim avatar Rakesh P avatar  avatar Andreas Trawoeger avatar

Watchers

Stephan Meißl avatar James Cloos avatar  avatar  avatar Martin Pačes avatar Christian avatar  avatar

libcoverage.js's Issues

node.js > ReferenceError: eoParse is not defined

ReferenceError: window is not defined in Node.js

/Users/ubarbaxor/code/imagery-watcher/node_modules/libcoverage/src/parse.js:12
if (typeof window.DOMParser != "undefined") {
^

ReferenceError: window is not defined
    at Object.<anonymous> (/Users/ubarbaxor/code/imagery-watcher/node_modules/libcoverage/src/parse.js:12:1)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ubarbaxor/code/imagery-watcher/src/index.js:98:21)
    at Module._compile (module.js:624:30)

I've been checking in src/parse.js:12 there's something in the taste of :

if (typeof window.DOMParser != "undefined") { ... }
else if (typeof window.ActiveXObject != "undefined" &&
        new window.ActiveXObject("Microsoft.XMLDOM")) { ... }

This causes ReferenceError: window is not defined in node.js.

A simple solution would be to wrap the whole block in something in the taste of :

if (typeof window != "undefined") { ... }

I'm not sure this lib is meant to be usable in node, currently trying it to integrate DigitalGlobe API, so I had to fork and fix this myself.

I'm willing to issue a PR in case this issue can be addressed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.