Skip to content

Commit

Permalink
Merge pull request #18 from KNMI/trajectory
Browse files Browse the repository at this point in the history
Add support for Trajectory domain type
  • Loading branch information
lukas-phaf authored Oct 22, 2024
2 parents f546efa + 9425c16 commit 5809d8c
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions src/covjson_pydantic/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DomainType(str, Enum):
point = "Point"
multi_point_series = "MultiPointSeries"
multi_point = "MultiPoint"
trajectory = "Trajectory"


class Axes(CovJsonBaseModel):
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
26 changes: 26 additions & 0 deletions tests/test_data/spec-domain-trajectory.json
Original file line number Diff line number Diff line change
@@ -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
]
]
}
}
}
112 changes: 112 additions & 0 deletions tests/test_data/spec-trajectory-coverage.json
Original file line number Diff line number Diff line change
@@ -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
]
}
}
}

0 comments on commit 5809d8c

Please sign in to comment.