Skip to content

Commit

Permalink
fix minor problems with initProj
Browse files Browse the repository at this point in the history
  • Loading branch information
gisma committed Jun 14, 2024
1 parent f4b4df6 commit 2ad90db
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ articles:
link2GI4: link2GI4.html
link2GI5: link2GI5.html
link2GI6: link2GI6.html
last_built: 2024-06-14T05:36Z
last_built: 2024-06-14T06:58Z
urls:
reference: https://r-spatial.github.io/link2GI/reference
article: https://r-spatial.github.io/link2GI/articles
Expand Down
22 changes: 9 additions & 13 deletions inst/templates/advancedSpatial.brew
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,24 @@

<% } %>

# append additional packages if defined by calling script
if (exists("appendlibs") && appendlibs[[1]] != "")
{
libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>)
} else {
libs = <%=deparse(libs)%>
}


# Now create/read root direcory, folder structure and load packages
# create/read root direcory, folder structure and load packages
# NOTE root_folder MUST be defined in calling script
if (!exists("root_folder")) {
stop("variable root_folder is NOT defined, You must define a root folder!")
}

# call central function
# append additional paths if defined by calling script
dirs = append(<%=deparse(dirs)%>,appendpaths)


# append additional packages if defined by calling script
libs = append(<%=deparse(libs)%>,appendlibs)

# call central function
dirs = link2GI::setupProj(root_folder = root_folder,
folders = <%=deparse(dirs)%>,
folders = dirs,
fcts_folder = <%=deparse(code_subfolder)%>)


# Define more variables

# Load more data
20 changes: 8 additions & 12 deletions inst/templates/base.brew
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,22 @@

<% } %>

# append additional packages if defined by calling script
if (exists("appendlibs") && appendlibs[[1]] != "")
{
libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>)
} else {
libs = <%=deparse(libs)%>
}


# Now create/read root direcory, folder structure and load packages
# create/read root direcory, folder structure and load packages
# NOTE root_folder MUST be defined in calling script
if (!exists("root_folder")) {
stop("variable root_folder is NOT defined, You must define a root folder!")
}

# append additional paths if defined by calling script
dirs = append(<%=deparse(dirs)%>,appendpaths)


# append additional packages if defined by calling script
libs = append(<%=deparse(libs)%>,appendlibs)

# call central function
# call central function
dirs = link2GI::setupProj(root_folder = root_folder,
folders = <%=deparse(dirs)%>,
folders = dirs,
fcts_folder = <%=deparse(code_subfolder)%>)


Expand Down
21 changes: 7 additions & 14 deletions inst/templates/baseSpatial.brew
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,22 @@
# This script is sourced when you run the main control script. Use variable dirs to access project directories.



# append additional packages if defined by calling script

# append additional packages if defined by calling script
if (exists("appendlibs") && appendlibs[[1]] != "")
{
libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>)
} else {
libs = <%=deparse(libs)%>
}


# Now create/read root direcory, folder structure and load packages
# create/read root direcory, folder structure and load packages
# NOTE root_folder MUST be defined in calling script
if (!exists("root_folder")) {
stop("variable root_folder is NOT defined, You must define a root folder!")
}

# append additional paths if defined by calling script
dirs = append(<%=deparse(dirs)%>,appendpaths)


# append additional packages if defined by calling script
libs = append(<%=deparse(libs)%>,appendlibs)

# call central function
dirs = link2GI::setupProj(root_folder = root_folder,
folders = <%=deparse(dirs)%>,
folders = dirs,
fcts_folder = <%=deparse(code_subfolder)%>)

# Define more variables
Expand Down
4 changes: 2 additions & 2 deletions inst/templates/config-default-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ baseSpatial:
init_git: true
init_renv: true
global: false
libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview", "dplyr"]
libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview", "dplyr", "CAST", "link2GI"]
create_folders: true
files: [ "src/pre-processing.R", "src/post-processing.R", "src/processing.R", "src/functions/000_setup.R" ,"src/main-control.R"]
advancedSpatial:
Expand All @@ -28,7 +28,7 @@ advancedSpatial:
init_git: true
init_renv: true
global: false
libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview" ,"dplyr", "caret" ,"randomforest"]
libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview" ,"dplyr", "caret" ,"randomforest", "CAST", "link2GI"]
create_folders: true
files: [ "src/pre-processing.R", "src/post-processing.R", "src/processing.R", "src/functions/000_setup.R" ,"src/main-control.R"]

Expand Down
7 changes: 6 additions & 1 deletion inst/templates/script_control.brew
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ require(yaml)
root_folder <- find_rstudio_root_file()

# Read master configuration
config_master <- read_yaml(file = file.path(root_folder, "src/configs/config-master.yml"))
config_master = read_yaml(file = file.path(root_folder, "src/configs/config-master.yml"))
# additional packages to load
appendlibs = ""
# additional paths to init
appendpaths = ""

# setup the environment
source(file.path(root_folder, "src/functions/000_setup.R"))


Expand Down
29 changes: 18 additions & 11 deletions inst/templates/script_setup.brew
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@
<% } %>
require(link2GI)

# Define libraries

# Load libraries and create environment object to be used in other scripts for path navigation
project_folders <- list.dirs(path = root_folder, full.names = FALSE, recursive = TRUE)
project_folders <- project_folders[!grepl("\\..", project_folders)]
dirs <- setupProj(
root_folder = root_folder,
fcts_folder = file.path(root_folder, "src/functions/"),
folders = project_folders,
libs = libs,
create_folders = FALSE)
# create/read root direcory, folder structure and load packages
# NOTE root_folder MUST be defined in calling script
if (!exists("root_folder")) {
stop("variable root_folder is NOT defined, You must define a root folder!")
}

# append additional paths if defined by calling script
dirs = append(<%=deparse(dirs)%>,appendpaths)


# append additional packages if defined by calling script
libs = append(<%=deparse(libs)%>,appendlibs)

# call central function
dirs = link2GI::setupProj(root_folder = root_folder,
folders = folders>,
fcts_folder = <%=deparse(code_subfolder)%>)



# Define more variables
Expand Down

0 comments on commit 2ad90db

Please sign in to comment.