From d69b1a5fd50654680f253c44b16b84e05dc6c2eb Mon Sep 17 00:00:00 2001 From: Balint Komjati Date: Sun, 20 Mar 2022 20:35:37 +0100 Subject: [PATCH] Fixing Issue #49 --- R/plot_3D.R | 16 ++++++++++++---- man/plot_3D.Rd | 11 +++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/R/plot_3D.R b/R/plot_3D.R index 9bed7c5..0dd9076 100644 --- a/R/plot_3D.R +++ b/R/plot_3D.R @@ -1,7 +1,10 @@ #' Create 3D interactive elevation map from gpx tracklogs #' -#' @param tracklog_file A path to a gpx file to be read by strava::process_data. -#' If the file covers a big area plot_3D() can slow down significantly. +#' @param tracklog_folder The path to the folder of your gpx file to be read by strava::process_data(). +#' process_data() will read all gpx files from this folder and plot_3D() will plot them all. +#' It is however recommended to PLACE ONLY ONE GPX file within the folder. +#' If the tracks cover an extended area plot_3D() can slow down significantly. +#' If tracklog_folder is undefined plot_3D() loads an example tracklog provided with the package. #' @param cache_folder Directory to store the downloaded elevation data and overlay image for reuse #' @param elevation_scale Horizontal vs vertical ratio of the plot. Could be estimated with geoviz::raster_zscale(dem). #' @param elevation_scale_tracklog_corr Raises elevation_scale for the tracklog by the specified percentage. @@ -25,7 +28,7 @@ #' strava::plot_3D() #' } plot_3D <- function( - tracklog_file = "gpx/mtb", + tracklog_folder = NULL, cache_folder = "~/cache_plot_3D", elevation_scale = 6, # elevation_scale_tracklog_corr = .01, @@ -44,7 +47,12 @@ plot_3D <- function( message("Reading the tracklog") - tracklog <- strava::process_data(system.file(tracklog_file, package = "strava")) + if (is.null(tracklog_folder)) { + tracklog <- strava::process_data(system.file("gpx/mtb", package = "strava")) + } else { + tracklog <- strava::process_data(tracklog_folder) + } + if( paste0(dem_file,".gri") %>% file.exists() ) { diff --git a/man/plot_3D.Rd b/man/plot_3D.Rd index 9c3c97e..95a0b5d 100644 --- a/man/plot_3D.Rd +++ b/man/plot_3D.Rd @@ -5,7 +5,7 @@ \title{Create 3D interactive elevation map from gpx tracklogs} \usage{ plot_3D( - tracklog_file = "gpx/mtb", + tracklog_folder = NULL, cache_folder = "~/cache_plot_3D", elevation_scale = 6, elevation_scale_tracklog_corr = 0.01, @@ -19,8 +19,11 @@ plot_3D( ) } \arguments{ -\item{tracklog_file}{A path to a gpx file to be read by strava::process_data. -If the file covers a big area plot_3D() can slow down significantly.} +\item{tracklog_folder}{The path to the folder of your gpx file to be read by strava::process_data(). +process_data() will read all gpx files from this folder and plot_3D() will plot them all. +It is however recommended to PLACE ONLY ONE GPX file within the folder. +If the tracks cover an extended area plot_3D() can slow down significantly. +If tracklog_folder is undefined plot_3D() loads an example tracklog provided with the package.} \item{cache_folder}{Directory to store the downloaded elevation data and overlay image for reuse} @@ -32,7 +35,7 @@ Useful if tracklog occasionally disappears into the ground.} \item{buffer_around_tracklog_km}{Buffer distance around the tracklog in km. Scene is cut outside this.} \item{render_high_quality}{If set to TRUE the function downloads higher resolution elevation and overlay data. -And calculates ambient shadows as well. All steps are time and resource consuming.} +All steps are very time and resource consuming.} \item{sunangle}{The direction of the light source of the scene}