Skip to content

Commit

Permalink
Merge pull request #290 from inbo/fix-source
Browse files Browse the repository at this point in the history
Fix two `write_eml()` issues
  • Loading branch information
peterdesmet authored Nov 23, 2023
2 parents 545f72f + cd3bbf9 commit 136c02c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: camtraptor
Title: Read, Explore and Visualize Camera Trap Data Packages
Version: 0.21.0
Version: 0.22.0
Authors@R: c(
person("Damiano", "Oldoni", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3445-7562")),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# camtraptor 0.22.0

- Fix bug in `write_eml()` for Camtrap DP 1.0 datasets (#290).
- `read_camtrap_dp()` will now always populate `taxonID` from the
`package.taxonomy` (#290).

# camtraptor 0.21.0

- `read_camtrap_dp()` supports Camtrap DP 1.0 (upcoming Agouti export format)
Expand Down
5 changes: 1 addition & 4 deletions R/write_eml.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ write_eml <- function(package,
)
}
# Sort contributors on order in creators
contributors <- dplyr::slice(
contributors,
order_by = order(factor(.data$title, levels = creators))
)
contributors <- arrange(contributors, factor(title, level = creators))
}
creator_list <- purrr::transpose(contributors) # Create list
message(glue::glue(
Expand Down
17 changes: 12 additions & 5 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,25 @@ add_taxonomic_info <- function(package) {
taxon_infos <- dplyr::select(
taxon_infos,
dplyr::all_of("scientificName"),
dplyr::any_of(c("taxonIDReference",
"taxonRank")),
dplyr::any_of(c("taxonID", "taxonIDReference", "taxonRank")),
dplyr::starts_with("vernacularNames")
)
# add taxon infos to observations
# Add taxon infos to observations
if (!is.null(taxon_infos)) {
cols_taxon_infos <- names(taxon_infos)
observations <-
dplyr::left_join(
package$data$observations,
taxon_infos,
by = c("scientificName")
by = "scientificName"
)
if ("taxonID.y" %in% colnames(observations)) {
# Keep only the taxonID added by join with taxonomy
observations <-
observations %>%
rename("taxonID" = "taxonID.y") %>%
select(-"taxonID.x")
}
package$data$observations <- observations
}
return(package)
Expand Down Expand Up @@ -497,7 +503,8 @@ convert_metadata_to_0.1.6 <- function(package, from = "1.0"){
"The field `sequenceInterval` is deprecated in version {from}."
))
}
package$platform <- package$sources[[1]]$title
package$platform <- package$sources[[1]]

# `title` value of the first contributor with role `rightsHolder`
package$rightsHolder <- purrr::map_df(package$contributors, unlist) %>%
dplyr::filter(.data$role == "rightsHolder") %>%
Expand Down

0 comments on commit 136c02c

Please sign in to comment.