UNPKG

1.38 kBMarkdownView Raw
1# covutils
2
3JavaScript utilities for creating, transforming, and handling [Coverage Data objects](https://github.com/Reading-eScience-Centre/coverage-jsapi).
4
5[API docs](https://doc.esdoc.org/github.com/Reading-eScience-Centre/covutils/)
6
7## Usage
8
9A minified bundle of this library is available on [npmcdn](https://npmcdn.com/covutils/).
10
11Usage is simple:
12```html
13<script src="https://npmcdn.com/covutils@0.6/covutils.min.js"></script>
14<script>
15var coverage = ... ;
16
17// let's mask the Coverage with a GeoJSON polygon
18// any data values outside the polygon become null
19var polygon = {
20 "type": "Polygon",
21 "coordinates": [
22 [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
23 ]
24}
25CovUtils.maskByPolygon(coverage, polygon, ['x','y'])
26 .then(function (maskedCov) {
27 // work with masked Coverage
28 })
29</script>
30```
31
32If polygon-related functionality is not needed, then a lite bundle can be used instead:
33```html
34<script src="https://npmcdn.com/covutils@0.6/covutils-lite.min.js"></script>
35```
36
37### CommonJS/JSPM/ES6
38
39You may also use this library within common package managers as it is published on npm.
40
41An ES6 import may look like that:
42
43```js
44import {maskByPolygon} from 'covutils'
45```
46
47## Acknowledgments
48
49This library is developed within the [MELODIES project](http://www.melodiesproject.eu).