From b2141a052c4da5b4ef649daf48ea396afa21b181 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Tue, 21 Jan 2020 12:55:10 +0100 Subject: [PATCH] Added support for labels to processes. --- CHANGELOG.md | 7 +++++-- aggregate_polygon.json | 3 ++- aggregate_temporal.json | 3 ++- apply_dimension.json | 3 ++- array_apply.json | 13 +++++++++---- array_contains.json | 2 +- array_element.json | 21 +++++++++++++-------- array_filter.json | 13 +++++++++---- array_find.json | 31 +++++++++++++++++++------------ reduce_dimension.json | 3 ++- resample_cube_temporal.json | 3 ++- 11 files changed, 66 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77122fd9..563010f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `all` - `any` - `array_apply` + - `array_contains` - `array_filter` - `array_find` - `array_labels` @@ -24,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `reduce_dimension` - `reduce_dimension_binary` - `rename_labels` -- Added further examples +- Support for labeled arrays. [API#245](https://github.com/Open-EO/openeo-api/issues/245) +- Added further examples. ### Changed - The JSON Schema keyword `format` has been replaced with the custom keyword `subtype`. @@ -35,9 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Processes supporting multiple data types in parameters or return values with `anyOf` are now listing the data types directly as array. `anyOf` is discouraged. - Comparison processes `eq`, `gt`, `gte`, `lt`, `lte`, `neq` and `between` accept all data types as input for the operands. - `add_dimension`: Parameter `value` renamed to `label`. -- `apply_dimension`: Replaced with a completely new definition. [#73](https://github.com/Open-EO/openeo-processes/issues/73) +- `aggregate_polygon`, `aggregate_polygon`, `apply_dimension`, `array_element` and `resample_cube_temporal`: Support labeled arrays. [API#245](https://github.com/Open-EO/openeo-api/issues/245) - `aggregate_polygon`: The data cube implicitly gets restricted to the bounds of the polygons as if `filter_polygon` would have been used beforehand. [#101](https://github.com/Open-EO/openeo-processes/issues/101) - `aggregate_temporal`: Parameter `labels` is optional. [#19](https://github.com/Open-EO/openeo-processes/issues/19) +- `apply_dimension`: Replaced with a completely new definition. [#73](https://github.com/Open-EO/openeo-processes/issues/73) - `apply_kernel`: Only supported 2D kernels on the horizontal spatial dimensions. [#69](https://github.com/Open-EO/openeo-processes/issues/69) - `clip`: Works on a single value instead on arrays (replaced parameter `data` with `x`). [#75](https://github.com/Open-EO/openeo-processes/issues/75) - `count`: Renamed parameter `expression` to `condition`. diff --git a/aggregate_polygon.json b/aggregate_polygon.json index 72b8ed05..e5b02b32 100644 --- a/aggregate_polygon.json +++ b/aggregate_polygon.json @@ -40,10 +40,11 @@ "parameters": [ { "name": "data", - "description": "An array with elements of any type.", + "description": "A labeled array with values of any type.", "required": true, "schema": { "type": "array", + "subtype": "labeled-array", "items": { "description": "Any data type." } diff --git a/aggregate_temporal.json b/aggregate_temporal.json index c69a49c1..22a7df58 100644 --- a/aggregate_temporal.json +++ b/aggregate_temporal.json @@ -89,10 +89,11 @@ "parameters": [ { "name": "data", - "description": "An array with elements of any type.", + "description": "A labeled array with elements of any type.", "required": true, "schema": { "type": "array", + "subtype": "labeled-array", "items": { "description": "Any data type." } diff --git a/apply_dimension.json b/apply_dimension.json index b5d2c2e7..022a8a2b 100644 --- a/apply_dimension.json +++ b/apply_dimension.json @@ -24,10 +24,11 @@ "parameters": [ { "name": "data", - "description": "An array with elements of any type.", + "description": "A labeled array with elements of any type.", "required": true, "schema": { "type": "array", + "subtype": "labeled-array", "items": { "description": "Any data type." } diff --git a/array_apply.json b/array_apply.json index 5f6aaccf..3fe74efc 100644 --- a/array_apply.json +++ b/array_apply.json @@ -34,11 +34,16 @@ }, { "name": "index", - "description": "The zero-based index of the current element being processed.", + "description": "The zero-based index or the label of the current element being processed.", "required": true, - "schema": { - "type": "integer" - } + "schema": [ + { + "type": "number" + }, + { + "type": "string" + } + ] } ] }, diff --git a/array_contains.json b/array_contains.json index 763477df..13b89377 100644 --- a/array_contains.json +++ b/array_contains.json @@ -1,7 +1,7 @@ { "id": "array_contains", "summary": "Check whether the array contains a given value", - "description": "Checks whether the array specified for `data` contains the value specified in `value`. Returns `true` if there's a match, otherwise `false`.\n\n**Remarks:**\n\n* To get the index of the value found, use ``array_find()``.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. This includes that data types MUST be checked strictly, for example a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating point numbers due to floating point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.", + "description": "Checks whether the array specified for `data` contains the value specified in `value`. Returns `true` if there's a match, otherwise `false`.\n\n**Remarks:**\n\n* To get the index or the label of the value found, use ``array_find()``.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. This includes that data types MUST be checked strictly, for example a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating point numbers due to floating point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.", "categories": [ "arrays", "comparison" diff --git a/array_element.json b/array_element.json index e85c33e8..375b7fae 100644 --- a/array_element.json +++ b/array_element.json @@ -1,7 +1,7 @@ { "id": "array_element", "summary": "Get an element from an array", - "description": "Returns the element at the specified zero-based index from the array.", + "description": "Returns the element with the specified index or label from the array.", "categories": [ "arrays" ], @@ -19,15 +19,20 @@ }, { "name": "index", - "description": "The zero-based index of the element to retrieve.", - "schema": { - "type": "integer" - }, + "description": "The zero-based index or the label of the element to retrieve.", + "schema": [ + { + "type": "number" + }, + { + "type": "string" + } + ], "required": true }, { "name": "return_nodata", - "description": "By default this process throws an `IndexOutOfBounds` exception if the index is invalid. If you want to return `null` instead, set this flag to `true`.", + "description": "By default this process throws an `ArrayElementNotAvailable` exception if the index or label is invalid. If you want to return `null` instead, set this flag to `true`.", "schema": { "type": "boolean" }, @@ -41,8 +46,8 @@ } }, "exceptions": { - "IndexOutOfBounds": { - "message": "The array has no element with the specified index." + "ArrayElementNotAvailable": { + "message": "The array has no element with the specified index or label." } }, "examples": [ diff --git a/array_filter.json b/array_filter.json index 88d27ef1..343d2d1b 100644 --- a/array_filter.json +++ b/array_filter.json @@ -35,11 +35,16 @@ }, { "name": "index", - "description": "The zero-based index of the current element being processed.", + "description": "The zero-based index or the label of the current element being processed.", "required": true, - "schema": { - "type": "integer" - } + "schema": [ + { + "type": "number" + }, + { + "type": "string" + } + ] } ] }, diff --git a/array_find.json b/array_find.json index 39e5f3b7..6fa2a6ca 100644 --- a/array_find.json +++ b/array_find.json @@ -1,7 +1,7 @@ { "id": "array_find", - "summary": "Get the index for a value in an array", - "description": "Checks whether the array specified for `data` contains the value specified in `value` and returns the zero-based index for the first match. If there's no match, `-1` is returned.\n\n**Remarks:**\n\n* To get a boolean value returned use ``array_contains()``.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. This includes that data types MUST be checked strictly, for example a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating point numbers due to floating point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.", + "summary": "Get the index/label for a value in an array", + "description": "Checks whether the array specified for `data` contains the value specified in `value` and returns the zero-based index or the label for the first match. If there's no match, `-1` is returned.\n\n**Remarks:**\n\n* To get a boolean value returned use ``array_contains()``.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. This includes that data types MUST be checked strictly, for example a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating point numbers due to floating point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.", "categories": [ "arrays" ], @@ -27,11 +27,18 @@ } ], "returns": { - "description": "Returns the index of the first element with the specified value. If no element was found, `-1` is returned.", - "schema": { - "type": "integer", - "minimum": -1 - } + "description": "Returns the index or the label of the first element with the specified value. If no element was found, `null` is returned.", + "schema": [ + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "null" + } + ] }, "examples": [ { @@ -54,7 +61,7 @@ ], "value": "b" }, - "returns": -1 + "returns": null }, { "arguments": { @@ -65,7 +72,7 @@ ], "value": "2" }, - "returns": -1 + "returns": null }, { "arguments": { @@ -96,7 +103,7 @@ 2 ] }, - "returns": -1 + "returns": null }, { "arguments": { @@ -112,7 +119,7 @@ ], "value": 2 }, - "returns": -1 + "returns": null }, { "arguments": { @@ -128,7 +135,7 @@ "a": "b" } }, - "returns": -1 + "returns": null } ] } \ No newline at end of file diff --git a/reduce_dimension.json b/reduce_dimension.json index d13d99fa..49f6ff3e 100644 --- a/reduce_dimension.json +++ b/reduce_dimension.json @@ -25,10 +25,11 @@ "parameters": [ { "name": "data", - "description": "An array with elements of any type.", + "description": "A labeled array with elements of any type.", "required": true, "schema": { "type": "array", + "subtype": "labeled-array", "items": { "description": "Any data type." } diff --git a/resample_cube_temporal.json b/resample_cube_temporal.json index 67029370..0985acd5 100644 --- a/resample_cube_temporal.json +++ b/resample_cube_temporal.json @@ -34,10 +34,11 @@ "parameters": [ { "name": "data", - "description": "An array with elements of any type.", + "description": "A labeled array with elements of any type.", "required": true, "schema": { "type": "array", + "subtype": "labeled-array", "items": { "description": "Any data type." }