It is possible to provide any package to write_dwc(). That package might be missing required resources (already covered) or fields that are used in the mapping. For example, the 2014_demer dataset currently deposited on MDA does not have tag_serial_number in animals. The user currently gets a deep dplyr error for this. It might be useful to provide an error earlier.
I suggest a generic check_cols() function (name similar to expand_cols()), called from within create_animal_occurrences() and create_gps_occurrences():
required_cols <- c("animal_id", "tag_serial_number")
check_cols(animals, required_cols)
It would return TRUE if all is fine, but return a nice error if one of the provided columns is not present. See https://github.com/inbo/movepub/blob/7c20e5aabfa2213a6605e35ffd4fed6d6664e4e5/R/check_ref.R#L16-L24 for inspiration on the error message.
- The function can later be called from
create_ano() too.
- The required_cols could be maintained in each function and test or be stored as globals.
It is possible to provide any
packagetowrite_dwc(). That package might be missing required resources (already covered) or fields that are used in the mapping. For example, the2014_demerdataset currently deposited on MDA does not havetag_serial_numberin animals. The user currently gets a deep dplyr error for this. It might be useful to provide an error earlier.I suggest a generic
check_cols()function (name similar toexpand_cols()), called from withincreate_animal_occurrences()andcreate_gps_occurrences():It would return TRUE if all is fine, but return a nice error if one of the provided columns is not present. See https://github.com/inbo/movepub/blob/7c20e5aabfa2213a6605e35ffd4fed6d6664e4e5/R/check_ref.R#L16-L24 for inspiration on the error message.
create_ano()too.