Skip to content

Commit

Permalink
Fill in missing argument definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
elipousson committed Oct 9, 2024
1 parent 10f82fc commit bb23938
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
5 changes: 2 additions & 3 deletions R/is_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ is_what <- function(x, what = NULL, allow_null = FALSE) {
#' What is the class or spatial attributes of this feature?
#'
#' @param x An `sf`, `sfc`, or `bbox` object.
#' @param y An sf object or a character or numeric object supported by
#' [sf::st_crs] that can be compared to x. (used by [is_same_crs])
#' @param ext If `TRUE`, check if x is a `sf`, `sfc`, or `bbox` class object or
#' not; defaults to `FALSE`. (used by [is_sf])
#' @param allow_null If `TRUE` and x is `NULL`, return `TRUE`; defaults to `FALSE`.
Expand All @@ -27,7 +25,6 @@ is_what <- function(x, what = NULL, allow_null = FALSE) {
#' - [is_sp]: is x a `Spatial` class object of any type?
#' - [is_geo_coords]: is x likely a geodetic coordinate pair (a length 2 numeric vector, with a max absolute value less than or equal to 180)?
#' - [is_wgs84]: is x using the [WSG84](https://en.wikipedia.org/wiki/World_Geodetic_System) coordinate reference system?
#' - [is_same_crs]: do x and y have the same coordinate reference system?
#'
#' @example examples/is_sf.R
#' @export
Expand Down Expand Up @@ -58,6 +55,8 @@ is_sfc <- function(x, allow_null = FALSE) {

#' @name is_bbox
#' @rdname is_sf
#' @param allow_na If `TRUE`, [is_bbox()] ignores any `NA` values. Defaults to
#' `FALSE`.
#' @export
is_bbox <- function(x, allow_null = FALSE, allow_na = FALSE) {
is_what(x, what = "bbox", allow_null = allow_null) &&
Expand Down
10 changes: 7 additions & 3 deletions R/mapview_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#'
#' @inheritParams mapview::mapview
#' @inheritDotParams mapview::mapview
#' @param remove_na If TRUE and zcol is not `NULL`, filter `NA` values from the
#' zcol before passing to [mapview::mapview()]
#' @param remove_na If `TRUE` and `zcol` is not `NULL`, filter `NA` values from
#' the data frame column defined by `zcol` before passing to
#' [mapview::mapview()]
#' @inheritParams mapview_popup_img
#' @seealso
#' [mapview::mapview()]
Expand Down Expand Up @@ -42,8 +43,9 @@ mapview_ext <- function(x, zcol = NULL, remove_na = FALSE, ...) {

#' @rdname mapview_ext
#' @name mapview_exif
#' @export
#' @inheritParams read_sf_exif
#' @param fileext File extension. Defaults to "jpeg".
#' @export
mapview_exif <- function(path = NULL,
fileext = "jpeg",
popup = TRUE,
Expand All @@ -70,6 +72,8 @@ mapview_exif <- function(path = NULL,
#' image width, and image height.
#' @name mapview_popup_img
#' @rdname mapview_ext
#' @inheritParams leafpop::addPopupImages
#' @inheritParams rlang::args_error_context
#' @export
mapview_popup_img <- function(images,
popup = TRUE,
Expand Down
1 change: 1 addition & 0 deletions R/read_sf_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ read_sf_esri <- function(url,

#' @name read_sf_felt
#' @rdname read_sf_ext
#' @inheritParams feltr::read_felt_map
#' @export
read_sf_felt <- function(url = NULL,
bbox = NULL,
Expand Down
2 changes: 2 additions & 0 deletions R/sf_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ NULL
#' @param ... For [sf_list_rbind()], additional parameters passed to
#' [purrr::list_rbind()]. For [map_as_sf()], additional parameters passed to
#' map.
#' @inheritParams st_transform_ext
#' @inheritParams rlang::args_error_context
#' @export
#' @importFrom dplyr summarize group_keys group_nest
Expand Down Expand Up @@ -187,6 +188,7 @@ sf_list_rbind <- function(x, ...) {

#' @name map_as_sf
#' @rdname sf_list
#' @inheritParams purrr::map
map_as_sf_list <- function(x, .f, ...) {
vctrs::new_list_of(
x = map(x, .f, ...),
Expand Down
4 changes: 3 additions & 1 deletion R/st_buffer_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#' @param single_side If `TRUE`, single-sided buffers are returned for linear
#' geometries, in which case negative dist values give buffers on the
#' right-hand side, positive on the left.
#' @param allow_list If `TRUE`, allow sf list objects as an input and use
#' @param allow_null If `TRUE` (default) and x is `NULL`, a `NULL` value is
#' returned with no error.
#' @param allow_list If `TRUE` (default), allow sf list objects as an input and use
#' [purrr::map()] to apply the provided parameters to each object within the
#' list to return as a new sf list object.
#' @param ... Additional parameters passed to [sf::st_buffer()]
Expand Down
15 changes: 11 additions & 4 deletions R/st_erase.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Erase or trim geometry of a sf or sfc object
#'
#' This function extends [sf::st_difference()] by unioning the second parameter
#' [st_erase()] extends [sf::st_difference()] by unioning the second parameter
#' by default, checking validity of inputs, and optionally (when `flip = TRUE`)
#' using [sf::st_intersection()] instead of [sf::st_difference]. [st_trim()] is
#' equivalent to [st_erase()] with flip set to `TRUE`.
Expand All @@ -10,13 +10,20 @@
#' @param flip If `TRUE`, use [sf::st_intersection()] to "erase" geometry of x
#' that intersects y; if `FALSE` use [sf::st_difference()] to trim x to y
#' geometry, Default: `FALSE`.
#' @param union If `TRUE`, use [sf::st_combine()] and [sf::st_union()] on y
#' before applying difference/intersection; defaults to `TRUE`.
#' @param union If `TRUE`, union `y` with [sf::st_union()] before applying
#' difference/intersection; defaults to `TRUE`.
#' @param combine If `TRUE` and `union = TRUE`, combine `y` with
#' [sf::st_combine()] before unioning. Defaults to `FALSE`.
#' @inheritParams sf::st_difference
#' @example examples/st_erase.R
#' @export
#' @importFrom sf st_union st_combine st_intersection st_difference
st_erase <- function(x, y, flip = FALSE, union = TRUE, combine = FALSE, ...) {
st_erase <- function(x,
y,
flip = FALSE,
union = TRUE,
combine = FALSE,
...) {
check_sf(x, ext = TRUE)

if (is_bbox(x)) {
Expand Down
5 changes: 5 additions & 0 deletions R/st_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ st_circumscribed_circle <- function(x,
#' @rdname st_misc
#' @name st_donut
#' @param width Donut width as proportion of outer size.
#' @param scale For [st_donut()], scale to apply to donut using [st_circle()].
#' Defaults to 1 which keeps the donut as the same size as the input object.
#' @param by_feature For [st_donut()], if `TRUE` the input object `x` is unioned
#' before converting into a donut geometry. If `FALSE`, each feature in the
#' input data remains a separate feature in the output.
#' @export
#' @importFrom sf st_inscribed_circle
st_donut <- function(x,
Expand Down
4 changes: 3 additions & 1 deletion R/st_square.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#' @param by_feature If `TRUE`, create new geometry for each feature. If
#' `FALSE`, create new geometry for all features combine with
#' [st_union_ext()].
#' @param ... Additional parameters passed to [st_square()] `sfc` method if x is
#' a `sf` or `bbox` object.
#' @examples
#' nc <- sf::read_sf(system.file("shape/nc.shp", package = "sf"))
#' nc <- sf::st_transform(nc, crs = 3857)
Expand All @@ -27,7 +29,7 @@ st_square <- function(x,
inscribed = FALSE,
by_feature = FALSE,
call = caller_env()) {
check_sf(x, ext = TRUE)
check_sf(x, ext = TRUE, call = call)
UseMethod("st_square")
}

Expand Down

0 comments on commit bb23938

Please sign in to comment.