Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues related to caching #11

Closed
benscarlson opened this issue Aug 29, 2022 · 2 comments
Closed

Issues related to caching #11

benscarlson opened this issue Aug 29, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@benscarlson
Copy link

I believe I've stumbled upon a couple of possibly inter-related issues with the caching code.

First, if I set something like the following:

basemap_ggplot(ext=ext,map_service='esri',map_type='world_imagery',verbose=TRUE, map_dir=file.path(.wd,'mymaps'))

png files are correctly placed in the mymaps folder. However, a file like mymapsbasemap_20220829115215.tif is placed in my working directory. Is this also supposed to be placed in the mymaps directory? If so, I think the culprit is here:

paste0(map_dir, "basemap_", gsub(":", "", gsub(" ", "", gsub("-", "", Sys.time()))), ".tif")

Perhaps you meant do so something like file.path(map_dir, ...) instead of paste0(map_dir,...) ?

Secondly, the basemap_* function throws an error message if you change the cache within the session. If I executed the code above, then execute (changing mymaps to mytiles):

basemap_ggplot(ext=ext,map_service='esri',map_type='world_imagery',verbose=TRUE, map_dir=file.path(.wd,'mytiles'))

I receive the error message

Error in cached[[which(cached.match)]]$file_comp : $ operator is invalid for atomic vectors

It seems to come from here:

cached[[which(cached.match)]]$file_comp

16EAGLE added a commit that referenced this issue Sep 8, 2022
16EAGLE added a commit that referenced this issue Sep 8, 2022
@16EAGLE
Copy link
Owner

16EAGLE commented Sep 8, 2022

Perhaps you meant do so something like file.path(map_dir, ...) instead of paste0(map_dir,...) ?

Thanks, that is clearly a bug – fixed this with 545fc49.

Secondly, the basemap_* function throws an error message if you change the cache within the session. If I executed the code above, then execute (changing mymaps to mytiles):

I could not exactly reproduce this, however, changing map_dir during a session definitely caused issues. When changing map_dir, all maps that had been previously cached in the current session were still considered even if they had been saved to a different directory, which was not intended. Cached maps that are not stored in the current map directory are now disregarded, so that only maps stored in map_dir are considered to be recycled (21daaa5).

Could you test whether the issue is solved with the most recent commits?

@16EAGLE 16EAGLE added the bug Something isn't working label Sep 8, 2022
@benscarlson
Copy link
Author

Both fixes worked!

library(basemaps)
packageDescription('basemaps')$Version #0.0.4
data(ext)

Validate that fix 545fc49 places the .tif file in map_dir

mp <- basemap_ggplot(ext=ext,map_service='esri',map_type='world_imagery',
  verbose=TRUE, map_dir='mymaps')

Validate that fix 21daaa5 does not throw an issue and does not attempt to load from cache if map_dir is changed

mp2 <- basemap_ggplot(ext=ext,map_service='esri',map_type='world_imagery',
  verbose=TRUE, map_dir='mytiles')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants