Skip to content

Commit 52f7257

Browse files
committed
added token message & bug fixes
1 parent 31918b1 commit 52f7257

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

R/basemap.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ basemap <- function(ext = NULL, map_service = NULL, map_type = NULL, map_res = N
6767
if(is.null(map_service)) map_service <- getOption("basemaps.defaults")$map_service
6868
if(is.null(map_type)) map_type <- getOption("basemaps.defaults")$map_type
6969
if(is.null(map_res)) map_res <- getOption("basemaps.defaults")$map_res
70+
7071
if(is.null(map_token)) map_token <- getOption("basemaps.defaults")$map_token
72+
if(map_service == "mapbox" & is.na(map_token)) out("You need to define 'map_token' to use map_service 'mapbox'. Register at https://mapbox.com to obtain a token.", type = 3)
73+
if(map_service == "osm_thunderforest" & is.na(map_token)) out("You need to define 'map_token' to use map_service 'osm_thunderforest'. Register at https://thunderforest.com to obtain a token.", type = 3)
7174

7275
extras <- list(...)
7376
if(!is.null(extras$browse)) browse <- extras$browse else browse <- TRUE
@@ -96,7 +99,7 @@ basemap <- function(ext = NULL, map_service = NULL, map_type = NULL, map_res = N
9699
if("stars" %in% class) return(map)
97100
if("plot" == class){
98101
dim_map <- dim(map)
99-
if(length(dim(map) == 2)) dim_map["band"] <- 1
102+
if(length(dim(map)) == 2) dim_map["band"] <- 1
100103
if(dim_map[3] == 3){
101104
plot(map, rgb = 1:3, main = NULL, downsample = 0)
102105
} else{

R/internal.R

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ gg.bmap <- function(r, r_type, gglayer = F, ...){
173173
resp <- GET(url)
174174
status <- resp$status_code
175175
if(status == 401 & map_service == "mapbox") out("Authentification failed. Is your map_token correct?", type = 3)
176+
if(status == 403 & map_service == "osm_thunderforest") out("Authentification failed. Is your map_token correct?", type = 3)
176177
}
177178
if(!file.exists(file)){
178179
tryCatch(curl_download(url = url, destfile = file), error = function(e) out(paste0("Tile download failed: ", e$message), type = 3))

data/ext.rda

1 Byte
Binary file not shown.

0 commit comments

Comments
 (0)