Commit 67ee529e authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Merge branch '30-manage-report' into 'master'

Resolve "manage report"

Closes #30

See merge request !23
1 merge request!23Resolve "manage report"
Pipeline #43953 failed with stages
in 1 minute and 9 seconds
Showing with 71 additions and 34 deletions
+71 -34
Package: floodam.data
Title: Collect and Process Data on Flood Damage (French Context)
Version: 0.9.32.0
Version: 0.9.33.0
Authors@R: c(
person(given = "Frédéric",
family = "Grelot",
......
......@@ -35,6 +35,7 @@ export(extract_building_agricultural)
export(extract_dwelling)
export(fmt)
export(format_scope)
export(generate_report)
export(get_archive)
export(gpkg_from_7z)
export(in_layer)
......
......@@ -10,9 +10,15 @@
#' @param archive either a list with the information to display in the report or
#' a vector of rds filenames containing compressed lists to be processed.
#' @param quiet logical, should \code{rmarkdown::render} be quiet or not.
#'
#' @param template character, either a keyword or the file name for the
#' template to be used.
#' @param purge logical, should existing template in destination be removed and,
#' so, a copy from original template in library be copied.
#'
#' @import kableExtra
#'
#' @export
#'
#' @encoding UTF-8
#' @author David Nortes Martinez
......@@ -20,9 +26,10 @@ generate_report = function(
origin,
destination = origin,
archive,
quiet = FALSE
quiet = FALSE,
template = "dwelling",
purge = FALSE
){
# Recursive call if archive is missing
if (missing(archive)) {
archive = list.files(origin, pattern = "analysed.rds$")
......@@ -33,7 +40,10 @@ generate_report = function(
archive,
generate_report,
origin = origin,
destination = destination
destination = destination,
quiet = quiet,
template = template,
purge = purge
)
)
if (length(archive) == 0)
......@@ -51,16 +61,37 @@ generate_report = function(
on.exit(rm(e))
assign("tab", tab_graphs, e)
template = switch(
template,
"dwelling" = "bd-topo_dwelling_template.rmd",
template
)
if (purge == TRUE) {
unlink(file.path(destination, template))
}
if (!file.exists(file.path(destination, template))) {
template_path = try(
system.file(
file.path("rmd", template),
package = 'floodam.data',
mustWork = TRUE
),
silent = TRUE
)
if (methods::is(template_path, "try-error")) {
message("No template found. NULL is returned.")
return(NULL)
}
file.copy(template_path, destination)
}
template = file.path(destination, template)
# creating report
rmarkdown::render(
system.file(
"rmd/bdtopo_dwelling_report_template.rmd",
package = 'floodam.data',
mustWork = TRUE
),
template,
envir = e,
output_dir = destination,
output_file = tab_graphs[["report"]][["report_name"]],
quiet = quiet
)
)
}
......@@ -12,6 +12,8 @@ if (FALSE) {
{
# system("mv ~/.Rprofile ~/.Rprofile-temp")
devtools::check(package)
# Quand data.cquest ne répond pas...
devtools::check(package, args = c("--no-examples", "--no-tests"))
# system("mv ~/.Rprofile-temp ~/.Rprofile")
}
}
......
floodam.data Version: 0.9.32.0
floodam.data Version: 0.9.33.0
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
**Note de version**
* Ajout de download_bd_topo
* remplace download.bd_topo
* téléchargement par défaut sur le site
https://geoservices.ign.fr/bdtopo
* simplification de l'appel
* Ajout de version_archive
* formatte une version d'archive pour l'IGN à partir des données sur la
version, precision, type, projection et scope pour être utilisé dans
get_archive
* Correction de adapt.eaip, adapt_ban, adapt_rpg, map_log_building
* type = "insee" dans appel de format_scope (au lieu de type = "INSEE")
* Amélioration de generate_report
* ajout de l'option quiet
* Amélioration de analyse_dwelling
* ajout de invisible au return
* Amélioration de extract_dwelling
* création de destination à la volée
* Amélioration de extract_building
* création de destination à la volée
* sauvegarde de result avant le tracé de la carte (plus robuste)
* ajout de l'option template
* ajout de l'option purge
* copie du template dans destination avant utilisation de
rmarkdown::render pour que output_dir, intermediates_dir soient par
défaut les mêmes que input. Ça évite plein d'ennuis.
* ajout de export
* Ajout de bd-topo_dwelling_template.rmd dans inst/exdata
* renommage de inst/rmd/bdtopo_dwelling_report_template.rmd pour
préparer mise en cohérence des noms
**Détails**
# git tag -a v0.9.32.0 -F dev/tag-message
# git tag -a v0.9.33.0 -F dev/tag-message
# git push --tags
......@@ -5,7 +5,14 @@
\alias{generate_report}
\title{Generate summary report of analysis}
\usage{
generate_report(origin, destination = origin, archive, quiet = FALSE)
generate_report(
origin,
destination = origin,
archive,
quiet = FALSE,
template = "dwelling",
purge = FALSE
)
}
\arguments{
\item{origin}{character, path to the directory where archive are stored.}
......@@ -17,6 +24,12 @@ saved.}
a vector of rds filenames containing compressed lists to be processed.}
\item{quiet}{logical, should \code{rmarkdown::render} be quiet or not.}
\item{template}{character, either a keyword or the file name for the
template to be used.}
\item{purge}{logical, should existing template in destination be removed and,
so, a copy from original template in library be copied.}
}
\description{
The function generates a report from a template. For the moment it only works
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment