Skip to content

Commit dd82a3f

Browse files
committed
feat: change include/exclude recommendations
1 parent 99e3612 commit dd82a3f

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

README.md

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,56 @@ name, e.g., `properties.datetime` or `datetime`.
7171

7272
## Include/Exclude Semantics
7373

74-
1. If `fields` attribute is specified with an empty object, or with both `include` and `exclude` set to null or an
75-
empty array, the recommended behavior is as if `include` was set to
76-
`["id", "type", "geometry", "bbox", "links", "assets", "properties.datetime"]`. This default is so that the entity
77-
returned is a valid STAC Item. Implementations may choose to add other properties, e.g., `created`, but the number
74+
1. If `fields` attribute is specified as an empty object (for POST requests), an empty string (for GET requests),
75+
or with both `include` and `exclude` set to null or an
76+
empty array, then the recommended behavior is to `include` the following keys:
77+
`["id", "type", "geometry", "bbox", "links", "assets", "properties.datetime", "stac_version"]`.
78+
This default is so that the entity returned is a valid STAC Item.
79+
Implementations may choose to add other properties, e.g., `properties.created`, but the number
7880
of default properties attributes should be kept to a minimum.
79-
2. If only `include` is specified, these attributes are added to the default set of attributes (set union operation).
80-
3. If only `exclude` is specified, these attributes are subtracted from the union of the default set of attributes and
81-
the `include` attributes (set difference operation). This will result in an entity that is not a valid Item if any
82-
of the excluded attributes are in the default set of attributes.
83-
4. If both `include` and `exclude` attributes are specified, semantics are that a field must be included and **not**
84-
excluded. E.g., if `properties` is included and `properties.datetime` is excluded, then `datetime` must not appear
85-
in the attributes of `properties`.
81+
2. If only `include` is specified, these attributes should be the only attributes included.
82+
3. If only `exclude` is specified, these attributes are subtracted from the full item.
83+
This may result in an entity that is not a valid STAC Item.
84+
4. If `exclude` is specified and `include` is null or an empty
85+
array, then the `exclude` attributes are subtracted from the default set.
86+
This may result in an entity that is not a valid STAC Item.
87+
5. If a key is in `exclude`, and a sub-key is in `include`, the sub-key should be included, but no other fields
88+
in the key should be included. E.g., if `properties` is excluded and `properties.datetime` is included, then `datetime`
89+
should be the only attribute in `properties`.
90+
6. If a key is in `include`, and a sub-key is in `exclude`, the key should be included, and the sub-key should be excluded.
91+
E.g., if `properties` is included and `properties.datetime` is excluded, then `datetime`
92+
should not be in `properties`.
93+
7. If the same attribute is present in both `include` and `exclude`, it should be included.
8694

8795
## Examples
8896

89-
Return baseline fields. This **must** return valid STAC Item entities.
97+
Return the default fields. This should return valid STAC Item entities.
9098

9199
Query Parameters
92-
```http
100+
101+
```text
93102
?fields=
94103
```
95104

96105
JSON
106+
97107
```json
98108
{
99109
"fields": {
100110
}
101111
}
102112
```
103113

104-
This has a similar effect as an empty object for `fields`, but it is up to the discretion of the implementation
114+
This has a similar effect as an empty object for `fields`, but it is up to the discretion of the implementation.
105115

106116
Query Parameters
107-
```http
108-
?fields=id,type,geometry,bbox,properties,links,assets
117+
118+
```text
119+
?fields=id,type,geometry,bbox,properties.datetime,links,assets,stac_version
109120
```
110121

111122
JSON
123+
112124
```json
113125
{
114126
"fields": {
@@ -117,22 +129,25 @@ JSON
117129
"type",
118130
"geometry",
119131
"bbox",
120-
"properties",
132+
"properties.datetime",
121133
"links",
122-
"assets"
134+
"assets",
135+
"stac_version",
123136
]
124137
}
125138
}
126139
```
127140

128-
Exclude `geometry` from the baseline fields. This **must** return an entity that is not a valid GeoJSON Feature or a valid STAC Item.
141+
Exclude `geometry` from the full item. This **must** return an entity that is not a valid GeoJSON Feature or a valid STAC Item.
129142

130143
Query Parameters
131-
```http
144+
145+
```text
132146
?fields=-geometry
133147
```
134148

135149
JSON
150+
136151
```json
137152
{
138153
"fields": {
@@ -143,17 +158,17 @@ JSON
143158
}
144159
```
145160

146-
To return the `id`, `type`, `geometry`, and the Properties attribute `eo:cloud_cover`.
147-
This **must** return a valid STAC Item, as the includes are added to the default includes.
148-
Explicitly specifying `id`, `type`, and `geometry` has not effect as these are default fields,
149-
but `properties.eo:cloud_cover` is not a default field and thereby should be in the response.
161+
Return the `id`, `type`, `geometry`, and the Properties attribute `eo:cloud_cover`.
162+
This might not return a valid STAC Item, since not all required Item attributes are included.
150163

151164
Query Parameters
152-
```http
165+
166+
```text
153167
?fields=id,type,geometry,properties.eo:cloud_cover
154168
```
155169

156170
JSON
171+
157172
```json
158173
{
159174
"fields": {
@@ -170,16 +185,19 @@ JSON
170185
To include `id` and all the properties fields, except for the `foo` field.
171186

172187
Query Parameters
173-
```http
188+
189+
```text
174190
?fields=id,properties,-properties.foo
175191
```
176192

177193
also valid:
178-
```http
194+
195+
```text
179196
?fields=+id,+properties,-properties.foo
180197
```
181198

182199
JSON
200+
183201
```json
184202
{
185203
"fields": {

0 commit comments

Comments
 (0)