From 18372416ffbf0a08aa99f2888558a67cd310a7de Mon Sep 17 00:00:00 2001 From: Ivor Bosloper Date: Mon, 27 Oct 2025 18:38:21 +0100 Subject: [PATCH 1/4] Extend create stac collection.json, include fiboa data, update processing-extension version --- fiboa_cli/create_stac.py | 21 +++++++++++++++++++++ fiboa_cli/publish.py | 4 ++-- tests/data-files/stac-collection.json | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fiboa_cli/create_stac.py b/fiboa_cli/create_stac.py index 88e18f92..07083ff5 100644 --- a/fiboa_cli/create_stac.py +++ b/fiboa_cli/create_stac.py @@ -1,6 +1,11 @@ import click +from geopandas import GeoDataFrame from vecorel_cli.cli.options import JSON_INDENT, VECOREL_FILE_ARG, VECOREL_TARGET_CONSOLE from vecorel_cli.create_stac import CreateStacCollection +from vecorel_cli.registry import VecorelRegistry +from vecorel_cli.vecorel.collection import Collection + +from fiboa_cli.fiboa.version import get_versions class CreateFiboaStacCollection(CreateStacCollection): @@ -24,3 +29,19 @@ def get_cli_args(): # todo: allow additional parameters for missing data in the collection? # https://stackoverflow.com/questions/36513706/python-click-pass-unspecified-number-of-kwargs } + + def create(self, collection: Collection, gdf: GeoDataFrame, *args, **kwargs) -> dict: + data = super().create(collection, gdf, *args, **kwargs) + vecorel = VecorelRegistry() + data["assets"]["data"]["processing:software"].setdefault( + vecorel.name, vecorel.get_version() + ) + schemas = collection.get_schemas() + vecorel_version, _, fiboa_version, _, extensions = get_versions( + next(iter(schemas.values())) + ) + data["fiboa_version"] = fiboa_version + data.setdefault("vecorel_version", vecorel_version) + data.setdefault("vecorel_extensions", {k: list(v) for k, v in schemas.items()}) + + return data diff --git a/fiboa_cli/publish.py b/fiboa_cli/publish.py index 64111fc4..8a34f8ef 100644 --- a/fiboa_cli/publish.py +++ b/fiboa_cli/publish.py @@ -13,10 +13,10 @@ from vecorel_cli.cli.options import VECOREL_TARGET from vecorel_cli.convert import ConvertData from vecorel_cli.converters import Converters -from vecorel_cli.create_stac import CreateStacCollection from vecorel_cli.encoding.auto import create_encoding from vecorel_cli.validate import ValidateData +from .create_stac import CreateFiboaStacCollection from .registry import Registry STAC_EXTENSION = "https://stac-extensions.github.io/web-map-links/v1.2.0/schema.json" @@ -322,7 +322,7 @@ def create_stac_collection(self, target, file_name, parquet_file, stac_file): self.success(f"Creating STAC collection.json for {parquet_file}") p_stac.parent.mkdir(exist_ok=True) - CreateStacCollection().create_cli(parquet_file, stac_file) + CreateFiboaStacCollection().create_cli(parquet_file, stac_file) Path(target, "stac").mkdir(parents=True, exist_ok=True) data = json.load(open(stac_file, "r")) diff --git a/tests/data-files/stac-collection.json b/tests/data-files/stac-collection.json index 36158694..eccd88fd 100644 --- a/tests/data-files/stac-collection.json +++ b/tests/data-files/stac-collection.json @@ -1,7 +1,7 @@ { "stac_version": "1.1.0", "stac_extensions": [ - "https://stac-extensions.github.io/processing/v1.1.0/schema.json" + "https://stac-extensions.github.io/processing/v1.2.0/schema.json" ], "type": "Collection", "id": "de_nrw", From 7df5eafd174322f64f41ce158f993599e004da11 Mon Sep 17 00:00:00 2001 From: Ivor Bosloper Date: Mon, 27 Oct 2025 18:40:46 +0100 Subject: [PATCH 2/4] Add Changlog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06504361..430c9d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- Extend create_stac, include include fiboa data - Fix to vecorel: converter.license and provider should be string - Added a Dockerfile to simplify working with fiboa - Command `fiboa publish` to automate source coop publication process From 30fbf19c59523caf336a90e8aa9393887ffde734 Mon Sep 17 00:00:00 2001 From: Ivor Bosloper Date: Wed, 29 Oct 2025 19:47:47 +0100 Subject: [PATCH 3/4] Make tests work --- tests/data-files/stac-collection.json | 20 +++++++++++--- tests/test_create_stac.py | 38 +++++++++++++-------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/tests/data-files/stac-collection.json b/tests/data-files/stac-collection.json index eccd88fd..6fc921da 100644 --- a/tests/data-files/stac-collection.json +++ b/tests/data-files/stac-collection.json @@ -1,7 +1,7 @@ { "stac_version": "1.1.0", "stac_extensions": [ - "https://stac-extensions.github.io/processing/v1.2.0/schema.json" + "https://stac-extensions.github.io/processing/v1.1.0/schema.json" ], "type": "Collection", "id": "de_nrw", @@ -18,9 +18,23 @@ "data": { "roles": ["data"], "href": "file://C:/Dev/fiboa-cli/tests/data-files/fiboa-example.json", - "processing:software": { "fiboa-cli": "0.20.3" }, + "processing:software": { + "fiboa-cli": "0.20.1", + "vecorel-cli": "0.2.3" + }, "type": "application/geo+json" } }, - "links": [] + "links": [], + "fiboa_version": "0.3.0", + "vecorel_version": "0.1.0", + "vecorel_extensions": { + "de_nrw": [ + "https://fiboa.org/crop-extension/v0.2.0/schema.yaml", + "https://fiboa.org/flik-extension/v0.2.0/schema.yaml", + "https://vecorel.org/specification/v0.1.0/schema.yaml", + "https://vecorel.org/administrative-division-extension/v0.1.0/schema.yaml", + "https://fiboa.org/specification/v0.3.0/schema.yaml" + ] + } } diff --git a/tests/test_create_stac.py b/tests/test_create_stac.py index 16af22b2..14a334d9 100644 --- a/tests/test_create_stac.py +++ b/tests/test_create_stac.py @@ -18,30 +18,28 @@ def test_create_stac_collection(tmp_folder: Path): created_file = load_file(out_file) expected = load_file(expected_file) - assert isinstance(created_file, dict), "Created file is not a valid JSON dict" + def pop_path(*args, value=None): + c, e = created_file, expected + for index, arg in enumerate(args): + assert arg in c, f"{arg} not in created stac {c}" + assert arg in e, f"{arg} not in expected {e}" + method = dict.pop if index == len(args) - 1 else dict.get + c, e = method(c, arg), method(e, arg) + if value is not None: + assert c == value, f"{c} != {value}" + # Cater for environment differences in paths - assert "assets" in created_file - assert "data" in created_file["assets"] - assert "href" in created_file["assets"]["data"] - del created_file["assets"]["data"]["href"] - del expected["assets"]["data"]["href"] + pop_path("assets", "data", "href") + # Cater for floating point differences - assert "extent" in created_file - assert "spatial" in created_file["extent"] - assert "bbox" in created_file["extent"]["spatial"] - del created_file["extent"]["spatial"]["bbox"] - del expected["extent"]["spatial"]["bbox"] + pop_path("extent", "spatial", "bbox") + # Cater for differences in version numbers - assert "assets" in created_file - assert "data" in created_file["assets"] - assert "processing:software" in created_file["assets"]["data"] - assert "fiboa-cli" in created_file["assets"]["data"]["processing:software"] - assert ( - created_file["assets"]["data"]["processing:software"]["fiboa-cli"] == Registry.get_version() - ) - del created_file["assets"]["data"]["processing:software"]["fiboa-cli"] - del expected["assets"]["data"]["processing:software"]["fiboa-cli"] + pop_path("assets", "data", "processing:software", "fiboa-cli", value=Registry.get_version()) + + created_file["vecorel_extensions"]["de_nrw"].sort() + expected["vecorel_extensions"]["de_nrw"].sort() assert created_file == expected From 1f197aa02f27655d99d81c256783a20c34bb5c3c Mon Sep 17 00:00:00 2001 From: Ivor Bosloper Date: Wed, 29 Oct 2025 19:58:38 +0100 Subject: [PATCH 4/4] Simplify tests --- tests/test_create_stac.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_create_stac.py b/tests/test_create_stac.py index 14a334d9..bd473e4d 100644 --- a/tests/test_create_stac.py +++ b/tests/test_create_stac.py @@ -38,6 +38,7 @@ def pop_path(*args, value=None): # Cater for differences in version numbers pop_path("assets", "data", "processing:software", "fiboa-cli", value=Registry.get_version()) + pop_path("assets", "data", "processing:software", "vecorel-cli") created_file["vecorel_extensions"]["de_nrw"].sort() expected["vecorel_extensions"]["de_nrw"].sort()