Skip to content

Commit 1f692a4

Browse files
Merge pull request #1321 from Open-EO/colormap-info
Better document colormap parameter
2 parents 1c11af7 + e448bd4 commit 1f692a4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

openeogeotrellis/backend.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@ def oidc_providers(self) -> List[OidcProvider]:
431431
return get_backend_config().oidc_providers
432432

433433
def file_formats(self) -> dict:
434+
colormap_properties = {
435+
"anyOf": [
436+
{"type": "integer"},
437+
{
438+
"type": "array",
439+
"items": {"type": "number", "minimum": 0, "maximum": 1},
440+
"minItems": 4,
441+
"maxItems": 4,
442+
},
443+
]
444+
}
434445
return {
435446
"input": {
436447
"GeoJSON": {
@@ -462,6 +473,7 @@ def file_formats(self) -> dict:
462473
"GTiff": {
463474
"title": "GeoTiff",
464475
"description": "Cloud Optimized Geotiff is one of the most widely supported formats and thus a popular choice for further dissemination. This implementation stores all bands in one file, and creates one file per timestamp in your datacube.",
476+
"type": "object",
465477
"gis_data_types": ["raster"],
466478
"parameters": {
467479
"tile_grid": {
@@ -494,7 +506,8 @@ def file_formats(self) -> dict:
494506
"colormap": {
495507
"type": ["object", "null"],
496508
"description": "Allows specifying a colormap, for single band geotiffs. The colormap is a dictionary mapping band values to colors, specified by an integer.",
497-
"default": None
509+
"default": None,
510+
"additionalProperties": colormap_properties,
498511
},
499512
"filename_prefix": {
500513
"type": "string",
@@ -540,7 +553,8 @@ def file_formats(self) -> dict:
540553
"colormap": {
541554
"type": ["object", "null"],
542555
"description": "Allows specifying a colormap, for single band PNGs. The colormap is a dictionary mapping band values to colors, either specified by an integer or an array of [R, G, B, A], where each value lies between 0.0 and 1.0.",
543-
"default": None
556+
"default": None,
557+
"additionalProperties": colormap_properties,
544558
},
545559
}
546560
},

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"rio_cogeo",
3333
"pydantic~=1.0",
3434
"zarr",
35+
"jsonschema",
3536
]
3637

3738
typing_require = [

tests/test_views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from unittest import mock
1313

1414
import boto3
15+
import jsonschema
1516
import kazoo.exceptions
1617
import pytest
1718
import requests
@@ -50,6 +51,13 @@ def test_capabilities(self, api100):
5051

5152
def test_file_formats(self, api100):
5253
formats = api100.get("/file_formats").assert_status_code(200).json
54+
formats_schema = {
55+
"$schema": "http://json-schema.org/draft-07/schema#",
56+
"$id": "https://processes.openeo.org/2.0.0-rc.1/meta/subtype-schemas.json",
57+
"type": "object",
58+
"properties": formats["output"],
59+
}
60+
jsonschema.validate(instance=formats_schema, schema={"$ref": "http://json-schema.org/draft-07/schema#"})
5361
assert "GeoJSON" in formats["input"]
5462
assert "GTiff" in formats["output"]
5563
assert "CovJSON" in formats["output"]

0 commit comments

Comments
 (0)