From 9824019b4951cb63c6dac02241ea4aebc38fbcf1 Mon Sep 17 00:00:00 2001 From: Michael Hodge Date: Mon, 3 Jun 2019 14:27:11 +0100 Subject: [PATCH] aes --- propeR/R/isochrone-multi.R | 67 ++++++++++++++---------- propeR/R/isochrone-time.R | 68 ++++++++++++++----------- propeR/R/isochrone.R | 58 +++++++++++---------- propeR/R/point-to-point-loop.R | 63 ++++++++++++++--------- propeR/R/point-to-point-nearest.R | 46 ++++++++++------- propeR/R/point-to-point-time.R | 85 +++++++++++++++++++++---------- propeR/R/point-to-point.R | 63 ++++++++++++++++------- 7 files changed, 280 insertions(+), 170 deletions(-) diff --git a/propeR/R/isochrone-multi.R b/propeR/R/isochrone-multi.R index d778879..0ea9674 100755 --- a/propeR/R/isochrone-multi.R +++ b/propeR/R/isochrone-multi.R @@ -24,6 +24,7 @@ ##' @param isochroneCutOffMax Provide the maximum cutoff time for the isochrone, defaults 90 ##' @param isochroneCutOffMin Provide the minimum cutoff time for the isochrone, defaults 10 ##' @param isochroneCutOffStep Provide the cutoff time step for the isochrone, 0 denotes no step is required (returns isochroneCutOffMax only), defaults 10 +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @param mapOutput Specifies whether you want to output a map, defaults to FALSE ##' @param geojsonOutput Specifies whether you want to output a GeoJSON file, defaults to FALSE ##' @param mapZoom The zoom level of the map as an integer (e.g. 12), defaults to bounding box approach @@ -38,8 +39,8 @@ ##' @param destinationMarkerStroke Specifies whether a destination marker(s) stroke is used (default is T) ##' @param destinationMarkerStrokeColor Specifies the stroke color for the destination marker(s) (default is 'black') ##' @param destinationMarkerStrokeWeight Specifies the marker stroke weight for the destination marker(s) (default is 1) -##' @param destinationMarkerColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is '#00FFAE') -##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 0.5 +##' @param destinationMarkerColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is 'white') +##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 1 ##' @param mapDarkMode Specifies if you want to use the dark leaflet map colour (default is FALSE) ##' @param failSafeSave Specify the failsafe save number for large datasets, default is 100 ##' @return Saves journey details as CSV to output directory (optional: a map in PNG and HTML formats, the polygons as a GeoJSON) @@ -73,6 +74,7 @@ isochroneMulti <- function(output.dir, isochroneCutOffMax = 90, isochroneCutOffMin = 10, isochroneCutOffStep = 10, + infoPrint = T, # output args mapOutput = F, geojsonOutput = F, @@ -90,8 +92,8 @@ isochroneMulti <- function(output.dir, destinationMarkerStroke = T, destinationMarkerStrokeColor = 'black', destinationMarkerStrokeWeight = 1, - destinationMarkerColor = '#00FFAE', - mapLegendOpacity = 0.5, + destinationMarkerColor = 'white', + mapLegendOpacity = 1, mapDarkMode = F) { ######################### @@ -121,11 +123,7 @@ isochroneMulti <- function(output.dir, isochroneCutOffs <- seq(isochroneCutOffMin, isochroneCutOffMax, isochroneCutOffStep) } - if (mapDarkMode == T){ - mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") - } else { - mapPolygonColours <- c("#192448", "#1F2B58", "#243368", "#293B78", "#2E4288", "#334A98", "#3851A8", "#3D58B9", "#4863C3") - } + mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") if (mapOutput == T) { library(leaflet) @@ -143,13 +141,15 @@ isochroneMulti <- function(output.dir, warning_list <- c() - cat("Now running the propeR isochrone tool.\n") - cat("Parameters chosen:\n") - cat("Date and Time: ", startDateAndTime, "\n", sep = "") - cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") - cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") - cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") - cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep = "") + if (infoPrint == T) { + cat("Now running the propeR isochrone tool.\n") + cat("Parameters chosen:\n") + cat("Date and Time: ", startDateAndTime, "\n", sep = "") + cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") + cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") + cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") + cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep = "") + } ########################### #### CALL OTP FUNCTION #### @@ -162,11 +162,15 @@ isochroneMulti <- function(output.dir, time.taken <- vector() originPoints_removed <- c() originPoints_removed_list <- c() - message("Creating ", num.total, " isochrones, please wait...") + if (infoPrint == T) { + message("Creating ", num.total, " isochrones, please wait...") + } - pb <- progress_bar$new( - format = " Isochrone calculation complete for call :what [:bar] :percent eta: :eta", - total = num.total, clear = FALSE, width= 100) + if (infoPrint == T) { + pb <- progress::progress_bar$new( + format = " Isochrone calculation complete for call :what [:bar] :percent eta: :eta", + total = num.total, clear = FALSE, width= 100) + } for (i in num.start:num.end) { num.run <- num.run + 1 @@ -303,7 +307,9 @@ isochroneMulti <- function(output.dir, isochrone_polygons@plotOrder <- tmp_seq - pb$tick(tokens = list(what = num.run)) + if (infoPrint == T) { + pb$tick(tokens = list(what = num.run)) + } if ((num.run/failSafeSave) %% 1 == 0) { # fail safe for large files is.na(time_df) <- sapply(time_df, is.infinite) @@ -359,7 +365,7 @@ isochroneMulti <- function(output.dir, m <- addScaleBar(m) if (mapDarkMode != T) { - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + m <- addProviderTiles(m, providers$CartoDB.Positron) } else { m <- addProviderTiles(m, providers$CartoDB.DarkMatter) } @@ -427,13 +433,16 @@ isochroneMulti <- function(output.dir, ###################### #### SAVE RESULTS #### ###################### - - cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") - cat("Journey details:\n", sep = "") - cat("Isochrones generated: ", num.total-length(originPoints_removed_list),"/",num.total,"\n", sep = "") is.na(time_df) <- sapply(time_df, is.infinite) - + + if (infoPrint == T) { + cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") + cat("Journey details:\n", sep = "") + cat("Isochrones generated: ", num.total-length(originPoints_removed_list),"/",num.total,"\n", sep = "") + cat("Destinations possible: ", ncol(time_df) - sum(colSums(is.na(time_df)) == nrow(time_df)),"/",ncol(time_df),"\n", sep = "") + } + write.csv( time_df, file = paste0(output.dir, "/isochroneMulti-", file_name, "/csv/isochroneMulti-isochrone_multi_inc-", file_name, ".csv"), @@ -468,5 +477,7 @@ isochroneMulti <- function(output.dir, unlink(paste0(output.dir, "/isochroneMulti-", file_name, "/map/isochroneMulti-", file_name, "_files"), recursive = T) } - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T) { + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/isochrone-time.R b/propeR/R/isochrone-time.R index eda8e8d..5c56ced 100755 --- a/propeR/R/isochrone-time.R +++ b/propeR/R/isochrone-time.R @@ -27,6 +27,7 @@ ##' @param isochroneCutOffMax Provide the maximum cutoff time for the isochrone, defaults 90 ##' @param isochroneCutOffMin Provide the minimum cutoff time for the isochrone, defaults 10 ##' @param isochroneCutOffStep Provide the cutoff time step for the isochrone, defaults 10 +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @param gifOutput Specifies whether you want to output a gif, defaults to FALSE ##' @param mapOutput Specifies whether you want to output the maps, defaults to FALSE ##' @param geojsonOutput Specifies whether you want to output a GeoJSON file, defaults to FALSE @@ -44,9 +45,9 @@ ##' @param destinationMarkerStroke Specifies whether a destination marker(s) stroke is used (default is T) ##' @param destinationMarkerStrokeColor Specifies the stroke color for the destination marker(s) (default is 'black') ##' @param destinationMarkerStrokeWeight Specifies the marker stroke weight for the destination marker(s) (default is 1) -##' @param destinationMarkerInColor Specifies the colour of destination marker(s)if it is within a isochrone (default is '#00FFAE') -##' @param destinationMarkerOutColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is '#FF00E0') -##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 0.5 +##' @param destinationMarkerInColor Specifies the colour of destination marker(s)if it is within a isochrone (default is 'white') +##' @param destinationMarkerOutColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is 'grey') +##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 1 ##' @param mapDarkMode Specifies if you want to use the dark leaflet map colour (default is FALSE) ##' @return Saves journey details as comma separated value file to output directory. An animated map in .gif format may also be saved. ##' @author Michael Hodge @@ -84,6 +85,7 @@ isochroneTime <- function(output.dir, isochroneCutOffMax = 90, isochroneCutOffMin = 10, isochroneCutOffStep = 10, + infoPrint = T, # leaflet map args gifOutput = F, mapOutput = F, @@ -102,9 +104,9 @@ isochroneTime <- function(output.dir, destinationMarkerStroke = T, destinationMarkerStrokeColor = 'black', destinationMarkerStrokeWeight = 1, - destinationMarkerInColor = '#00FFAE', - destinationMarkerOutColor = '#FF00E0', - mapLegendOpacity = 0.5, + destinationMarkerInColor = 'white', + destinationMarkerOutColor = 'grey', + mapLegendOpacity = 1, mapDarkMode = F) { ######################### @@ -141,11 +143,7 @@ isochroneTime <- function(output.dir, isochroneCutOffs <- seq(isochroneCutOffMin, isochroneCutOffMax, isochroneCutOffStep) } - if (mapDarkMode == T){ - mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") - } else { - mapPolygonColours <- c("#192448", "#1F2B58", "#243368", "#293B78", "#2E4288", "#334A98", "#3851A8", "#3D58B9", "#4863C3") - } + mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") if (gifOutput == T || mapOutput == T) { library(leaflet) @@ -167,15 +165,17 @@ isochroneTime <- function(output.dir, warning_list <- c() - cat("Now running the propeR pointToPointTime tool.\n", sep="") - cat("Parameters chosen:\n", sep="") - cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") - cat("Date and Time: ", startDateAndTime, " (start) to ", endDateAndTime, " (end)\n", sep="") - cat("Intervals (mins): ", timeIncrease, "\n", sep="") - cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") - cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") - cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") - cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "] GIF [", gifOutput, "]\n\n", sep="") + if (infoPrint == T) { + cat("Now running the propeR pointToPointTime tool.\n", sep="") + cat("Parameters chosen:\n", sep="") + cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") + cat("Date and Time: ", startDateAndTime, " (start) to ", endDateAndTime, " (end)\n", sep="") + cat("Intervals (mins): ", timeIncrease, "\n", sep="") + cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") + cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") + cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") + cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "] GIF [", gifOutput, "]\n\n", sep="") + } ########################### #### CALL OTP FUNCTION #### @@ -186,11 +186,15 @@ isochroneTime <- function(output.dir, num.run <- 0 num.total <- num.end time.taken <- vector() - cat("Creating ", num.total, " isochrone connections, please wait...\n", sep="") + if (infoPrint == T) { + cat("Creating ", num.total, " isochrone connections, please wait...\n", sep="") + } - pb <- progress_bar$new( - format = " Isochrone calculation complete for time :what [:bar] :percent eta: :eta", - total = num.total, clear = FALSE, width= 100) + if (infoPrint == T) { + pb <- progress::progress_bar$new( + format = " Isochrone calculation complete for time :what [:bar] :percent eta: :eta", + total = num.total, clear = FALSE, width= 100) + } for (i in num.start:num.total) { num.run <- num.run + 1 @@ -273,7 +277,7 @@ isochroneTime <- function(output.dir, m <- addScaleBar(m) if (mapDarkMode != T) { - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + m <- addProviderTiles(m, providers$CartoDB.Positron) } else { m <- addProviderTiles(m, providers$CartoDB.DarkMatter) } @@ -372,7 +376,9 @@ isochroneTime <- function(output.dir, driver = "GeoJSON") } - pb$tick(tokens = list(what = time)) + if (infoPrint == T) { + pb$tick(tokens = list(what = time)) + } } @@ -380,7 +386,9 @@ isochroneTime <- function(output.dir, #### SAVE RESULTS #### ###################### - cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") + if (infoPrint == T) { + cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") + } write.csv( destination_points_output, @@ -408,10 +416,12 @@ isochroneTime <- function(output.dir, m <- magick::image_read(paste0(output.dir, "/isochroneTime-", file_name, "/gif/", "/isochroneTime-gif-", file_name, ".gif")) %>% - magick::image_scale("600") # Loads GIF into R + magick::image_scale("800") # Loads GIF into R invisible(print(m)) # plots map to Viewer } - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T) { + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/isochrone.R b/propeR/R/isochrone.R index 71906c0..c89265e 100755 --- a/propeR/R/isochrone.R +++ b/propeR/R/isochrone.R @@ -24,6 +24,7 @@ ##' @param isochroneCutOffMax Provide the maximum cutoff time for the isochrone, defaults 90 ##' @param isochroneCutOffMin Provide the minimum cutoff time for the isochrone, defaults 10 ##' @param isochroneCutOffStep Provide the cutoff time step for the isochrone, 0 denotes no step is required (returns isochroneCutOffMax only), defaults 10 +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @param mapOutput Specifies whether you want to output a map, defaults to FALSE ##' @param geojsonOutput Specifies whether you want to output a GeoJSON file, defaults to FALSE ##' @param mapZoom The zoom level of the map as an integer (e.g. 12), defaults to bounding box approach @@ -39,9 +40,9 @@ ##' @param destinationMarkerStroke Specifies whether a destination marker(s) stroke is used (default is T) ##' @param destinationMarkerStrokeColor Specifies the stroke color for the destination marker(s) (default is 'black') ##' @param destinationMarkerStrokeWeight Specifies the marker stroke weight for the destination marker(s) (default is 1) -##' @param destinationMarkerInColor Specifies the colour of destination marker(s)if it is within a isochrone (default is '#00FFAE') -##' @param destinationMarkerOutColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is '#FF00E0') -##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 0.5 +##' @param destinationMarkerInColor Specifies the colour of destination marker(s)if it is within a isochrone (default is 'white') +##' @param destinationMarkerOutColor Specifies the colour of destination marker(s) if it is not within a isochrone (default is 'grey') +##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 1 ##' @param mapDarkMode Specifies if you want to use the dark leaflet map colour (default is FALSE) ##' @return Saves journey details as comma separated value file to output directory. A map in .png and .html formats, and/or a polygon as a .GeoJSON format, may also be saved ##' @author Michael Hodge @@ -75,6 +76,7 @@ isochrone <- function(output.dir, isochroneCutOffMax = 90, isochroneCutOffMin = 10, isochroneCutOffStep = 10, + infoPrint = T, # leaflet map args mapOutput = F, geojsonOutput = F, @@ -91,9 +93,9 @@ isochrone <- function(output.dir, destinationMarkerStroke = T, destinationMarkerStrokeColor = 'black', destinationMarkerStrokeWeight = 1, - destinationMarkerInColor = '#00FFAE', - destinationMarkerOutColor = '#FF00E0', - mapLegendOpacity = 0.5, + destinationMarkerInColor = 'white', + destinationMarkerOutColor = 'grey', + mapLegendOpacity = 1, mapDarkMode = F) { ######################### @@ -128,12 +130,8 @@ isochrone <- function(output.dir, isochroneCutOffs <- seq(isochroneCutOffMin, isochroneCutOffMax, isochroneCutOffStep) } - if (mapDarkMode == T){ - mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") - } else { - mapPolygonColours <- c("#192448", "#1F2B58", "#243368", "#293B78", "#2E4288", "#334A98", "#3851A8", "#3D58B9", "#4863C3") - } - + mapPolygonColours <- c("#4365BC", "#5776C4", "#6C87CC", "#8098D4", "#95A9DB", "#AABAE3", "#BFCBEA", "#D4DCF1", "#E9EEF8") + if (mapOutput == T) { library(leaflet) pal_time_date = leaflet::colorFactor(c("#FFFFFF"), domain = NULL) @@ -150,14 +148,16 @@ isochrone <- function(output.dir, warning_list <- c() - cat("Now running the propeR isochrone tool.\n") - cat("Parameters chosen:\n") - cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep = "") - cat("Date and Time: ", startDateAndTime, "\n", sep = "") - cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") - cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") - cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") - cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep = "") + if (infoPrint == T) { + cat("Now running the propeR isochrone tool.\n") + cat("Parameters chosen:\n") + cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep = "") + cat("Date and Time: ", startDateAndTime, "\n", sep = "") + cat("Min Duration (mins): ", isochroneCutOffMin, "\n", sep = "") + cat("Max Duration (mins): ", isochroneCutOffMax, "\n", sep = "") + cat("Isochrone Step (mins): ", isochroneCutOffStep, "\n", sep = "") + cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep = "") + } ########################### #### CALL OTP FUNCTION #### @@ -226,7 +226,7 @@ isochrone <- function(output.dir, m <- addScaleBar(m) if (mapDarkMode != T) { - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + m <- addProviderTiles(m, providers$CartoDB.Positron) } else { m <- addProviderTiles(m, providers$CartoDB.DarkMatter) } @@ -321,11 +321,13 @@ isochrone <- function(output.dir, #### SAVE RESULTS #### ###################### - cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") - cat("Journey details:\n", sep = "") - cat("Destinations possible: ", nrow(destinationPoints[!is.na(destinationPoints$travel_time),]),"/",nrow(destinationPoints),"\n", sep = "") - cat("Mean Duration (mins): ", round(mean(destinationPoints$travel_time, na.rm=TRUE),2), " [+/-", round(sd(destinationPoints$travel_time, na.rm=TRUE),2), "]\n", sep = "") - + if (infoPrint == T) { + cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") + cat("Journey details:\n", sep = "") + cat("Destinations possible: ", nrow(destinationPoints[!is.na(destinationPoints$travel_time),]),"/",nrow(destinationPoints),"\n", sep = "") + cat("Mean Duration (mins): ", round(mean(destinationPoints$travel_time, na.rm=TRUE),2), " [+/-", round(sd(destinationPoints$travel_time, na.rm=TRUE),2), "]\n", sep = "") + } + write.csv( destinationPoints, file = paste0(output.dir, "/isochrone-", file_name, "/csv/isochrone-", file_name, ".csv"), @@ -361,5 +363,7 @@ isochrone <- function(output.dir, driver = "GeoJSON") } - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T) { + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/point-to-point-loop.R b/propeR/R/point-to-point-loop.R index 07fa6c1..11f2550 100755 --- a/propeR/R/point-to-point-loop.R +++ b/propeR/R/point-to-point-loop.R @@ -27,6 +27,8 @@ ##' @param busTicketPriceMax Specifiy the maximum cost of a bus journey (default is 12 GPB) ##' @param trainTicketPriceKm Specifiy the cost of a train journey per km (default is 0.12 GPB per km) ##' @param trainTicketPriceMin Specifiy the minimum cost of a train journey (default is 3 GBP) +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE +##' @param failSafeSave Specify the failsafe save number for large datasets, default is 100 ##' @return Saves journey details as comma separated value file to output directory ##' @author Michael Hodge ##' @examples @@ -66,7 +68,9 @@ pointToPointLoop <- function(output.dir, busTicketPrice = 3, busTicketPriceMax = 12, trainTicketPriceKm = 0.12, - trainTicketPriceMin = 3) { + trainTicketPriceMin = 3, + infoPrint = T, + failSafeSave = 100) { ######################### #### SETUP VARIABLES #### @@ -110,19 +114,21 @@ pointToPointLoop <- function(output.dir, dir.create(paste0(output.dir, "/pointToPointLoop-", file_name)) dir.create(paste0(output.dir, "/pointToPointLoop-", file_name, "/csv")) - cat("Now running the propeR pointToPointLoop tool.\n", sep="") - cat("Parameters chosen:\n", sep="") - if (journeyLoop == 0) { - cat("Loop Type: Origin and destination (", num.total, " calls)\n", sep="") - } else if (journeyLoop == 1) { - cat("Loop Type: Origin only (", num.total, " calls)\n", sep="") - } else if (journeyLoop == 2) { - cat("Loop Type: Destination only (", num.total, " calls)\n", sep="") - } else if (journeyLoop == 3) { - cat("Loop Type: Origin and Destination are fixed (", num.total, " calls)\n", sep="") + if (infoPrint == T) { + cat("Now running the propeR pointToPointLoop tool.\n", sep="") + cat("Parameters chosen:\n", sep="") + if (journeyLoop == 0) { + cat("Loop Type: Origin and destination (", num.total, " calls)\n", sep="") + } else if (journeyLoop == 1) { + cat("Loop Type: Origin only (", num.total, " calls)\n", sep="") + } else if (journeyLoop == 2) { + cat("Loop Type: Destination only (", num.total, " calls)\n", sep="") + } else if (journeyLoop == 3) { + cat("Loop Type: Origin and Destination are fixed (", num.total, " calls)\n", sep="") + } + cat("Return Journey: ", journeyReturn, "\n", sep="") + cat("Date and Time: ", startDateAndTime, "\n", sep="") } - cat("Return Journey: ", journeyReturn, "\n", sep="") - cat("Date and Time: ", startDateAndTime, "\n", sep="") ########################### #### CALL OTP FUNCTION #### @@ -133,7 +139,9 @@ pointToPointLoop <- function(output.dir, start_date <- as.Date(startDateAndTime) time.taken <- vector() calls.list <- c(0) - cat("Creating ", num.total, " point to point connections, please wait...\n") + if (infoPrint == T) { + cat("Creating ", num.total, " point to point connections, please wait...\n") + } make_blank_df <- function(from, to, time_twenty_four) { df <- data.frame( @@ -155,9 +163,11 @@ pointToPointLoop <- function(output.dir, df } - pb <- progress_bar$new( - format = " Travel time calculation complete for call :what [:bar] :percent eta: :eta", - total = num.total, clear = FALSE, width= 100) + if (infoPrint == T) { + pb <- progress::progress_bar$new( + format = " Travel time calculation complete for call :what [:bar] :percent eta: :eta", + total = num.total, clear = FALSE, width= 100) + } for (j in 1:multiplier) { @@ -306,9 +316,12 @@ pointToPointLoop <- function(output.dir, point_to_point_table_overview <- rbind(point_to_point_table_overview, point_to_point_table_overview_tmp) } } - pb$tick(tokens = list(what = num.run)) - if ((num.run/100) %% 1 == 0) { # fail safe for large files + if (infoPrint == T) { + pb$tick(tokens = list(what = num.run)) + } + + if ((num.run/failSafeSave) %% 1 == 0) { # fail safe for large files point_to_point_table_overview_out <- point_to_point_table_overview @@ -329,9 +342,11 @@ pointToPointLoop <- function(output.dir, } } - cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") - cat("Journey details:\n", sep = "") - cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") + if (infoPrint == T) { + cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") + cat("Journey details:\n", sep = "") + cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") + } if (modes == "CAR") { colnames(point_to_point_table_overview)[which(names(point_to_point_table_overview) == "walk_time_mins")] <- "drive_time_mins" @@ -344,5 +359,7 @@ pointToPointLoop <- function(output.dir, file = paste0(output.dir, "/pointToPointLoop-", file_name, "/csv/pointToPointLoop-", file_name, ".csv"), row.names = F) - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T) { + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/point-to-point-nearest.R b/propeR/R/point-to-point-nearest.R index 9d95f8e..fc368ac 100644 --- a/propeR/R/point-to-point-nearest.R +++ b/propeR/R/point-to-point-nearest.R @@ -25,6 +25,7 @@ ##' @param busTicketPriceMax Specifiy the maximum cost of a bus journey (default is 12 GPB) ##' @param trainTicketPriceKm Specifiy the cost of a train journey per km (default is 0.12 GPB per km) ##' @param trainTicketPriceMin Specifiy the minimum cost of a train journey (default is 3 GBP) +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @author Michael Hodge ##' @examples ##' pointToPointNearest( @@ -59,7 +60,8 @@ pointToPointNearest <- function(output.dir, busTicketPrice = 3, busTicketPriceMax = 12, trainTicketPriceKm = 0.12, - trainTicketPriceMin = 3) { + trainTicketPriceMin = 3, + infoPrint = T) { ######################### #### SETUP VARIABLES #### @@ -83,11 +85,13 @@ pointToPointNearest <- function(output.dir, dir.create(paste0(output.dir, "/pointToPointNearest-", file_name)) dir.create(paste0(output.dir, "/pointToPointNearest-", file_name, "/csv")) - cat("Now running the propeR pointToPointNearest tool.\n", sep="") - cat("Parameters chosen:\n", sep="") - cat("KNN nearest number: ", nearestNum, " (", num.total, " calls)\n", sep="") - cat("Return Journey: ", journeyReturn, "\n", sep="") - cat("Date and Time: ", startDateAndTime, "\n", sep="") + if (infoPrint == T) { + cat("Now running the propeR pointToPointNearest tool.\n", sep="") + cat("Parameters chosen:\n", sep="") + cat("KNN nearest number: ", nearestNum, " (", num.total, " calls)\n", sep="") + cat("Return Journey: ", journeyReturn, "\n", sep="") + cat("Date and Time: ", startDateAndTime, "\n", sep="") + } ########################### #### CALL OTP FUNCTION #### @@ -99,7 +103,9 @@ pointToPointNearest <- function(output.dir, start_date <- as.Date(startDateAndTime) time.taken <- vector() calls.list <- c(0) - cat("Creating ", num.total, " point to point connections, please wait...\n") + if (infoPrint == T) { + cat("Creating ", num.total, " point to point connections, please wait...\n") + } make_blank_df <- function(from_origin, to_destination, time_twenty_four) { df <- data.frame( @@ -121,9 +127,11 @@ pointToPointNearest <- function(output.dir, df } - pb <- progress_bar$new( - format = " Travel time calculation complete for call :what [:bar] :percent eta: :eta", - total = num.total, clear = FALSE, width= 100) + if (infoPrint == T) { + pb <- progress::progress_bar$new( + format = " Travel time calculation complete for call :what [:bar] :percent eta: :eta", + total = num.total, clear = FALSE, width= 100) + } for (j in 1:multiplier) { @@ -263,8 +271,9 @@ pointToPointNearest <- function(output.dir, point_to_point_table_overview <- rbind(point_to_point_table_overview, point_to_point_table_overview_tmp) } } - - pb$tick(tokens = list(what = num.run)) + if (infoPrint == T) { + pb$tick(tokens = list(what = num.run)) + } if ((num.run/100) %% 1 == 0) { # fail safe for large files @@ -286,9 +295,11 @@ pointToPointNearest <- function(output.dir, } } - cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") - cat("Journey details:\n", sep = "") - cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") + if (infoPrint == T) { + cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") + cat("Journey details:\n", sep = "") + cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") + } if (modes == "CAR") { colnames(point_to_point_table_overview)[which(names(point_to_point_table_overview) == "walk_time_mins")] <- "drive_time_mins" @@ -300,6 +311,7 @@ pointToPointNearest <- function(output.dir, point_to_point_table_overview, file = paste0(output.dir, "/pointToPointNearest-", file_name, "/csv/pointToPointNearest-", file_name, ".csv"), row.names = F) - - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T) { + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/point-to-point-time.R b/propeR/R/point-to-point-time.R index 1bcf312..df642a1 100755 --- a/propeR/R/point-to-point-time.R +++ b/propeR/R/point-to-point-time.R @@ -29,6 +29,7 @@ ##' @param busTicketPriceMax Specifiy the maximum cost of a bus journey (default is 12 GPB) ##' @param trainTicketPriceKm Specifiy the cost of a train journey per km (default is 0.12 GPB per km) ##' @param trainTicketPriceMin Specifiy the minimum cost of a train journey (default is 3 GBP) +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @param mapOutput Specifies whether you want to output a map, defaults to FALSE ##' @param gifOutput Specifies whether you want to output an animated gif map, defaults to FALSE ##' @param geojsonOutput Specifies whether you want to output the polylines as a geojson, defaults to FALSE @@ -36,8 +37,11 @@ ##' @param mapZoom The zoom level of the map as an integer (e.g. 12), defaults to bounding box approach ##' @param mapPolylineWeight Specifies the weight of the polyline, defaults to 5 px ##' @param mapPolylineOpacity Specifies the opacity of the polyline, defaults to 1 (solid) +##' @param mapMarkerStrokeColor Specifies the outline color of the marker, defaults to black +##' @param mapMarkerStrokeWeight Specifies the stroke weight of the marker, defaults to 1 (solid) ##' @param mapMarkerOpacity Specifies the opacity of the marker, defaults to 1 (solid) ##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 1 (solid) +##' @param mapDarkMode Specifies if you want to use the dark leaflet map colour (default is FALSE) ##' @return Saves journey details as comma separated value file to output directory. An animated map in .gif format may also be saved. ##' @author Michael Hodge ##' @examples @@ -76,6 +80,7 @@ pointToPointTime <- function(output.dir, busTicketPriceMax = 12, trainTicketPriceKm = 0.12, trainTicketPriceMin = 3, + infoPrint = T, # leaflet map args mapOutput = F, gifOutput = F, @@ -91,8 +96,11 @@ pointToPointTime <- function(output.dir, mapZoom = "bb", mapPolylineWeight = 5, mapPolylineOpacity = 1, + mapMarkerStrokeColor = 'black', + mapMarkerStrokeWeight = 1, mapMarkerOpacity = 1, - mapLegendOpacity = 1) { + mapLegendOpacity = 1, + mapDarkMode = F) { ######################### #### SETUP VARIABLES #### @@ -126,6 +134,9 @@ pointToPointTime <- function(output.dir, levels = as.factor(names(mapPolylineColours)), reverse = F) pal_time_date = leaflet::colorFactor(c("#FFFFFF"), domain = NULL) + if (mapDarkMode == T){ + mapMarkerStrokeColor = 'white' + } } if (mapOutput == T){ @@ -140,14 +151,16 @@ pointToPointTime <- function(output.dir, dir.create(paste0(output.dir, "/pointToPointTime-", file_name, "/geojson")) } - cat("Now running the propeR pointToPointTime tool.\n", sep="") - cat("Parameters chosen:\n", sep="") - cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") - cat("To: ", to_destination$name, " (", to_destination$lat_lon, ")\n", sep="") - cat("Date and Time: ", startDateAndTime, " (start) to ", endDateAndTime, " (end)\n", sep="") - cat("Intervals (mins): ", timeIncrease, "\n", sep="") - cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "] GIF [", gifOutput, "]\n\n", sep="") - + if (infoPrint == T){ + cat("Now running the propeR pointToPointTime tool.\n", sep="") + cat("Parameters chosen:\n", sep="") + cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") + cat("To: ", to_destination$name, " (", to_destination$lat_lon, ")\n", sep="") + cat("Date and Time: ", startDateAndTime, " (start) to ", endDateAndTime, " (end)\n", sep="") + cat("Intervals (mins): ", timeIncrease, "\n", sep="") + cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "] GIF [", gifOutput, "]\n\n", sep="") + } + ########################### #### CALL OTP FUNCTION #### ########################### @@ -157,7 +170,9 @@ pointToPointTime <- function(output.dir, num.run <- 0 num.total <- num.end time.taken <- vector() - cat("Creating ", num.total, " point to point connections, please wait...\n", sep="") + if (infoPrint == T){ + cat("Creating ", num.total, " point to point connections, please wait...\n", sep="") + } make_blank_df <- function(from_origin, to_destination, time_twenty_four) { df <- data.frame( @@ -179,9 +194,11 @@ pointToPointTime <- function(output.dir, df } - pb <- progress_bar$new( - format = " Travel time calculation complete for time :what [:bar] :percent eta: :eta", - total = num.total, clear = FALSE, width= 100) + if (infoPrint == T){ + pb <- progress::progress_bar$new( + format = " Travel time calculation complete for time :what [:bar] :percent eta: :eta", + total = num.total, clear = FALSE, width= 100) + } for (i in num.start:num.end) { @@ -239,7 +256,11 @@ pointToPointTime <- function(output.dir, } m <- leaflet() - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + if (mapDarkMode == T) { + m <- addProviderTiles(m, providers$CartoDB.DarkMatter) + } else { + m <- addProviderTiles(m, providers$CartoDB.Positron) + } m <- addScaleBar(m) if (is.numeric(mapZoom)){ @@ -280,7 +301,9 @@ pointToPointTime <- function(output.dir, lat = ~ from_lat, lng = ~ from_lon, fillColor = ~ pal_transport(point_to_point_table$mode), - stroke = F, + stroke = T, + color = mapMarkerStrokeColor, + weight = mapMarkerStrokeWeight, fillOpacity = mapMarkerOpacity, popup = ~ mode) m <- addLegend( @@ -317,7 +340,11 @@ pointToPointTime <- function(output.dir, } m <- leaflet() - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + if (mapDarkMode == T) { + m <- addProviderTiles(m, providers$CartoDB.DarkMatter) + } else { + m <- addProviderTiles(m, providers$CartoDB.Positron) + } m <- addScaleBar(m) if (is.numeric(mapZoom)){ @@ -486,7 +513,9 @@ pointToPointTime <- function(output.dir, point_to_point_table_overview <- rbind(point_to_point_table_overview, point_to_point_table_overview_tmp) } } - pb$tick(tokens = list(what = time)) + if (infoPrint == T){ + pb$tick(tokens = list(what = time)) + } } @@ -494,13 +523,14 @@ pointToPointTime <- function(output.dir, #### SAVE RESULTS #### ###################### - cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") - cat("Journey details:\n", sep = "") - cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") - cat("Mean Duration (mins): ", round(mean(point_to_point_table_overview$duration_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$duration_mins, na.rm=TRUE),2), "] ", " (Walk time: ", round(mean(point_to_point_table_overview$walk_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$walk_time_mins, na.rm=TRUE),2), "] ", ", Transit time: ", round(mean(point_to_point_table_overview$transit_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$transit_time_mins, na.rm=TRUE),2), "] ", ", Waiting time: ", round(mean(point_to_point_table_overview$waiting_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$waiting_time_mins, na.rm=TRUE),2), "])\n", sep = "") - cat("Mean Distance (km): ", round(mean(point_to_point_table_overview$distance_km, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$distance_km, na.rm=TRUE),2), "]\n", sep = "") - cat("Median Transfers: ", median(point_to_point_table_overview$transfers, na.rm=TRUE), " (Buses: ", median(point_to_point_table_overview$no_of_buses, na.rm=TRUE), ", Trains: ", median(point_to_point_table_overview$no_of_trains, na.rm=TRUE), ")\n\n", sep = "") - + if (infoPrint == T){ + cat("\nAnalysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep="") + cat("Journey details:\n", sep = "") + cat("Trips possible: ", nrow(point_to_point_table_overview[!is.na(point_to_point_table_overview$duration_mins),]),"/",num.total,"\n", sep = "") + cat("Mean Duration (mins): ", round(mean(point_to_point_table_overview$duration_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$duration_mins, na.rm=TRUE),2), "] ", " (Walk time: ", round(mean(point_to_point_table_overview$walk_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$walk_time_mins, na.rm=TRUE),2), "] ", ", Transit time: ", round(mean(point_to_point_table_overview$transit_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$transit_time_mins, na.rm=TRUE),2), "] ", ", Waiting time: ", round(mean(point_to_point_table_overview$waiting_time_mins, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$waiting_time_mins, na.rm=TRUE),2), "])\n", sep = "") + cat("Mean Distance (km): ", round(mean(point_to_point_table_overview$distance_km, na.rm=TRUE),2), " [+/-", round(sd(point_to_point_table_overview$distance_km, na.rm=TRUE),2), "]\n", sep = "") + cat("Median Transfers: ", median(point_to_point_table_overview$transfers, na.rm=TRUE), " (Buses: ", median(point_to_point_table_overview$no_of_buses, na.rm=TRUE), ", Trains: ", median(point_to_point_table_overview$no_of_trains, na.rm=TRUE), ")\n\n", sep = "") + } for (i in 1:nrow(point_to_point_table_overview)) { @@ -543,10 +573,11 @@ pointToPointTime <- function(output.dir, m <- magick::image_read(paste0(output.dir, "/pointToPointTime-", file_name, "/gif/", "/pointToPointTime-gif-", file_name, ".gif")) %>% - magick::image_scale("600") + magick::image_scale("800") invisible(print(m)) } - - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T){ + cat("Outputs saved. Thanks for using propeR.\n") + } } diff --git a/propeR/R/point-to-point.R b/propeR/R/point-to-point.R index 56950ce..1998922 100755 --- a/propeR/R/point-to-point.R +++ b/propeR/R/point-to-point.R @@ -26,14 +26,18 @@ ##' @param busTicketPriceMax Specifiy the maximum cost of a bus journey (default is 12 GPB) ##' @param trainTicketPriceKm Specifiy the cost of a train journey per km (default is 0.12 GPB per km) ##' @param trainTicketPriceMin Specifiy the minimum cost of a train journey (default is 3 GBP) +##' @param infoPrint Specifies whether you want some information printed to the console or not, default is TRUE ##' @param mapOutput Specifies whether you want to output a map, defaults to FALSE ##' @param geojsonOutput Specifies whether you want to output the polylines as a geojson, defaults to FALSE ##' @param mapPolylineColours A list defining the colours to assign to each mode of transport. ##' @param mapZoom The zoom level of the map as an integer (e.g. 12), defaults to bounding box approach ##' @param mapPolylineWeight Specifies the weight of the polyline, defaults to 5 px ##' @param mapPolylineOpacity Specifies the opacity of the polyline, defaults to 1 (solid) +##' @param mapMarkerStrokeColor Specifies the outline color of the marker, defaults to black +##' @param mapMarkerStrokeWeight Specifies the stroke weight of the marker, defaults to 1 (solid) ##' @param mapMarkerOpacity Specifies the opacity of the marker, defaults to 1 (solid) ##' @param mapLegendOpacity Specifies the opacity of the legend, defaults to 1 (solid) +##' @param mapDarkMode Specifies if you want to use the dark leaflet map colour (default is FALSE) ##' @return Saves journey details as comma separated value file to output directory. A map in .png and .html formats may also be saved) ##' @author Michael Hodge ##' @examples @@ -68,6 +72,7 @@ pointToPoint <- function(output.dir, busTicketPriceMax = 12, trainTicketPriceKm = 0.12, trainTicketPriceMin = 3, + infoPrint = T, # leaflet map args mapOutput = F, geojsonOutput = F, @@ -82,8 +87,11 @@ pointToPoint <- function(output.dir, mapZoom = "bb", mapPolylineWeight = 5, mapPolylineOpacity = 1, + mapMarkerStrokeColor = 'black', + mapMarkerStrokeWeight = 1, mapMarkerOpacity = 1, - mapLegendOpacity = 1) { + mapLegendOpacity = 1, + mapDarkMode = F) { ######################### #### SETUP VARIABLES #### @@ -121,18 +129,23 @@ pointToPoint <- function(output.dir, reverse = F ) pal_time_date = leaflet::colorFactor(c("#FFFFFF"), domain = NULL) + if (mapDarkMode == T){ + mapMarkerStrokeColor = 'white' + } } if (geojsonOutput == T){ dir.create(paste0(output.dir, "/pointToPoint-", file_name, "/geojson")) } - cat("Now running the propeR pointToPoint tool.\n") - cat("Parameters chosen:\n", sep="") - cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") - cat("To: ", to_destination$name, " (", to_destination$lat_lon, ")\n", sep="") - cat("Date and Time: ", startDateAndTime, sep="") - cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep="") + if (infoPrint == T){ + cat("Now running the propeR pointToPoint tool.\n") + cat("Parameters chosen:\n", sep="") + cat("From: ", from_origin$name, " (", from_origin$lat_lon, ")\n", sep="") + cat("To: ", to_destination$name, " (", to_destination$lat_lon, ")\n", sep="") + cat("Date and Time: ", startDateAndTime, "\n", sep="") + cat("Outputs: CSV [TRUE] Map [", mapOutput, "] GeoJSON [", geojsonOutput, "]\n\n", sep="") + } ########################### #### CALL OTP FUNCTION #### @@ -213,7 +226,9 @@ pointToPoint <- function(output.dir, } if (mapOutput == T) { - cat("Generating map, please wait.\n") + if (infoPrint == T){ + cat("Generating map, please wait.\n") + } popup_poly_lines <- paste0( "Mode: ", @@ -226,11 +241,15 @@ pointToPoint <- function(output.dir, round(poly_lines$duration / 60, digits = 2), " mins", "
Distance: ", - round(poly_lines$duration, digits = 2), - " meters") + round(poly_lines$distance / 1000, digits = 2), + " km") m <- leaflet() - m <- addProviderTiles(m, providers$OpenStreetMap.BlackAndWhite) + if (mapDarkMode == T) { + m <- addProviderTiles(m, providers$CartoDB.DarkMatter) + } else { + m <- addProviderTiles(m, providers$CartoDB.Positron) + } m <- addScaleBar(m) if (is.numeric(mapZoom)){ @@ -272,7 +291,9 @@ pointToPoint <- function(output.dir, lat = ~ from_lat, lng = ~ from_lon, fillColor = ~ pal_transport(point_to_point_table$mode), - stroke = F, + stroke = T, + color = mapMarkerStrokeColor, + weight = mapMarkerStrokeWeight, fillOpacity = mapMarkerOpacity, popup = ~ from) m <- addLegend( @@ -305,12 +326,14 @@ pointToPoint <- function(output.dir, #### SAVE RESULTS #### ###################### - cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") - cat("Journey details:\n", sep = "") - cat("Duration (mins): ", point_to_point_table_overview$duration_mins, " (Walk time: ", point_to_point_table_overview$walk_time_mins, ", Transit time: ", point_to_point_table_overview$transit_time_mins, ", Waiting time: ", point_to_point_table_overview$waiting_time_mins, ")\n", sep = "") - cat("Distance (km): ", point_to_point_table_overview$distance_km, "\n", sep = "") - cat("Transfers: ", point_to_point_table_overview$transfers, " (Buses: ", point_to_point_table_overview$no_of_buses, ", Trains: ", point_to_point_table_overview$no_of_trains, ")\n\n", sep = "") - + if (infoPrint == T){ + cat("Analysis complete, now saving outputs to ", output.dir, ", please wait.\n", sep = "") + cat("Journey details:\n", sep = "") + cat("Duration (mins): ", point_to_point_table_overview$duration_mins, " (Walk time: ", point_to_point_table_overview$walk_time_mins, ", Transit time: ", point_to_point_table_overview$transit_time_mins, ", Waiting time: ", point_to_point_table_overview$waiting_time_mins, ")\n", sep = "") + cat("Distance (km): ", point_to_point_table_overview$distance_km, "\n", sep = "") + cat("Transfers: ", point_to_point_table_overview$transfers, " (Buses: ", point_to_point_table_overview$no_of_buses, ", Trains: ", point_to_point_table_overview$no_of_trains, ")\n\n", sep = "") + } + if (modes == "CAR") { colnames(point_to_point_table_overview)[which(names(point_to_point_table_overview) == "walk_time_mins")] <- "drive_time_mins" } else if (modes == "BICYCLE") { @@ -355,5 +378,7 @@ pointToPoint <- function(output.dir, stop("No journey found with given parameters!\n") } - cat("Outputs saved. Thanks for using propeR.\n") + if (infoPrint == T){ + cat("Outputs saved. Thanks for using propeR.\n") + } } \ No newline at end of file