Skip to content

Commit a268ad8

Browse files
committed
forgot we are importing data.table now, rbindlist is way faster
1 parent dde01f8 commit a268ad8

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ Imports:
5656
httr2,
5757
whisker,
5858
sf,
59-
data.table
59+
data.table,
60+
rlang
6061
Suggests:
6162
covr,
6263
dplyr,

R/get_ogc_data.R

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,37 @@
33
#' @param args arguments from individual functions
44
#' @param output_id Name of id column to return
55
#' @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.
78
#'
89
#' @noRd
910
#' @return data.frame with attributes
1011
get_ogc_data <- function(args,
1112
output_id,
1213
service,
13-
split_into = 250){
14+
...,
15+
chunk_size = 250){
1416

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){
1720

1821
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))
2023

2124
rl <- lapply(ml_splits, function(x) {
2225
args[["monitoring_location_id"]] <- x
2326
get_ogc_data(args = args,
2427
output_id = output_id,
2528
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]
2733

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))
2937

3038
} else {
3139
args[["chunk_sites_by"]] <- NULL

man/read_waterdata_combined_meta.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)