Commit c5f6b053 authored by Dorchies David's avatar Dorchies David
Browse files

fix(get_hydrometrie_sites): potential issue if using the "fields" parameter

Refs #7
parent ae5eae01
No related merge requests found
Showing with 16 additions and 14 deletions
+16 -14
......@@ -37,22 +37,24 @@ get_hydrometrie_sites <- function(params,
)
bFirst <- TRUE
for (field in fields) {
fieldValue <- unique(unlist(x[[field]]))
if (unique_site && length(fieldValue) > 1) {
if(bFirst) {
warning(
"The site '",
x$code_site,
"' has ",
length(fieldValue),
" different locations, only the first one is returned",
call. = FALSE
)
bFirst <- FALSE
if (!is.null(x[[field]])) {
fieldValue <- unique(unlist(x[[field]]))
if (unique_site && length(fieldValue) > 1) {
if(bFirst) {
warning(
"The site '",
x$code_site,
"' has ",
length(fieldValue),
" different locations, only the first one is returned",
call. = FALSE
)
bFirst <- FALSE
}
fieldValue <- x[[field]][[1]]
}
fieldValue <- x[[field]][[1]]
x[[field]] <- fieldValue
}
x[[field]] <- fieldValue
}
x$geometry <- NULL
x
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment