From 7ec047f6cfd8b526a07cc249a7843ca1393c51a2 Mon Sep 17 00:00:00 2001 From: Lukas Phaf Date: Tue, 22 Oct 2024 13:16:15 +0200 Subject: [PATCH 1/2] Add support for Trajectory domain type. --- src/covjson_pydantic/domain.py | 6 + tests/test_coverage.py | 2 + tests/test_data/spec-domain-trajectory.json | 26 ++++ tests/test_data/spec-trajectory-coverage.json | 112 ++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 tests/test_data/spec-domain-trajectory.json create mode 100644 tests/test_data/spec-trajectory-coverage.json diff --git a/src/covjson_pydantic/domain.py b/src/covjson_pydantic/domain.py index af581c6..9806668 100644 --- a/src/covjson_pydantic/domain.py +++ b/src/covjson_pydantic/domain.py @@ -53,6 +53,7 @@ class DomainType(str, Enum): point = "Point" multi_point_series = "MultiPointSeries" multi_point = "MultiPoint" + trajectory = "Trajectory" class Axes(CovJsonBaseModel): @@ -165,4 +166,9 @@ def check_domain_consistent(self): domain_type, axes, required_axes={"composite"}, allowed_axes={"t"}, single_value_axes={"t"} ) + if domain_type == DomainType.trajectory: + Domain.check_axis( + domain_type, axes, required_axes={"composite"}, allowed_axes={"z"}, single_value_axes={"z"} + ) + return self diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 4c678e6..c862a74 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -20,6 +20,7 @@ ("coverage-json.json", Coverage), ("doc-example-coverage.json", Coverage), ("spec-vertical-profile-coverage.json", Coverage), + ("spec-trajectory-coverage.json", Coverage), ("doc-example-coverage-collection.json", CoverageCollection), ("grid-domain.json", Domain), ("point-series-domain-custom.json", Domain), @@ -30,6 +31,7 @@ ("spec-domain-point-compact.json", Domain), ("spec-domain-multipoint-series.json", Domain), ("spec-domain-multipoint.json", Domain), + ("spec-domain-trajectory.json", Domain), ("ndarray-float.json", NdArray), ("spec-ndarray.json", NdArray), ("spec-tiled-ndarray.json", TiledNdArray), diff --git a/tests/test_data/spec-domain-trajectory.json b/tests/test_data/spec-domain-trajectory.json new file mode 100644 index 0000000..13c3d87 --- /dev/null +++ b/tests/test_data/spec-domain-trajectory.json @@ -0,0 +1,26 @@ +{ + "type": "Domain", + "domainType": "Trajectory", + "axes": { + "composite": { + "dataType": "tuple", + "coordinates": [ + "t", + "x", + "y" + ], + "values": [ + [ + "2008-01-01T04:00:00Z", + 1, + 20 + ], + [ + "2008-01-01T04:30:00Z", + 2, + 21 + ] + ] + } + } +} diff --git a/tests/test_data/spec-trajectory-coverage.json b/tests/test_data/spec-trajectory-coverage.json new file mode 100644 index 0000000..a0459e4 --- /dev/null +++ b/tests/test_data/spec-trajectory-coverage.json @@ -0,0 +1,112 @@ +{ + "type": "Coverage", + "domain": { + "type": "Domain", + "domainType": "Trajectory", + "axes": { + "composite": { + "dataType": "tuple", + "coordinates": [ + "t", + "x", + "y", + "z" + ], + "values": [ + [ + "2008-01-01T04:00:00Z", + 1, + 20, + 1 + ], + [ + "2008-01-01T04:30:00Z", + 2, + 21, + 3 + ] + ] + } + }, + "referencing": [ + { + "coordinates": [ + "x", + "y" + ], + "system": { + "type": "GeographicCRS", + "id": "http://www.opengis.net/def/crs/OGC/1.3/CRS84" + } + }, + { + "coordinates": [ + "z" + ], + "system": { + "type": "VerticalCRS", + "cs": { + "csAxes": [ + { + "name": { + "en": "Pressure" + }, + "direction": "down", + "unit": { + "symbol": "Pa" + } + } + ] + } + } + }, + { + "coordinates": [ + "t" + ], + "system": { + "type": "TemporalRS", + "calendar": "Gregorian" + } + } + ] + }, + "parameters": { + "temperature": { + "type": "Parameter", + "description": { + "en": "This is the air temperature" + }, + "observedProperty": { + "label": { + "en": "temperature" + } + }, + "unit": { + "label": { + "en": "Degree Celsius" + }, + "symbol": { + "value": "Cel", + "type": "http://www.opengis.net/def/uom/UCUM" + } + } + } + }, + "ranges": { + "temperature": { + "type": "NdArray", + "dataType": "float", + "axisNames": [ + "composite" + ], + "shape": [ + 2 + ], + "values": [ + 10.1, + 11.3 + ] + } + } +} From 9425c1698a04fa3b9c982b3767cd0a8ffdfaf211 Mon Sep 17 00:00:00 2001 From: Lukas Phaf Date: Tue, 22 Oct 2024 14:54:47 +0200 Subject: [PATCH 2/2] Bump version. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fbd49c0..8c8bd72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: GIS", "Typing :: Typed", ] -version = "0.3.0" +version = "0.4.0" dependencies = ["pydantic>=2.3,<3"] [project.optional-dependencies]