Closed arthurgailes closed 4 years ago
If I may, I would like to propose a slight change on code, regarding the default behaviour of cachedir
, from an user perspective.
cachedir=TRUE
would move the output to "<working directory>\<src>"
By doing , users wouldn't mind to type the full path and on RStudio you can navigate easily on Files, I think this would work:
if(isFALSE(cachedir)) {
cachedir <- tempdir()
} else if (isTRUE(cachedir)) {
cachedir <- getwd()
} else {
# create the cachedir if it doesn't exist.
if (!dir.exists(cachedir)) dir.create(cachedir)
}
# uses subdirectories based on src to make the directory easier for users to navigate
cachedir <- paste0(cachedir, "/", src)
if (!dir.exists(cachedir)) dir.create(cachedir)
instead of
I agree, that's better. Small change to add "tile.chache" folder to working directory, so subfolders for different map sources won't cause clutter. Committed.
Merged! Thank you very much @arthurgailes and @dieghernan . I just had to modify a bit barscale.R to make the automatic size work with other metrics.
Two quick feature additions - I was creating maps in a loop, and being able to cache the tiles sped up the process quite a bit.
By default, getTiles behaves as before, only placing them in a tempdir. Now if cachedir is specified to a file path, it will save the tiles to that directory, allowing the files to be re-used if the function is called again. Useful for re-running the code in different sessions.
forceDownload
will overwrite existing cached tiles.example code:
I hope to work on an efficient raster caching system if this is accepted, which would really speed things up.
Second addition is the ability to use miles and meters in the barscale; pretty straightforward. I wrote the conversion in a separate function in case you'd want to add more unit types later.