|
8 | 8 | #'
|
9 | 9 | #' Users should parse and validate parameters such as `collection_id`,
|
10 | 10 | #' `bbox`, and `datetime` before calling these functions.
|
11 |
| -#' `openstac` provides functions like `parse_json()`, `parse_datetime()`, |
12 |
| -#' `parse_dbl()`, `parse_int()`, and `parse_str()` to facilitate this process. |
| 11 | +#' `openstac` provides functions like `parse_geojson()`, `parse_datetime()`, |
| 12 | +#' `parse_dbl()`, `parse_int()`, and `parse_str()` to facilitate this |
| 13 | +#' process. |
13 | 14 | #'
|
14 | 15 | #' \itemize{
|
15 | 16 | #'
|
16 |
| -#' \item `api_landing_page`: handles the STAC `/` endpoint |
| 17 | +#' \item `create_ogcapi`: Creates an API object for OGC API Features. |
17 | 18 | #'
|
18 |
| -#' \item `api_conformance`: handles the STAC `/conformance` endpoint |
| 19 | +#' \item `create_stac`: Creates an API object for STAC. |
19 | 20 | #'
|
20 |
| -#' \item `api_collections`: handles the STAC `/collections` endpoint |
| 21 | +#' \item `api_landing_page`: Handles the STAC `/` endpoint. |
21 | 22 | #'
|
22 |
| -#' \item `api_collection`: handles the STAC |
23 |
| -#' `/collection/\{collection_id\}` endpoint |
| 23 | +#' \item `api_conformance`: Handles the STAC `/conformance` endpoint. |
24 | 24 | #'
|
25 |
| -#' \item `api_items`: handles the STAC |
26 |
| -#' `/collection/\{collection_id\}/items` endpoint |
| 25 | +#' \item `api_collections`: Handles the STAC `/collections` endpoint. |
27 | 26 | #'
|
28 |
| -#' \item `api_item`: handles the STAC |
29 |
| -#' `/collection/\{collection_id\}/item/\{item_id\}` endpoint |
| 27 | +#' \item `api_collection`: Handles the STAC |
| 28 | +#' `/collection/{collection_id}` endpoint. |
30 | 29 | #'
|
31 |
| -#' \item `api_search`: handles the STAC `/search` endpoint |
| 30 | +#' \item `api_items`: Handles the STAC |
| 31 | +#' `/collection/{collection_id}/items` endpoint. |
| 32 | +#' |
| 33 | +#' \item `api_item`: Handles the STAC |
| 34 | +#' `/collection/{collection_id}/item/{item_id}` endpoint. |
| 35 | +#' |
| 36 | +#' \item `api_search`: Handles the STAC `/search` endpoint. |
32 | 37 | #'
|
33 | 38 | #' }
|
34 | 39 | #'
|
| 40 | +#' @param id A character string specifying the id of the API. |
| 41 | +#' |
| 42 | +#' @param title A character string specifying the title of the API. |
| 43 | +#' |
| 44 | +#' @param description A character string describing the API. |
| 45 | +#' |
| 46 | +#' @param conforms_to A character vector specifying the conformance |
| 47 | +#' standards adhered to by the API. This parameter can be NULL or |
| 48 | +#' contain additional conformance standards to add to the defaults. |
| 49 | +#' |
35 | 50 | #' @param api An object representing the API. This object is typically
|
36 | 51 | #' created using either the `create_stac` or `create_ogcapi`
|
37 | 52 | #'
|
|
45 | 60 | #' @param collection_id The identifier of the collection. This parameter
|
46 | 61 | #' specifies which collection the request is targeting.
|
47 | 62 | #'
|
| 63 | +#' @param item_id The identifier of the item within the specified collection. |
| 64 | +#' This parameter specifies which item the request is targeting. |
| 65 | +#' |
48 | 66 | #' @param limit The maximum number of items to return. If not specified,
|
49 | 67 | #' the default value is used.
|
50 | 68 | #'
|
51 | 69 | #' @param bbox The bounding box for spatial filtering, specified as a
|
52 | 70 | #' numeric vector of four coordinates
|
53 |
| -#' (`minlon`, `minlat`, `maxlon`, `maxlat`). Use `parse_dbl()` to |
| 71 | +#' (`long_min`, `lat_min`, `long_max`, `lat_max`). Use `parse_dbl()` to |
54 | 72 | #' convert comma-separated string to numeric vector.
|
55 | 73 | #'
|
56 | 74 | #' @param datetime The temporal filter for items. It must be specified
|
|
59 | 77 | #' string to this object.
|
60 | 78 | #'
|
61 | 79 | #' @param intersects The spatial filter for items, specified as a GeoJSON
|
62 |
| -#' geometry object representing the area of interest. Use `parse_json()` |
| 80 | +#' geometry object representing the area of interest. Use `parse_geojson()` |
63 | 81 | #' function to convert strings of GeoJSON geometries into an equivalent
|
64 | 82 | #' `list()` object.
|
65 | 83 | #'
|
66 | 84 | #' @param ids A list of item identifiers to filter the search results.
|
67 |
| -#' Use `parse_str()` to convert a comma-separated string to character |
68 |
| -#' vector. |
69 |
| -#' @param collections A list of collection identifiers to filter the search results. |
| 85 | +#' Use `parse_str()` to convert a comma-separated string to a |
| 86 | +#' character vector |
| 87 | +#' |
| 88 | +#' @param collections A list of collection identifiers to filter the |
| 89 | +#' search results. Use `parse_str()` to convert a comma-separated |
| 90 | +#' string to a character vector. |
| 91 | +#' |
70 | 92 | #' @param page The page number of the results when paginating.
|
| 93 | +#' |
71 | 94 | #' @param ... Additional arguments to be passed to the method-specific
|
72 | 95 | #' functions.
|
73 | 96 | #'
|
74 |
| -#' @seealso \code{\link{create_stac}}, \code{\link{create_ogcapi}} |
75 |
| -#' Functions for creating STAC and OGC API objects, respectively. |
| 97 | +#' @return For API creation functions, returns a api object. For API |
| 98 | +#' handling functions, returns the document to return as response. |
| 99 | +#' |
| 100 | +#' @seealso |
| 101 | +#' [create_stac()], [create_ogcapi()]: Functions for creating STAC and |
| 102 | +#' OGC API objects, respectively. |
| 103 | +#' |
| 104 | +#' [parse_int()], [parse_dbl()], [parse_str()], [parse_datetime()], |
| 105 | +#' [parse_geojson()]: Functions to convert HTTP input strings |
| 106 | +#' into R data types. |
76 | 107 | #'
|
77 | 108 | #' @references
|
78 | 109 | #' For more information about the STAC specification,
|
79 | 110 | #' see: \url{https://stacspec.org/}
|
| 111 | +#' |
80 | 112 | #' For more information about the OGC API specification,
|
81 | 113 | #' see: \url{http://www.opengis.net/doc/IS/ogcapi-features-1/1.0}
|
82 | 114 | #'
|
@@ -160,41 +192,3 @@ api_search <- function(api,
|
160 | 192 | page, ...) {
|
161 | 193 | UseMethod("api_search", api)
|
162 | 194 | }
|
163 |
| - |
164 |
| -# Based on https://github.com/rstudio/plumber/issues/66#issuecomment-418660334 |
165 |
| -# HTTP CORS support |
166 |
| -#' @rdname api_helpers |
167 |
| -#' @export |
168 |
| -api_cors_handler <- function(req, res, origin = "*", methods = "*") { |
169 |
| - res$setHeader("Access-Control-Allow-Origin", origin) |
170 |
| - if (req$REQUEST_METHOD != "OPTIONS") { |
171 |
| - plumber::forward() |
172 |
| - } else { |
173 |
| - res$setHeader("Access-Control-Allow-Methods", methods) |
174 |
| - res$setHeader("Access-Control-Allow-Headers", |
175 |
| - req$HTTP_ACCESS_CONTROL_REQUEST_HEADERS) |
176 |
| - res$status <- 200 |
177 |
| - return(list()) |
178 |
| - } |
179 |
| -} |
180 |
| -#' @rdname api_helpers |
181 |
| -#' @export |
182 |
| -api_error_handler <- function(req, res, err) { |
183 |
| - if (is.null(err$status)) err$status <- 500 |
184 |
| - if (is.null(err$message)) err$message <- "Internal server error" |
185 |
| - res$status <- err$status |
186 |
| - list(code = err$status, message = paste("Error:", err$message)) |
187 |
| -} |
188 |
| -#' @rdname api_helpers |
189 |
| -#' @export |
190 |
| -api_stop <- function(status, ...) { |
191 |
| - stop(errorCondition(paste0(...), status = status)) |
192 |
| -} |
193 |
| -#' @rdname api_helpers |
194 |
| -#' @export |
195 |
| -api_stopifnot <- function(expr, status, ...) { |
196 |
| - message <- paste0(...) |
197 |
| - if (!nzchar(message)) |
198 |
| - message <- paste(deparse(substitute(expr)), "is not TRUE") |
199 |
| - if (!expr) api_stop(status, message) |
200 |
| -} |
0 commit comments