Skip to content

Commit efaecfa

Browse files
committed
Updated version number and added code examples.
1 parent a8b681d commit efaecfa

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

README.md

+69-5
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,85 @@ JavaScript client for the openEO API.
44

55
[![Build Status](https://travis-ci.org/Open-EO/openeo-js-client.svg?branch=master)](https://travis-ci.org/Open-EO/openeo-js-client)
66

7-
This client is in **version 0.3.2** and supports **openEO API versions 0.3.0 and 0.3.1**. Legacy versions are available as releases.
7+
This client is in **version 0.3.3** and supports **openEO API versions 0.3.0 and 0.3.1**. Legacy versions are available as releases.
88

99
## Usage
1010
This library can run in a recent browser supporting ECMAScript 2015 or node.js.
1111

1212
To use it in a browser environment simply add the following code to your HTML file:
13-
```
13+
```html
1414
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
1515
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client/openeo.js"></script>
1616
```
1717

18-
To install it with npm: `npm install @openeo/js-client`
18+
To install it with npm run: `npm install @openeo/js-client`
19+
20+
### Running a job
21+
22+
```js
23+
// Import the library if running in a nodeJS environment
24+
// const { OpenEO } = require('@openeo/js-client');
25+
26+
var obj = new OpenEO();
27+
// Show the client version
28+
console.log("Client Version: " +obj.version());
29+
30+
try {
31+
// Connect to the back-end
32+
var con = await obj.connect("https://earthengine.openeo.org/v0.3", "basic", {username: "group1", password: "test123"});
33+
34+
// Show implemented API version of the back-end
35+
var capabilities = await con.capabilities();
36+
console.log("Server API version: " +capabilities.version());
37+
38+
// List collection names
39+
var collections = await con.listCollections();
40+
console.log("Collections: " +collections.collections.map(c => c.name));
41+
42+
// List process ids
43+
var processes = await con.listProcesses();
44+
console.log("Processes: " + processes.processes.map(p => p.name));
45+
46+
// List supported file types
47+
var fileTypes = await con.listFileTypes();
48+
console.log("Files types: " + Object.keys(fileTypes.formats));
49+
50+
// Check whether synchronous previews are supported
51+
var syncSupport = capabilities.hasFeature("execute");
52+
console.log("Synchronous previews: " + (syncSupport ? "supported" : "NOT supported"));
53+
54+
// Request a preview synchronously for a process graph
55+
if (syncSupport) {
56+
// Derives maximum NDVI measurements over pixel time series of Sentinel 2 imagery
57+
var processGraph = {
58+
"imagery": {
59+
"red": "B4",
60+
"nir": "B8",
61+
"imagery": {
62+
"extent": ["2018-12-01T00:00:00Z","2018-12-31T23:59:59Z"],
63+
"imagery": {
64+
"extent": {"west": 8.265169,"south": 52.453917,"east": 8.42035,"north": 52.576767},
65+
"imagery": {
66+
"process_id": "get_collection",
67+
"name": "COPERNICUS/S2"
68+
},
69+
"process_id": "filter_bbox"
70+
},
71+
"process_id": "filter_daterange"
72+
},
73+
"process_id": "NDVI"
74+
},
75+
"process_id": "max_time"
76+
};
77+
var preview = await con.execute(processGraph, "png");
78+
// This returns a Blob object with data you could further process or show.
79+
}
80+
} catch(e) {
81+
console.log(e);
82+
}
83+
```
84+
1985

20-
Dependencies required to run the openEO JS client:
21-
* [axios](https://github.com/axios/axios)
2286

2387
## Interactive JS Editor
2488

0 commit comments

Comments
 (0)