Skip to content

Commit

Permalink
Merge pull request #9 from KNMI/issue-8-custom-extent
Browse files Browse the repository at this point in the history
Change custom extend to be in line with EDR 1.1 spec
  • Loading branch information
lukas-phaf authored May 17, 2024
2 parents 45830a6 + 3a74b86 commit efa28a7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 4 additions & 3 deletions src/edr_pydantic/extent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import List
from typing import Optional
from typing import Union

from pydantic import AwareDatetime

Expand All @@ -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):
Expand Down
61 changes: 61 additions & 0 deletions tests/test_data/doc-example-extent.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
2 changes: 2 additions & 0 deletions tests/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -13,6 +14,7 @@
("doc-example-collections.json", Collections),
("simple-instance.json", Instance),
("landing-page.json", LandingPageModel),
("doc-example-extent.json", Extent),
]


Expand Down

0 comments on commit efa28a7

Please sign in to comment.