Nothing
#' @importFrom rlang .data check_installed
NULL
#' Download tracking data from data repositories
#'
#' @description
#' Downloads animal tracking data from data repositories (Movebank Data Repository
#' or Zenodo) and returns a `move2` object. This function provides a unified interface
#' for accessing tracking data that has been published in data repositories.
#'
#' @param url A character string containing the URL or DOI of the data repository record.
#' Supported formats:
#' - Movebank Data Repository: DOI URLs like `"https://doi.org/10.5441/001/1.734"`
#' - Zenodo: Record URLs like `"https://zenodo.org/records/5068540"` or DOI URLs like
#' `"https://doi.org/10.5281/zenodo.12336021"`
#' @param ... Additional arguments passed to internal repository-specific download functions.
#' For zenodo `resources` can be used to read only specific resources (e.g. `"gps"`)
#'
#' @return A `move2` object containing the tracking data.
#'
#' @details
#' This function automatically detects whether the provided URL points to a Movebank
#' Data Repository record (via DOI) or a Zenodo record, and uses the appropriate
#' download method.
#'
#'
#' @examples
#' \dontrun{
#' # Download from Movebank Data Repository using DOI
#' move2_data <- mt_get_dataset("http://doi.org/10.5441/001/1.734")
#'
#' # Download from Zenodo using record URL
#' move2_data <- mt_get_dataset("https://zenodo.org/records/12336021",
#' resources="gps")
#'}
#'
#' @seealso
#' [movebank_download_study()] for downloading directly from Movebank API
#' [mt_read()] for reading tracking data from local files
#'
#' @export
mt_get_dataset <- function(url, ...) {
# Determine repository type using case_when
result <- dplyr::case_when(
grepl(
"doi.org/10.5441",
url,
ignore.case = TRUE
) ||
grepl(
"doi:10.5441",
url,
ignore.case = TRUE
) ||
grepl(
"^10.5441/",
url,
ignore.case = TRUE
) ~ "mt_get_dataset_movebank",
grepl(
"doi.org/10.5281/zenodo",
url,
ignore.case = TRUE
) ~ "mt_get_dataset_zenodo",
grepl(
"zenodo.org",
url,
ignore.case = TRUE
) ~ "mt_get_dataset_zenodo",
TRUE ~ NA_character_
)
# Dispatch to appropriate function
if (is.na(result)) {
cli_abort(
c(
"Unsupported repository URL: {url}",
i = "Currently supported repositories are:",
i = "- Movebank Data Repository (DOI URLs with prefix 10.5441)",
i = "- Zenodo (record URLs with domain zenodo.org or DOI URLs with prefix 10.5281/zenodo)"
),
class = "move2_error_unsupported_repository_url"
)
}
rlang::exec(result, url, ...)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.