pull/17/head
Norwin 6 years ago
parent e7203cea81
commit 909e4de36d
Signed by: norwin
GPG Key ID: 24BC059DE24C43A3

@ -8,7 +8,7 @@ Imports:
dplyr, dplyr,
httr, httr,
magrittr magrittr
Suggests: Suggests:
maps, maps,
maptools, maptools,
readr, readr,

@ -29,7 +29,7 @@ dplyr_class_wrapper = function(callback) {
#' the callstack. See https://stackoverflow.com/a/33108841 #' the callstack. See https://stackoverflow.com/a/33108841
#' #'
#' @noRd #' @noRd
isNonInteractive = function () { is_non_interactive = function () {
ff <- sapply(sys.calls(), function(f) as.character(f[1])) ff <- sapply(sys.calls(), function(f) as.character(f[1]))
any(ff %in% c("knit2html", "render")) || !interactive() any(ff %in% c("knit2html", "render")) || !interactive()
} }

@ -60,7 +60,7 @@ get_stats_ = function (endpoint) {
} }
osem_request_ = function (host, path, ..., type = 'parsed', progress) { osem_request_ = function (host, path, ..., type = 'parsed', progress) {
progress = if (progress && !isNonInteractive()) httr::progress() else NULL progress = if (progress && !is_non_interactive()) httr::progress() else NULL
res = httr::GET(host, progress, path = path, query = list(...)) res = httr::GET(host, progress, path = path, query = list(...))
if (httr::http_error(res)) { if (httr::http_error(res)) {

@ -106,9 +106,10 @@ parse_get_measurements_params = function (params) {
if (is.null(params$phenomenon) | is.na(params$phenomenon)) if (is.null(params$phenomenon) | is.na(params$phenomenon))
stop('Parameter "phenomenon" is required') stop('Parameter "phenomenon" is required')
if ((!is.na(params$from) && is.na(params$to)) || if (
(!is.na(params$to) && is.na(params$from)) (!is.na(params$from) && is.na(params$to)) ||
) stop('specify "from" only together with "to"') (!is.na(params$to) && is.na(params$from))
) stop('specify "from" only together with "to"')
if ( if (
(!is.null(params$bbox) && !is.null(params$boxes)) || (!is.null(params$bbox) && !is.null(params$boxes)) ||
@ -161,7 +162,7 @@ paged_measurements_req = function (query) {
query$`to-date` = date_as_isostring(page$to) query$`to-date` = date_as_isostring(page$to)
res = do.call(get_measurements_, query) res = do.call(get_measurements_, query)
if (query$progress && !isNonInteractive()) if (query$progress && !is_non_interactive())
cat(paste(query$`from-date`, query$`to-date`, sep = ' - '), '\n') cat(paste(query$`from-date`, query$`to-date`, sep = ' - '), '\n')
res res

Loading…
Cancel
Save