From 3a74b86c62794ba7baebe5d2a7f5d953b87119cc Mon Sep 17 00:00:00 2001 From: Lukas Phaf Date: Thu, 16 May 2024 10:45:01 +0200 Subject: [PATCH] Change custom extend to be in line with EDR 1.1 spec See: https://docs.ogc.org/is/19-086r6/19-086r6.html#_a2113fbe-7d9d-4295-bdfa-25b9cc89fa03 --- pyproject.toml | 2 +- src/edr_pydantic/extent.py | 7 +-- tests/test_data/doc-example-extent.json | 61 +++++++++++++++++++++++++ tests/test_edr.py | 2 + 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 tests/test_data/doc-example-extent.json diff --git a/pyproject.toml b/pyproject.toml index fc3dab1..992c416 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: GIS", "Typing :: Typed", ] -version = "0.2.1" +version = "0.3.0" dependencies = ["pydantic>=2.3,<3"] [project.optional-dependencies] diff --git a/src/edr_pydantic/extent.py b/src/edr_pydantic/extent.py index be808e4..cb5dfd6 100644 --- a/src/edr_pydantic/extent.py +++ b/src/edr_pydantic/extent.py @@ -1,5 +1,6 @@ from typing import List from typing import Optional +from typing import Union from pydantic import AwareDatetime @@ -26,10 +27,10 @@ class Vertical(EdrBaseModel): class Custom(EdrBaseModel): - interval: List[str] id: str - values: List[str] - reference: Optional[str] = None + interval: List[List[Union[str, float]]] + values: Optional[List[Union[str, float]]] = None + reference: str class Extent(EdrBaseModel): diff --git a/tests/test_data/doc-example-extent.json b/tests/test_data/doc-example-extent.json new file mode 100644 index 0000000..61548e3 --- /dev/null +++ b/tests/test_data/doc-example-extent.json @@ -0,0 +1,61 @@ +{ + "spatial": { + "bbox": [ + [ + -180.0, + -90.0, + 180.0, + 90.0 + ] + ], + "crs": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" + }, + "temporal": { + "interval": [ + [ + "2017-06-14T00:00:00Z", + "2017-06-14T12:00:00Z" + ] + ], + "values": [ + "2017-06-14T00:00:00Z", + "2017-06-14T06:00:00Z", + "2017-06-14T12:00:00Z", + "2017-06-14T18:00:00Z" + ], + "trs": "TIMECRS[\"DateTime\",TDATUM[\"Gregorian Calendar\"],CS[TemporalDateTime,1],AXIS[\"Time (T)\",future]]" + }, + "custom": [ + { + "id": "realisations", + "interval": [ + [ + 1.0, + 50.0 + ] + ], + "values": [ + "R50/1/1" + ], + "reference": "Ensemble members" + }, + { + "id": "icao_ids", + "interval": [ + [ + "EB", + "EB" + ] + ], + "values": [ + "EBAW", + "EBBR", + "EBBR", + "EBKT", + "EBLG", + "EBOS" + ], + "reference": "https://en.wikipedia.org/wiki/ICAO_airport_code" + } + ] +} diff --git a/tests/test_edr.py b/tests/test_edr.py index 0376f71..c68e4ac 100644 --- a/tests/test_edr.py +++ b/tests/test_edr.py @@ -5,6 +5,7 @@ from edr_pydantic.capabilities import LandingPageModel from edr_pydantic.collections import Collections from edr_pydantic.collections import Instance +from edr_pydantic.extent import Extent from edr_pydantic.unit import Unit from pydantic import ValidationError @@ -13,6 +14,7 @@ ("doc-example-collections.json", Collections), ("simple-instance.json", Instance), ("landing-page.json", LandingPageModel), + ("doc-example-extent.json", Extent), ]