Skip to content

Commit ae0d046

Browse files
authored
Merge pull request #72 from radiantearth/fragments
Fragments
2 parents 211f372 + 3771f2a commit ae0d046

File tree

8 files changed

+203
-160
lines changed

8 files changed

+203
-160
lines changed

fragments/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
# STAC API - Fragments
2+
3+
This directory contains reusable OpenAPI fragments that are used by other capabilities. They tend to
4+
be common API components such as parameters that get mixed in to various endpoints.
5+
They are kept in this separate fragment directory as they are not specific to any extension and are meant
6+
to be re-used when drafting new API extensions.
7+
8+
For example '[sort](sort/)' introduces a parameter (`sortby`) that can be used by both [item-search](../item-search)
9+
at the `/search` endpoint, and by [features](../ogcapi-features) in any of its `items` endpoints. To keep
10+
things clean we specify a conformance class for each, so clients can know exactly what to expect. Each
11+
conformance class is specified in the relevant folder as an 'extension' to the main capability. But their
12+
semantics are exactly the same, so we put the shared openapi definition in this `fragments` directory.
13+
14+
| Fragment Name | Description |
15+
|----------------------------------------|----------------------------------------------------------------------------|
16+
| [Fields](fields/README.md) | Adds parameter to control which fields are returned in the response. |
17+
| [Query](query/README.md) | Adds parameter to compare properties and only return the items that match |
18+
| [Context](context/README.md) | Adds search related metadata (context) to GeoJSON Responses. |
19+
| [Sort](sort/README.md) | Adds Parameter to control sorting of returns results. |

fragments/context/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
This extension is intended to augment the core ItemCollection
99
object when the ItemCollection is the result of a search, for example, from calling the `/search` API endpoint.
1010

11-
**Note**: *This extension is currently scoped to just the [STAC Item Search](../../item-search) functionality.
11+
**Note**: *This extension is currently only used by [STAC Item Search](../../item-search) functionality.
1212
OGC API has their own way returning `numberMatched` and `numberReturned` at the top level, instead of in a context
1313
object. We are hoping to [align](https://github.com/opengeospatial/ogcapi-common/issues/82), but until then it
1414
is recommended to use STAC Context in the cross-collection `search` endpoint, and follow the OGC API way when

fragments/fields/README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
- **Dependents:**
66
- [Item Search](../../item-search)
77

8-
By default, the STAC search endpoint `/search` returns all attributes of each Item, as there is no way to specify
9-
exactly those attributes that should be returned. The Fields API Extension adds new functionality that allows the
10-
client to suggest to the server which Item attributes should be included or excluded in the response.
8+
STAC API by default returns everything within an item. But Items can have hundreds of fields, or incredibly large
9+
geometries, and even smaller Items can get big when millions are requested but not all information is used. This
10+
fragment provides a mechanism for clients to request that servers to explicitly include or exclude certain fields.
1111

12-
When calling `/search` using POST with`Content-Type: application/json`, this extension adds an attribute `fields` with
12+
When used in a POST request with `Content-Type: application/json`, this adds an attribute `fields` with
1313
an object value to the core JSON search request body. The `fields` object contains two attributes with string array
1414
values, `include` and `exclude`.
1515

16-
When calling `/search` using GET or POST with `Content-Type: application/x-www-form-urlencoded` or
16+
When used with GET or POST with `Content-Type: application/x-www-form-urlencoded` or
1717
`Content-Type: multipart/form-data`, the semantics are the same, except the syntax is a single parameter `fields` with
1818
a comma-separated list of attribute names, where `exclude` values are those prefixed by a `-` and `include` values are
1919
those with no prefix, e.g., `-geometry`, or `id,-geometry,properties`.
@@ -29,7 +29,7 @@ polygons can be very large when reprojected to EPSG:4326, as in the case of a hi
2929
Implementations are also not required to implement semantics for nested values whereby one can include an object, but
3030
exclude attributes of that object, e.g., include `properties` but exclude `properties.datetime`.
3131

32-
No error should be returned if a specified field has no value for it in the catalog. For example, if the attribute
32+
No error should be returned if a specified field has no value for it in the catalog. For example, if the attribute
3333
"properties.eo:cloud_cover" is specified but there is no cloud cover value for an Item or the API does not even
3434
support the EO Extension, a successful HTTP response should be returned and the Item entities will not contain that
3535
attribute.
@@ -42,11 +42,6 @@ will not be a valid STAC Item.
4242
Implementations may return attributes not specified, e.g., id, but should avoid anything other than a minimal entity
4343
representation.
4444

45-
**NOTE**: *This extension is built to be compatible
46-
[OAFeat](https://github.com/opengeospatial/ogcapi-features) endpoints, but does not yet have a conformance
47-
class to use in that way. Our goal is to align with OGC API functionality, which looks to be prioritized currently as
48-
[future work](https://github.com/opengeospatial/ogcapi-features/issues/451)*
49-
5045
## Include/Exclude Semantics
5146

5247
1. If `fields` attribute is specified with an empty object, or with both `include` and `exclude` set to null or an

fragments/query/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
- **OpenAPI specification:** [openapi.yaml](openapi.yaml)
44
- **Extension [Maturity Classification](../../extensions.md#extension-maturity):** Pilot
5-
Likely to get deprecated in the future in favor of CQL.
5+
Likely to get deprecated in the future in favor of [CQL](http://docs.opengeospatial.org/DRAFTS/19-079.html).
66
- **Dependents:**
77
- [Item Search](../../item-search)
88

9-
The STAC search endpoint, `/search`, by default only accepts a limited set of core filter parameters.
10-
The Query API extension adds additional filters for searching on the properties of Items.
9+
The `query` parameter adds additional filters for searching on the properties of Items.
1110

1211
The syntax for the `query` filter is:
1312

fragments/sort/README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
- **Fragment [Maturity Classification](../../extensions.md#extension-maturity):** Pilot
55
- **Dependents:**
66
- [Item Search](../../item-search)
7-
8-
By default, the STAC search endpoint `/search` returns results in no specified order. Whatever order the results are in
9-
is up to the implementor, and will typically default to an arbitrary order that is fastest for the underlying data store
10-
to retrieve results.
117

12-
The Sort API Extension adds a new parameter, `sortby`, that allows the user to define fields by which to sort results.
8+
This defines a new parameter, `sortby`, that allows the user to define fields by which to sort results.
139
Only string, numeric, and datetime attributes of Item (`id` and `collection` only) or Item Properties (any attributes)
1410
may be used to sort results. It is not required that implementations support sorting over all attributes, but
1511
implementations should return an error when attempting to sort over a field that does not support sorting.
@@ -18,13 +14,13 @@ Fields may be sorted in ascending or descending order. The syntax between GET r
1814
body vary. The `sortby` value is an array, so multiple sort fields can be defined which will be used to sort
1915
the data in the order provided (e.g., first by `datetime`, then by `eo:cloud_cover`).
2016

21-
**NOTE**: *This extension is built to be compatible [OAFeat](../../ogcapi-features/README.md) endpoints,
22-
but does not yet have a conformance class to use in that way.
23-
Our goal is to align with OGC API functionality, which is currently being worked on as part of OGC API - Records.*
17+
**NOTE**: *This fragment may change, as our goal is to align with OGC API functionality, and sorting is currently being
18+
worked on as part of OGC API - Records, see [this issue](https://github.com/opengeospatial/ogcapi-records/issues/22)
19+
for the latest discussion.*
2420

2521
## HTTP GET (or POST Form)
2622

27-
When calling `/search` using GET (or POST with `Content-Type: application/x-www-form-urlencoded` or
23+
When calling a relevant endpoint using GET (or POST with `Content-Type: application/x-www-form-urlencoded` or
2824
`Content-Type: multipart/form-data)`, a single parameter `sortby` with a comma-separated list of item field names should
2925
be provided. The field names may be prefixed with either "+" for ascending, or "-" for descending. If no sign is
3026
provided before the field name, it will be assumed to be "+".
@@ -41,7 +37,7 @@ Note that examples 1 and 2 are symantically equivalent, as well as examples 3 an
4137

4238
## HTTP POST JSON Entity
4339

44-
When calling `/search` using POST with`Content-Type: application/json`, this extension adds an attribute `sortby` with
40+
When calling the relevant endpoint using POST with`Content-Type: application/json`, this adds an attribute `sortby` with
4541
an object value to the core JSON search request body.
4642

4743
The syntax for the `sortby` attribute is:

item-search/README.md

Lines changed: 49 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search>
55
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
66
- **Dependencies**: [STAC API - Core](../core)
7+
- **Examples**: [examples.md](examples.md)
78

89
A search endpoint, linked to from the STAC landing page, provides the ability to query STAC `Items` across collections.
910
It retrieves a group of Items that match the provided parameters, wrapped in an ItemCollection (which is a
@@ -28,32 +29,6 @@ This link should look like:
2829
}
2930
```
3031

31-
## Extensions
32-
33-
### Context
34-
35-
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#context>**
36-
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
37-
- **Dependencies**: [STAC API - Context Fragment](../fragments/context/)
38-
39-
### Fields
40-
41-
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#fields>
42-
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
43-
- **Dependencies**: [STAC API - Fields Fragment](../fragments/fields/)
44-
45-
### Query
46-
47-
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#query>
48-
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
49-
- **Dependencies**: [STAC API - Query Fragment](../fragments/query/)
50-
51-
### Sort
52-
53-
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#sort>
54-
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
55-
- **Dependencies**: [STAC API - Sort Fragment](../fragments/sort/)
56-
5732
## Query Parameters and Fields
5833

5934
The following list of parameters is used to narrow search queries. They can all be represented as query string parameters
@@ -75,6 +50,8 @@ GET /search?collections=landsat8,sentinel&bbox=-10.415,36.066,3.779,44.213&limit
7550
}
7651
```
7752

53+
For more examples see [examples.md](examples.md).
54+
7855
### Query Parameter Table
7956

8057
The core parameters for STAC search are defined by OAFeat, and STAC adds a few parameters for convenience.
@@ -89,7 +66,7 @@ The core parameters for STAC search are defined by OAFeat, and STAC adds a few p
8966
| collections | \[string] | STAC | Array of one or more Collection IDs to include in the search for items. Only Items in one of the provided Collections will be searched |
9067

9168
Only one of either **intersects** or **bbox** should be specified. If both are specified, a 400 Bad Request response
92-
should be returned. See [examples](#examples) to see sample requests.
69+
should be returned. See [examples](examples.md) to see sample requests.
9370

9471
## Response
9572

@@ -180,124 +157,61 @@ searching on specific Item properties.
180157
The other HTTP verbs are not supported in STAC Item Search. The [Transaction Extension](../ogcapi-features/extensions/transaction/README.md)
181158
does implement them, for STAC and OAFeat implementations that want to enable writing and deleting items.
182159

183-
#### Examples
160+
## Extensions
184161

185-
##### Simple GET based search
186-
Request:
187-
```http
188-
HTTP GET /search?bbox=-110,39.5,-105,40.5
189-
```
162+
These extensions provide additional functionality that enhances the core item search. All are specified as
163+
[fragments](../fragments), as they are re-used by other extensions STAC API's that offer the following capabilities at
164+
the `search` endpoint must include the relevant **conformance URI** in the `conformsTo` response at
165+
the root (`/`) landing page, to indicate to clients that they will respond properly to requests from clients.
190166

191-
Response with `200 OK`:
192-
```json
193-
{
194-
"type": "FeatureCollection",
195-
"features": [],
196-
"links": [
197-
{
198-
"rel": "next",
199-
"href": "http://api.cool-sat.com/search?page=2"
200-
}
201-
]
202-
}
203-
```
204-
Following the link `http://api.cool-sat.com/search?page=2` will send the user to the next page of results.
167+
### Fields
205168

206-
##### POST search with body and merge fields
207-
Request to `HTTP POST /search`:
208-
```json
209-
{
210-
"bbox": [-110, 39.5, -105, 40.5]
211-
}
212-
```
169+
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#fields>
170+
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
171+
- **Definition**: [STAC API - Fields Fragment](../fragments/fields/)
213172

214-
Response with `200 OK`:
215-
```json
216-
{
217-
"type": "FeatureCollection",
218-
"features": [],
219-
"links": [
220-
{
221-
"rel": "next",
222-
"href": "http://api.cool-sat.com/search",
223-
"method": "POST",
224-
"body": {
225-
"page": 2,
226-
"limit": 10
227-
},
228-
"merge": true
229-
}
230-
]
231-
}
232-
```
173+
By default, the STAC search endpoint `/search` returns all attributes of each Item, as there is no way to specify
174+
exactly those attributes that should be returned. The Fields extension to Item Search adds new functionality that
175+
allows the client to suggest to the server which Item attributes should be included or excluded in the response,
176+
through the use of a `fields` parameter. The full description of how this extension works can be found in the
177+
[fields fragment](../fragments/fields/).
233178

234-
This tells the client to POST to the search endpoint using the original request with the `page` and `limit` fields
235-
merged in to obtain the next set of results:
179+
### Query
236180

237-
Request to `POST /search`:
238-
```json
239-
{
240-
"bbox": [-110, 39.5, -105, 40.5],
241-
"page": 2,
242-
"limit": 10
243-
}
244-
```
181+
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#query>
182+
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
183+
- **Definition**: [STAC API - Query Fragment](../fragments/query/)
245184

246-
This can be even more effective when using continuation tokens on the server, as the entire request body need not be
247-
repeated in the subsequent request:
185+
The STAC search endpoint, `/search`, by default only accepts a limited set of parameters to limit the results
186+
by properties. The Query extension adds a new parameter, `query`, that can take a number of comparison operators to
187+
match predicates between the fields requested and the values of Items. It can be used with both GET and POST, though
188+
GET includes the exact same JSON. The full details on the JSON structure are specified in the [query
189+
fragment](../fragments/query/).
248190

249-
Response with `200 OK`:
250-
```json
251-
{
252-
"rel": "next",
253-
"href": "http://api.cool-sat.com/search",
254-
"method": "POST",
255-
"body": {
256-
"next": "a9f3kfbc98e29a0da23"
257-
}
258-
}
259-
```
260-
The above link tells the client not to merge (default of false) so it is only required to pass the next token in the body.
191+
### Sort
261192

262-
Request to `POST /search`:
263-
```json
264-
{
265-
"next": "a9f3kfbc98e29a0da23"
266-
}
267-
```
193+
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#sort>
194+
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
195+
- **Definition**: [STAC API - Sort Fragment](../fragments/sort/)
268196

269-
##### POST search using headers
270-
Request to `HTTP POST /search`:
271-
```json
272-
{
273-
"bbox": [-110, 39.5, -105, 40.5],
274-
"page": 2,
275-
"limit": 10
276-
}
277-
```
197+
By default, the STAC search endpoint `/search` returns results in no specified order. Whatever order the results are in
198+
is up to the implementor, and will typically default to an arbitrary order that is fastest for the underlying data store
199+
to retrieve results. This extension adds a new parameter, `sortby`, that lets a user specify a comma separated list of
200+
field names to sort by, with an indication of direction. It can be used with both GET and POST, the former using '+' and
201+
'-' to indicate sort order, and the latter including a 'direction' field in JSON. The full description of the semantics
202+
of this extension can be found in the [sort fragment](../fragments/sort).
278203

279-
Response with `200 OK`:
280-
```json
281-
{
282-
"type": "FeatureCollection",
283-
"features": [],
284-
"links": [
285-
{
286-
"rel": "next",
287-
"href": "http://api.cool-sat.com/search",
288-
"method": "POST",
289-
"headers": {
290-
"Search-After": "LC81530752019135LGN00"
291-
}
292-
}
293-
]
294-
}
295-
```
204+
### Context
296205

297-
This tells the client to POST to the search endpoint with the header `Search-After` to obtain the next set of results:
206+
- **Conformance URI:** <http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#context>**
207+
- **Extension [Maturity Classification](../extensions.md#extension-maturity):** Pilot
208+
- **Definition**: [STAC API - Context Fragment](../fragments/context/)
298209

299-
Request:
300-
```http
301-
POST /search
302-
Search-After: LC81530752019135LGN00
303-
```
210+
This extension is intended to augment the core ItemCollection responses from the `search` API endpoint with a
211+
JSON object called `context` that includes the number of items `matched`, `returned` and the `limit` requested.
212+
The full description and examples of this are found in the [context fragment](../fragments/context)
213+
214+
STAC API's that support the context functionality must include the conformance class
215+
<http://stacspec.org/spec/api/1.0.0-beta.1/extensions/item-search#context> in the `conformsTo` response at
216+
the root (`/`) landing page, to indicate to clients that they will to respond with a `context` JSON object in all
217+
responses from the `search` endpoint.

0 commit comments

Comments
 (0)