Skip to content

Commit

Permalink
use option defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Aariq committed Mar 15, 2024
1 parent eeb93c4 commit 1b902e1
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions R/tar-terra-vect.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,16 @@ tar_terra_vect <- function(name,
tidy_eval = tidy_eval
)

# TODO: pull defaults from geotargets package options
if (is.null(filetype)) {
filetype <- "GeoJSON"
}

if (is.null(gdal)) {
gdal <- "ENCODING=UTF-8"
}

format <- ifelse(
test = filetype == "ESRI Shapefile",
#special handling of ESRI shapefiles because the output is a dir of multiple files.
yes = create_format_terra_vect_shz(options = gdal, ...),
no = create_format_terra_vect(filetype, options = gdal, ...)
)
# if not specified by user, pull the corresponding geotargets option
filetype <- filetype %||% geotargets_option_get("gdal.vector.driver")
gdal <- gdal %||% geotargets_option_get("gdal.vector.creation_options")

format <- ifelse(
test = filetype == "ESRI Shapefile",
#special handling of ESRI shapefiles because the output is a dir of multiple files.
yes = create_format_terra_vect_shz(options = gdal, ...),
no = create_format_terra_vect(filetype, options = gdal, ...)
)

targets::tar_target_raw(
name = name,
Expand Down

0 comments on commit 1b902e1

Please sign in to comment.