|
3 | 3 | #' @param args arguments from individual functions |
4 | 4 | #' @param output_id Name of id column to return |
5 | 5 | #' @param service Endpoint name. |
6 | | -#' @param split_into Number of monitoring_location_ids to chunk requests into. |
| 6 | +#' @param \dots Used to force users to fully name the details argument. |
| 7 | +#' @param chunk_size Number of monitoring_location_ids to chunk requests into. |
7 | 8 | #' |
8 | 9 | #' @noRd |
9 | 10 | #' @return data.frame with attributes |
10 | 11 | get_ogc_data <- function(args, |
11 | 12 | output_id, |
12 | 13 | service, |
13 | | - split_into = 250){ |
| 14 | + ..., |
| 15 | + chunk_size = 250){ |
14 | 16 |
|
15 | | - |
16 | | - if(length(args[["monitoring_location_id"]]) > split_into){ |
| 17 | + rlang::check_dots_empty() |
| 18 | + |
| 19 | + if(length(args[["monitoring_location_id"]]) > chunk_size){ |
17 | 20 |
|
18 | 21 | ml_splits <- split(args[["monitoring_location_id"]], |
19 | | - ceiling(seq_along(args[["monitoring_location_id"]])/split_into)) |
| 22 | + ceiling(seq_along(args[["monitoring_location_id"]])/chunk_size)) |
20 | 23 |
|
21 | 24 | rl <- lapply(ml_splits, function(x) { |
22 | 25 | args[["monitoring_location_id"]] <- x |
23 | 26 | get_ogc_data(args = args, |
24 | 27 | output_id = output_id, |
25 | 28 | service = service)}) |
26 | | - rl_filtered <- rl[sapply(rl, function(x) dim(x)[1]) > 0] |
| 29 | + |
| 30 | + rl_filtered <- rl[vapply(rl, |
| 31 | + FUN = function(x) dim(x)[1], |
| 32 | + FUN.VALUE = NA_integer_) > 0] |
27 | 33 |
|
28 | | - return_list <- do.call(rbind, rl_filtered) |
| 34 | + return_list <- data.frame(data.table::rbindlist(rl_filtered, |
| 35 | + use.names = TRUE, |
| 36 | + ignore.attr = TRUE)) |
29 | 37 |
|
30 | 38 | } else { |
31 | 39 | args[["chunk_sites_by"]] <- NULL |
|
0 commit comments