|
| 1 | +# Processing / API integration |
| 2 | + |
| 3 | +The eodash ecosystem allows integration of nearly limitless custom endpoints and APIs to further enrich the information that can be provided to the user. |
| 4 | + |
| 5 | +Typical use cases are fetching time series or statistics for an area that can be either selected from already existing features on the map or allow the user to create a custom geometry that will be passed to the endpoint. |
| 6 | + |
| 7 | +The three main configuration blocks can be seen in the figure below. They are basically definition of: |
| 8 | + |
| 9 | +* **Input**: what inputs are required for the call |
| 10 | +* **Process call**: where is the endpoint and how will the inputs be passed |
| 11 | +* **Output**: how should the result be presented to the user |
| 12 | + |
| 13 | +This means that in principle the whole definition can be done with two json files and the references in the STAC collection definition. |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Input |
| 18 | + |
| 19 | +The inputs needed for the endpoint to be queried can be configured through a **eodash:jsonform** definition. A url to this file needs to be included in the root of the STAC collection definition or configured in the eodash_catalog collection definition. |
| 20 | + |
| 21 | +This in principle allows a broad spectrum of input fields as well as even custom widgets for helping the user select correct values. The component used in eodash to render the form is the [eox-jsonform](https://eox-a.github.io/EOxElements/?path=/docs/elements-eox-jsonform--docs) from the EOxElements. Which is in turn based on the [json-editor](https://github.com/json-editor/json-editor) software. |
| 22 | + |
| 23 | +A typical json-form configuration file could look like this: |
| 24 | + |
| 25 | +```json |
| 26 | +{ |
| 27 | + "type": "object", |
| 28 | + "properties": { |
| 29 | + "feature_id": { |
| 30 | + "type": "string", |
| 31 | + "title": "Select feature on the map", |
| 32 | + "format": "feature", |
| 33 | + "options": { |
| 34 | + "drawtools": { |
| 35 | + "for": "eox-map#main", |
| 36 | + "layerId": "collection_layer_id" |
| 37 | + }, |
| 38 | + "featureProperty": "id", |
| 39 | + "type": "string" |
| 40 | + } |
| 41 | + } |
| 42 | + }, |
| 43 | + "options": { |
| 44 | + "execute": true |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +This configuration allows the user to click on a feature on the map, and the endpoint will only need the `id` of that feature as a string. |
| 50 | + |
| 51 | +The drawtool widget integrations is very customizable, allowing custom point/bbox/area selection and other options, a more in depth explanation and further examples can be found in the [Input definition](/processing_inputs) section. |
| 52 | + |
| 53 | +## Process call |
| 54 | + |
| 55 | +Once the inputs have been configured it is possible to define how they should be applied into the request. |
| 56 | +The usual RESTful interfaces allow to send a GET request to retrieve the relevant information. For example this could be a typical endpoint: |
| 57 | + |
| 58 | +``` |
| 59 | +https://greatapi.com/v1/feature/timeseries/austria |
| 60 | +``` |
| 61 | + |
| 62 | +By using templating language it is possible to utilize the properties that have been defined in the inputs. For example we can use the `feature_id` in the GET request. The definition in the eodash_catalog collection would be: |
| 63 | + |
| 64 | +```yaml |
| 65 | +Process: |
| 66 | + Name: "timeseries", |
| 67 | + JsonForm: "https://url.to/jsonform.json" |
| 68 | + VegaDefinition: "https://url.to/vega_chart.json" |
| 69 | + EndPoints: |
| 70 | + - Identifier: "timeseries" |
| 71 | + Url: "https://greatapi.com/v1/feature/timeseries/{{feature_id}}" |
| 72 | + Type: "application/json" |
| 73 | + Method: "GET" |
| 74 | +``` |
| 75 | +
|
| 76 | +or directly in STAC collection as service link: |
| 77 | +
|
| 78 | +```json |
| 79 | +{ |
| 80 | + "rel": "service", |
| 81 | + "href": "https://greatapi.com/v1/feature/timeseries/{{feature_id}}", |
| 82 | + "type": "application/json", |
| 83 | + "id": "timeseries", |
| 84 | + "method": "GET" |
| 85 | +}, |
| 86 | +``` |
| 87 | + |
| 88 | +## Output |
| 89 | + |
| 90 | +The request to the endpoint will then return some data. eodash foresees two types of outputs: |
| 91 | + |
| 92 | +* tabular or similar |
| 93 | +* or georeferenced data |
| 94 | + |
| 95 | +### Chart data |
| 96 | + |
| 97 | +For tabular data it is possible to specify a VEGA Chart definition. [Vega](https://vega.github.io/vega/) is a well established Visualization Grammar. Through this a completely custom visualization of the data can be configured for the user. |
| 98 | + |
| 99 | +Here is a screenshot of just a few examples (https://vega.github.io/vega/examples/) showing what is possible with VEGA definitions: |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +An example definition could look like this, it can be tried out directly in the [online editor](https://vega.github.io/editor/) as well: |
| 104 | + |
| 105 | +```json |
| 106 | +{ |
| 107 | + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", |
| 108 | + "data": { |
| 109 | + "values": [ |
| 110 | + { "x": 1, "y": 3 }, |
| 111 | + { "x": 2, "y": 5 }, |
| 112 | + { "x": 3, "y": 2 } |
| 113 | + ] |
| 114 | + }, |
| 115 | + "mark": "point", |
| 116 | + "encoding": { |
| 117 | + "x": { "field": "x", "type": "quantitative" }, |
| 118 | + "y": { "field": "y", "type": "quantitative" } |
| 119 | + } |
| 120 | +} |
| 121 | +``` |
| 122 | +The main change that is needed is to remove the **data** content and only leave a name property inside, e.g.: |
| 123 | +```json |
| 124 | +{ |
| 125 | + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", |
| 126 | + "data": { |
| 127 | + "name": "timeseries" |
| 128 | + }, |
| 129 | + ... |
| 130 | +} |
| 131 | +``` |
| 132 | +The data section will be filled by eodash. |
| 133 | + |
| 134 | +### Georeferenced data |
| 135 | + |
| 136 | +For georeferenced data such as Cloud optimized **Geotiffs (COGs), GeoJSON or FlatGeobuf** an **eodash:style** definition file can be specified. |
| 137 | +More information on the style definition can be found under [Styling](/styling). |
| 138 | + |
| 139 | +It is also possible to specify multiple endpoints, for example, one that provides a timeseries and another that provides a GeoJSON with some location data, this can be seen in the following image: |
| 140 | + |
| 141 | + |
| 142 | + |
0 commit comments