PB-2354: Add CF extension fields - #656
Conversation
e14bbe0 to
2bb5a64
Compare
boecklic
left a comment
There was a problem hiding this comment.
Thanks a lot.
I'd generalize handling of extension, see comment below.
|
On hold until this is merged: #658 |
b1c9186 to
2dd8fe6
Compare
|
Finally adapted to the changes made in #658: Can you have another look please @boecklic? To test manually:
Then create a feature with the putFeature endpoint (:warning: declare the CF extension in curl -X PUT \
"http://127.0.0.1:8000/api/stac/v1/collections/cf-collection/items/cf-item-1" \
-H "Content-Type: application/json" \
-H "Authorization: Token b5c95f9615d610635c88226d03344fee8ea2ea67" \
-d '{
"id": "cf-item-1",
"geometry": {
"type": "Point",
"coordinates": [8.5417, 47.3769]
},
"properties": {
"created": "2018-02-12T23:20:50Z",
"datetime": "2018-02-12T23:20:50Z",
"updated": "2018-02-12T23:20:50Z",
"title": "Feature title",
"cf:standard_name": "air_temperature",
"unit": "K"
},
"links": [],
"stac_extensions": ["https://stac-extensions.github.io/cf/v1.0.0/schema.json"]
}'Which can also be retrieved through the POST /search endpoint as with the curl -X POST \
"http://127.0.0.1:8000/api/stac/v1/search" \
-H "Content-Type: application/json" \
-H "Authorization: Token b5c95f9615d610635c88226d03344fee8ea2ea67" \
-d '{
"cf:standard_name": "air_temperature"
}' |
2dd8fe6 to
7be895d
Compare
|
From offline discussion with @boecklic regarding POST /search: Currently, to query "query": {
"title": {
"eq": "CF Collection 1"
}
}For the other fields, you can just do {
"datetime": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"
}This is in accordance with the query extension. However, currently "query" only accepts the following fields:
For the {
"forecast:variable": "ALB_RAD"
}But this is a bug! It should work like this: "query": {
"forecast:variable": {
"eq": "ALB_RAD"
}
}So for the CF fields, we should do it correctly from the start: They need to be queried through the "query" field. We agreed to do that in the scope of this ticket. Other possible follow-ups identified:
|
Not strictly necessary as it's an optional field but added nonetheless to keep it representative of the schema.
This avoids pylints warning "too-many-branches"
Created with `python app/manage.py makemigrations`.
Initially, this followed the example of the `forecast:*` fields (see PB-1169, #500). But that turned out to be wrong: Actually, as we implement the [query extension](https://github.com/stac-api-extensions/query), we are supposed to filter property fields through the "query" param. We keep it for the `forecast:*` fields for the moment in order to avoid breaking changes. For the CF extension fields, we do it right from the start. While doing this, I found another bug: We cannot query multiple fields as it is supposed to work. Will be fixed in a follow up where we replace the Query Extension by the Filter Extension. I added a comment and a disabled test to document that. Technical sidenote: Currently, there are two locations where external API field names are mapped to internal Django names: - `ItemQuerySet.filter_by_query`: Used by the "query" param in postSearchSTAC - `ItemsPropertiesSerializer.to_internal_value`: Used e.g. by putFeature I tried to bring this together at first to avoid duplication. It turned out, however, that it's not quite the same: - `ItemQuerySet.filter_by_query`: Maps to Django model field - `ItemsPropertiesSerializer.to_internal_value`: Maps to DRF Serializer field So, unfortunately, these have to be kept separate. For `filter_by_query`, it's just a simple replacement of colon by underscore, e.g., `cf:standard_name` to `cf_standard_name`. We don't need to prepend `cf:standard_name` and ``unit` with `properties_` like e.g. `expires` which is `properties_expires` internally. This is in line with how the fields of the Forecast extension are handled.
d278c66 to
de2ba15
Compare
|
Update: To filter by a CF field, you need to go through the "query": {
"cf:standard_name": {
"eq": "air_temperature"
}
}This is now also reflected in the OpenAPI docs:
"query": {
"cf:standard_name": {
"eq": "air_temperature"
},
"unit": {
"eq": "K"
}
}As agreed with @boecklic: We ignore this for the moment as POST /search does not seem to be used a lot. Instead, we fix this properly when moving service-stac to SWISSGEO by replacing the Query Extension with the Filter Extension. This is also what the Query extension recommends:
Impact on the geoadmin STAC Browser: Probably none - the Query Extension is not supported as far as I can see. The latest STAC Browser (not the geoadmin fork) is compatible with CQL, so I understand that it rather supports the Filter Extension instead of the (deprecated) Query Extension. |


This adds CF extension fields
cf:standard_namesandunitto a STACItem.Example:
It follows the example of the forecast extension properties. So we add the fields to:
The more peculiar bits:
:character in the URL.ch.meteoschweiz.ogd-forecasting-icon.As discussed:
cf:standard_nameis from the CF Standard Name Table.cf:cell_methods/descriptionare left out on purpose.❓ To be clarified: In #653 a trigger
update_collection_child_trigger_etag_onlywas added to update the ETag if a field changed. I am not familiar with how this works, Do I have to add another trigger for the new properties?