Skip to content

Commit

Permalink
Remove redundant location processing
Browse files Browse the repository at this point in the history
  • Loading branch information
wkmor1 committed Nov 6, 2024
1 parent 63204e4 commit 5d6736b
Show file tree
Hide file tree
Showing 36 changed files with 2 additions and 44 deletions.
41 changes: 1 addition & 40 deletions R/get_occurrences.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ get_occurrences <- function(

}

verbatim_loc <- c(
"county" = "verbatimCounty",
"stateProvince" = "verbatimStateProvince",
"country"= "verbatimCountry"
)

verbatim_loc <- verbatim_loc[intersect(select, names(verbatim_loc))]

media_vars <- NULL

if ("associatedMedia" %in% select) {
Expand All @@ -83,8 +75,7 @@ get_occurrences <- function(

}

select_vars <- unname(verbatim_loc)
select_vars <- c(select, oq, dk, rk, select_vars, type_vars)
select_vars <- c(select, oq, dk, rk, type_vars)
select_vars <- unique(select_vars)
select_vars <- setdiff(select_vars, "associatedMedia")
select_vars <- c(select_vars, media_vars)
Expand All @@ -110,8 +101,6 @@ get_occurrences <- function(

data <- process_occurrence_remarks(data, oq, dk, rk)

data <- process_location(data, verbatim_loc)

data <- process_type_status(data, type_vars, select)

data <- combine_fields(data, combine)
Expand Down Expand Up @@ -301,34 +290,6 @@ process_occurrence_remarks <- function(data, oq, dk, rk) {

#' @noRd

process_location <- function(data, verbatim_loc) {

for (i in seq_along(verbatim_loc)) {

var_name <- names(verbatim_loc)[[i]]

var <- verbatim_loc[[i]]

has_var <- var_name %in% names(data)

if (has_var) {

data[[var_name]] <- ifelse(
is.na(data[[var_name]]), data[[var]], data[[var_name]]
)

}

data[[var]] <- NULL

}

data

}

#' @noRd

process_type_status <- function(data, type_vars, select) {

if (!is.null(type_vars)) {
Expand Down
5 changes: 1 addition & 4 deletions inst/tinytest/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ default:
- associatedMedia
nmax: 2.5e4
filters:
date_range_ymd: ["2000-01-01", ""]
facts:
recordNumber: MY.legID
verbatimElevation: MY.alt
habitat: MY.habitatDescription
combine:
habitat:
- habitat

test:
filters:
date_range_ymd: ["2000-01-01", ""]
Binary file modified inst/tinytest/finbif_cache_file_0828250b14bae0a6132e370c0f9c9f0e
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_0e3359b7535080a42ae70fb62fa5b7a6
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_0f85c5e43611549bb81d21ad9de8f860
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_25a0626b833603fe59365e9753bd00fe
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_2fb2154276c298550219bb368c6b4046
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_3131b57d1ead6947c09e78c72abbb7c1
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_36664b0bba9f45a81e3131747b87fb43
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_3abd792e21e4ce05e3ce1e253b1a3887
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_3bd7fb28a1b04ef8ce230bade2b38f9f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_9b2ec085b19c17b53facba07712b8ad8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_c20c8d743912af6e748f35af894d55e5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_f05a965fe9d224c792ce875d356bc2e0
Binary file not shown.
Binary file not shown.
Binary file modified inst/tinytest/finbif_cache_file_f721ebf2de6b84f6a740654ab9ce0c09
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 5d6736b

Please sign in to comment.