Skip to content

Commit 3ae3ade

Browse files
Merge pull request DOI-USGS#753 from ldecicco-USGS/develop
Add post stuff to readWQPdata
2 parents 5ee2e1a + e79be61 commit 3ae3ade

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

R/readWQPdata.R

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ readWQPdata <- function(...,
254254
convertType = TRUE) {
255255

256256
tz <- match.arg(tz, OlsonNames())
257-
257+
258258
service <- match.arg(service, c("Result", "Station", "Activity",
259259
"ActivityMetric", "SiteSummary",
260260
"Project", "ProjectMonitoringLocationWeighting",
@@ -267,8 +267,9 @@ readWQPdata <- function(...,
267267

268268
valuesList <- readWQPdots(..., legacy = legacy)
269269
values <- valuesList[["values"]]
270-
270+
271271
baseURL <- httr2::request(pkg.env[[service]])
272+
POST = FALSE
272273

273274
if(!legacy){
274275
if(service == "ResultWQX3" & !"dataProfile" %in% names(values)){
@@ -281,23 +282,28 @@ readWQPdata <- function(...,
281282
if("siteid" %in% names(values)){
282283
if(length(values[["siteid"]]) > 1){
283284
sites <- values[["siteid"]]
284-
baseURL <- httr2::req_url_query(baseURL,
285-
siteid = sites,
286-
.multi = function(x) paste0(x, collapse = ";"))
285+
POST = nchar(paste0(sites, collapse = "")) > 2048
286+
287+
baseURL <- get_or_post(baseURL,
288+
POST = POST,
289+
siteid = sites,
290+
.multi = function(x) paste0(x, collapse = ";"))
287291
values <- values[names(values) != "siteid"]
288292
}
289293
}
290-
baseURL <- httr2::req_url_query(baseURL, !!!values,
291-
.multi = "explode")
294+
baseURL <- get_or_post(baseURL,
295+
POST = POST,
296+
!!!values,
297+
.multi = "explode")
292298
}
293-
299+
294300
if (querySummary) {
295301
retquery <- getQuerySummary(baseURL)
296302
return(retquery)
297303
} else {
298304
retval <- importWQP(baseURL,
299-
tz = tz,
300-
convertType = convertType
305+
tz = tz,
306+
convertType = convertType
301307
)
302308

303309
if(is.null(retval)){
@@ -313,7 +319,7 @@ readWQPdata <- function(...,
313319
params <- params[!names(params) %in% c("dataProfile", "service")]
314320
retval <- create_WQP_attributes(retval, params)
315321
}
316-
322+
317323
attr(retval, "url") <- baseURL$url
318324

319325
if(legacy){
@@ -329,7 +335,7 @@ readWQPdata <- function(...,
329335

330336

331337
create_WQP_attributes <- function(retval, ...){
332-
338+
333339
col_legacy <- c("CharacteristicName", #legacy
334340
"ResultMeasure.MeasureUnitCode",
335341
"ResultSampleFractionText")
@@ -342,7 +348,7 @@ create_WQP_attributes <- function(retval, ...){
342348
names(retvalVariableInfo) <- c("characteristicName",
343349
"param_units",
344350
"valueType")
345-
351+
346352
attr(retval, "variableInfo") <- retvalVariableInfo
347353
} else if(all(col_wqx3 %in% names(retval))){
348354
retvalVariableInfo <- retval[, col_wqx3]

0 commit comments

Comments
 (0)