Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisholbrook committed Sep 4, 2024
1 parent f9486cb commit 6fa9ec3
Show file tree
Hide file tree
Showing 29 changed files with 8,144 additions and 26 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: glatos
Type: Package
Title: A package for the Great Lakes Acoustic Telemetry Observation System
Description: Functions useful to members of the Great Lakes Acoustic Telemetry Observation System https://glatos.glos.us; many more broadly relevant to simulating, processing, analysing, and visualizing acoustic telemetry data.
Version: 0.8.0.9009
Date: 2024-08-29
Version: 0.8.0.9010
Date: 2024-09-04
Depends: R (>= 3.5.0)
Imports:
av,
Expand All @@ -20,6 +20,7 @@ Imports:
sp,
zip
Suggests:
vdiffr,
gifski,
knitr,
methods,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export(detection_bubble_plot)
export(detection_events)
export(false_detections)
export(format_POSIXt)
export(get_local_vdat_schema)
export(get_local_vdat_template)
export(get_local_vdat_version)
export(get_local_vue_version)
export(glatos_animals)
Expand Down
22 changes: 14 additions & 8 deletions R/util-vdat.r
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ vdat_convert <- function(src,
show_progress = TRUE,
diagn = FALSE,
export_settings = NULL) {

## Declare global variables for NSE & R CMD check
src_dir <- src_file <- out_file <- out_file_exists <- src_to_convert <-
written <- NULL
Expand Down Expand Up @@ -601,35 +602,40 @@ get_local_vdat_version <- function(vdat_exe_path = NULL) {
}


#' Get schema from local installation of Innovsea program VDAT.exe
#' Get schema from local installation of Innovasea program VDAT.exe
#'
#' @param vdat_exe_path The full path to \code{VDAT.exe}. If \code{NULL}
#' (default) then the path to VDAT.exe must be in the PATH environment variable
#' of the system. See \code{\link{check_vdat}}.
#'
#'
#' @details A bug in vdat.exe version 9 (confirmed on v. vdat-9.3.0) will cause
#' this function to return an empty list. Fixed in vdat.exe version 10
#' (confirmed in 10.6.0).
#'
#' @returns
#' Schema (template) of VDAT CSV produced by installed version of VDAT.exe.
#' Schema (template) of VDAT CSV produced by installed version of VDAT.exe.
#'
#' @examples
#' \dontrun{
#'
#' # use if VDAT.exe in Windows system PATH variable
#' get_local_vdat_schema()
#' get_local_vdat_template()
#'
#' # or specify path to VDAT.exe
#' get_local_vdat_schema(
#' get_local_vdat_template(
#' vdat_exe_path =
#' "C:/Program Files/Innovasea/Fathom/VDAT.exe"
#' )
#' }
#'
#' @export
get_local_vdat_schema <- function(vdat_exe_path = NULL) {
get_local_vdat_template <- function(vdat_exe_path = NULL) {

# Check path to vdat.exe and get (valid) command arg for system2 call
vdat_cmd <- check_vdat(vdat_exe_path)

# Invoke VDAT.exe
vdat_call <- "--format=csv.fathom template"
vdat_call <- "template --format=csv.fathom"

vdat_schema <- system2(vdat_cmd, vdat_call, stdout = TRUE)

Expand All @@ -641,6 +647,6 @@ get_local_vdat_schema <- function(vdat_exe_path = NULL) {

# Drop RECORD TYPE element
vdat_schema_list["RECORD TYPE"] <- NULL

return(vdat_schema_list)
}
28 changes: 23 additions & 5 deletions R/vis-kml_workbook.r
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,17 @@
#'
#' @export
kml_workbook <- function(
wb = NULL, wb_file = NULL, receiver_locs = NULL,
animals = NULL, kmz = FALSE, show_ongoing_recs = TRUE, end_date = NULL,
out_file = NULL, wb_version = NULL, ...) {
wb = NULL,
wb_file = NULL,
receiver_locs = NULL,
animals = NULL,
kmz = FALSE,
show_ongoing_recs = TRUE,
end_date = NULL,
out_file = NULL,
wb_version = NULL,
...) {

# check for features not yet supported
if (!is.null(animals)) stop("use of 'animals' input not yet supported.")
if (!is.null(receiver_locs)) stop("use of 'receiver_locs' input not yet supported.")
Expand Down Expand Up @@ -120,7 +128,7 @@ kml_workbook <- function(

# set default and get optional kml arguments
kml_args <- list(labelSize = 0.6, iconSize = 0.6)
args_in <- list(...)
args_in <- if(interactive()) list() else list(...)
if (length(args_in) > 0) kml_args[names(args_in)] <- args_in

# get data from workbook
Expand Down Expand Up @@ -397,12 +405,22 @@ kml_workbook <- function(
file.path(dirname(wb_file), kmlName)
)

# change ext to kml if kmz
if(kmz & grepl("\\.kmz$", kmlFullName, ignore.case = TRUE)){
kmzFullName <- kmlFullName
kmlFullName <- gsub("z$", "l", kmlFullName)
kmlFullName <- gsub("Z$", "L", kmlFullName)
}

write.table(kmlOut, kmlFullName,
col.names = FALSE, row.names = FALSE,
quote = FALSE
)

if (kmz) zip(gsub(".kml$", ".kmz", kmlFullName), files = kmlFullName)
if (kmz) {
utils::zip(kmzFullName, files = kmlFullName, flags = "-q")
return(kmzFullName)
}

return(kmlFullName)
}
19 changes: 12 additions & 7 deletions man/get_local_vdat_schema.Rd → man/get_local_vdat_template.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6fa9ec3

Please sign in to comment.