Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edr feature collection #7

Closed
wants to merge 9 commits into from
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ This repository contains the edr-pydantic Python package. It provides [Pydantic]
for the [OGC Environmental Data Retrieval (EDR) API](https://ogcapi.ogc.org/edr/).
This can, for example, be used to help develop an EDR API using FastAPI.

## EDR GeoJSON
The EDR spec adds [optional fields](https://docs.ogc.org/is/19-086r4/19-086r4.html#toc9) to GeoJSON to help the user discover EDR resources. Therefore, there is an EDR Feature collection model in this repository which is a limited implementation of the [EDRFeatureCollection implementation](https://schemas.opengis.net/ogcapi/edr/1.1/openapi/schemas/edr-geojson/edrFeatureCollectionGeoJSON.yaml). The model extends [GeoJSON Pydantic](https://github.com/developmentseed/geojson-pydantic) by adding the optional properties.


## Install
```shell
pip install edr-pydantic
Expand Down Expand Up @@ -185,6 +189,7 @@ This library is used to build an OGC Environmental Data Retrieval (EDR) API, ser
Help is wanted in the following areas to fully implement the EDR spec:
* See TODOs in code listing various small inconsistencies in the spec
* In various places there could be more validation on content
* In the future all the [EDR GeoJSON schemas](https://schemas.opengis.net/ogcapi/edr/1.1/openapi/schemas/edr-geojson/) should be in this repository.

## License

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ classifiers = [
"Topic :: Scientific/Engineering :: GIS",
"Typing :: Typed",
]
version = "0.2.1"
dependencies = ["pydantic>=2.3,<3"]
version = "0.3.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, when upgrading you can still use the FeatureCollection of geojson-pydantic. It is not mandatory to use the model or implement the parameters.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why bump minor version?

dependencies = ["pydantic>=2.3,<3", "geojson-pydantic>1.0,<2.0", "covjson-pydantic>=0.2.1,<0.3.0"]

[project.optional-dependencies]
test = ["pytest", "pytest-cov"]
Expand Down
10 changes: 10 additions & 0 deletions src/edr_pydantic/edr_feature_collection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import Dict
from typing import Optional

from covjson_pydantic.parameter import Parameter # type: ignore
from edr_pydantic.base_model import EdrBaseModel
from geojson_pydantic import FeatureCollection # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a # type: ignore here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because mypy is not able to find the stubs for the external packages. I would have to look into it, but I think that there are two possible fixes:

  1. add py.typed to the library and ensure it is distributed by adding it to pytoml or setup.py:
[tool.setuptools.package-data]
"<package_name>" = ["py.typed"]
  1. Ignore it.



class EDRFeatureCollection(EdrBaseModel, FeatureCollection):
parameters: Optional[Dict[str, Parameter]] = None
112 changes: 112 additions & 0 deletions tests/test_data/edr-geojson-feature-collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
5.1797,
52.0989,
1.9
]
},
"properties": {
"name": "DE BILT AWS",
"parameter-name": [
"air_temperature_1.5_maximum_PT10M",
"dew_point_temperature_1.5_mean_PT1M",
"duration_of_sunshine_2.0_point_PT0S",
"wind_speed_10_mean_PT10M"
]
},
"id": "06260"
}
],
"parameters": {
"tx_dryb_10": {
"type": "Parameter",
"description": {
"en": "Temperature, air, maximum, 10"
},
"observedProperty": {
"id": "https://vocab.nerc.ac.uk/standard_name/air_temperature",
"label": {
"en": "Air temperature maximum"
}
},
"unit": {
"label": {
"en": "degree Celsius"
},
"symbol": {
"value": "°C",
"type": "http://www.opengis.net/def/uom/UCUM/"
}
}
},
"t_dewp_10": {
"type": "Parameter",
"description": {
"en": "Temperature air dewpoint 10"
},
"observedProperty": {
"id": "https://vocab.nerc.ac.uk/standard_name/dew_point_temperature",
"label": {
"en": "Dew Point Temperature"
}
},
"unit": {
"label": {
"en": "degree Celsius"
},
"symbol": {
"value": "°C",
"type": "http://www.opengis.net/def/uom/UCUM/"
}
}
},
"sq_10": {
"type": "Parameter",
"description": {
"en": "Sunshine duration, duration derived from radiation, 10"
},
"observedProperty": {
"id": "https://vocab.nerc.ac.uk/standard_name/duration_of_sunshine",
"label": {
"en": "Sunshine duration"
}
},
"unit": {
"label": {
"en": "minute"
},
"symbol": {
"value": "min",
"type": "http://www.opengis.net/def/uom/UCUM/"
}
}
},
"ff_10m_10": {
"type": "Parameter",
"description": {
"en": "Wind, speed, average, converted to 10 metres, 10"
},
"observedProperty": {
"id": "https://vocab.nerc.ac.uk/standard_name/wind_speed",
"label": {
"en": "wind_speed_10_mean_PT10M"
}
},
"unit": {
"label": {
"en": "metre per second"
},
"symbol": {
"value": "m/s",
"type": "http://www.opengis.net/def/uom/UCUM/"
}
}
}
}
}
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.edr_feature_collection import EDRFeatureCollection
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),
("edr-geojson-feature-collection.json", EDRFeatureCollection),
]


Expand Down