Running ‘colourScale.R’ [3s/4s]
  Running ‘omerc.R’ [9s/15s]
  Running ‘openmap.R’ [8s/12s]
  Running ‘worldMap.R’ [11s/15s]
Running the tests in ‘tests/openmap.R’ failed.
Complete output:
  > #+ setup
  > library('mapmisc')
  Loading required package: sp
  Loading required package: raster
  map images will be cached in  /home/hornik/tmp/scratch/RtmpB6WS38/mapmiscCache
  > 
  > if(!exists('mapmiscCachePath'))
  +   mapmiscCachePath = system.file('extdata', package='mapmisc')
  > 
  > if(!exists('mapmiscCacheReadOnly'))
  +   mapmiscCacheReadOnly = TRUE
  > 
  > 
  > options(
  +   mapmiscCachePath = mapmiscCachePath,
  +   mapmiscCacheReadOnly = mapmiscCacheReadOnly,
  +   mapmiscVerbose=TRUE)
  > 
  > getOption("mapmiscCachePath")
  [1] "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata"
  > getOption("mapmiscCacheReadOnly")
  [1] TRUE
  > #'
  > 
  > 
  > #+ simplePlot
  > myraster = raster(matrix(0,10,10),xmn=8,xmx=18,ymn=0,ymx=10, 
  +   crs=CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
  + )
  > values(myraster) = seq(0,1,len=ncell(myraster))
  > 
  > myPoints = SpatialPoints(myraster, 
  +   proj4string=CRS(proj4string(myraster)))[
  +   seq(1,ncell(myraster),len=5)]
  > 
  > plot(myraster)
  > points(myPoints)
  > #'
  > #' 
  > #' only do the following if rgdal is available
  > #+ africaPlots 
  > if(require('rgdal', quietly=TRUE)) {
  +   
  +   # utm zone 32
  +   utmproj = CRS("+init=epsg:3064") 
  +   myrasterUTM = projectRaster(myraster, crs=utmproj)
  +   myPointsUTM = spTransform(myPoints, utmproj)
  +   plot(myrasterUTM)
  +   points(myPointsUTM)
  +   
  +   myPointsMercator = spTransform(myPoints, 
  +     crsMerc)
  +   
  +   
  +   myplot = function(first,second=first) {
  +     par(mar=c(0,0,0,0))
  +     plot(first)
  +     plot(mytiles, add=TRUE)
  +     plot(second,add=TRUE,col='blue')
  + #	points(mycities,col='red')
  + #	text(mycities, labels=mycities$name, col='red',pos=4)
  +     scaleBar(first)
  +   }
  +   
  +   
  +   thezoom=6
  +   
  + # only do the following if running unix (because nsl is available)
  + # and if the OpenStreetMap.org web site can be accessed
  +   
  +   # raster, result will be in project of the raster (long-lat)
  +   mytiles = openmap(x=extend(myraster,1),
  +     zoom=thezoom)
  + #		mycities = GNcities(extend(myraster,1),max=5)
  +   myplot(myraster, myPoints)
  +   
  +   # slash at the end
  +   mytiles = openmap(extend(myraster,1),zoom=thezoom, 
  +     path="http://tile.openstreetmap.org/")
  + #		mycities = GNcities(extend(myraster,1),max=5)
  +   myplot(myraster, myPoints)
  +   
  +   # no http at beginning
  +   mytiles = openmap(extend(myraster,1),path="tile.openstreetmap.org")
  + #		mycities = GNcities(extend(myraster,1),max=5)
  +   myplot(myraster, myPoints)
  +   
  +   
  +   # extent, tiles will be long-lat
  +   mytiles = openmap(extent(myraster),zoom=thezoom)
  +   # cities will be long=lat
  + #		mycities = GNcities(extent(myraster),max=5,lang="fr")
  + #		myplot(mycities,myPoints)
  +   
  +   # give the bbox, long lat
  +   mytiles = openmap(bbox(myraster),zoom=thezoom)
  + #		mycities = GNcities(bbox(myraster),max=5)
  + #		myplot(mycities,myPoints)
  +   
  +   
  +   # give points, result is CRS of points (long-lat)
  +   mytiles = openmap(myPoints,zoom=thezoom)
  + #		mycities = GNcities(myPoints,max=5,lang="es")
  +   myplot(myPoints)
  +   
  +   # UTM raster
  +   mytiles = openmap(myrasterUTM,zoom=thezoom)
  + #		mycities = GNcities(myrasterUTM,max=5)
  +   myplot(myrasterUTM, myPointsUTM)
  +   
  +   # supply a crs
  +   mytiles = openmap(x=extent(myrasterUTM),zoom=thezoom, 
  +     crs=proj4string(myrasterUTM))
  + #		mycities = GNcities(myrasterUTM,max=5)
  +   myplot(myrasterUTM, myPointsUTM)
  +   
  +   # utm points
  +   mytiles = openmap(myPointsUTM,zoom=thezoom)
  + #		mycities = GNcities(myPointsUTM,max=5)
  +   myplot(myPointsUTM)
  +   
  +   # specify different output crs
  +   mytiles = openmap(myPointsUTM, crs=CRS("+init=epsg:4326"))
  + #	mycities = GNcities(myPoints,max=5)
  +   myplot(myPoints)
  +   
  +   # one point only
  +   mytiles = openmap(coordinates(myPoints)[1,], zoom=4)
  +   myplot(myPoints)
  +   } # end have rgdal
  rgdal: version: 1.4-7, (SVN revision 845)
   Geospatial Data Abstraction Library extensions to R successfully loaded
   Loaded GDAL runtime: GDAL 2.4.3, released 2019/10/28
   Path to GDAL shared files: /usr/share/gdal
   GDAL binary built with GEOS: TRUE 
   Loaded PROJ.4 runtime: Rel. 6.2.1, November 1st, 2019, [PJ_VERSION: 621]
   Path to PROJ.4 shared files: (autodetected)
   Linking to sp version: 1.3-2 
  zoom is  6 ,  9 tiles
  http://tile.openstreetmap.org/ 
  http://tile.openstreetmap.org/ 
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/33/30.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/33/31.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/33/32.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/34/30.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/34/31.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/34/32.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/35/30.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/35/31.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/6/35/32.png  cached
  reprojecting  589824  cells... ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  mapmisc
   --- call from context --- 
  openmap(x = extend(myraster, 1), zoom = thezoom)
   --- call from argument --- 
  if (class(bboxx) != "try-error" & class(projx) != "try-error") {
      if (identical(projx, crsOut)) {
          bigExtent = extend(extent(x), buffer + abs(as.numeric(apply(bboxx, 
              1, diff))/2))
          toRaster = raster::crop(toRaster, bigExtent)
      }
  }
   --- R stacktrace ---
  where 1: openmap(x = extend(myraster, 1), zoom = thezoom)
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (x, zoom, path = "http://tile.openstreetmap.org/", maxTiles = 9, 
      crs = projection(x), buffer = 0, fact = 1, verbose = getOption("mapmiscVerbose"), 
      cachePath = getOption("mapmiscCachePath")) 
  {
      verbose = max(c(0, verbose))
      if (is.null(cachePath)) {
          cachePath = tempdir()
      }
      if (!nchar(cachePath)) {
          cachePath = "."
      }
      alltiles = osmTiles()
      pathOrig = path
      pathisname = gsub("-", ".", pathOrig) %in% gsub("-", ".", 
          names(alltiles))
      path[pathisname] = alltiles[path[pathisname]]
      if (length(grep("[[:punct:]]$", path, invert = TRUE))) 
          path[grep("[[:punct:]]$", path, invert = TRUE)] = paste(path[grep("[[:punct:]]$", 
              path, invert = TRUE)], "/", sep = "")
      if (length(grep("^http[s]*://", path, invert = TRUE))) 
          path[grep("^http[s]*://", path, invert = TRUE)] = paste("http://", 
              path[grep("^http[s]*://", path, invert = TRUE)], 
              sep = "")
      names(path) = pathOrig
      if (all(class(x) == "CRS")) {
          crs = x
          toCrop = attributes(x)$ellipse
          x = attributes(x)$regionLL
      }
      else {
          toCrop = NULL
      }
      crsOut = crs
      crsIn = crs(x)
      if (all(is.na(crsIn))) {
          if (is.vector(x)) {
              crsIn = crsLL
          }
          else {
              crsIn = crs
          }
      }
      extMerc = .getExtent(x, crsIn, buffer, crsMerc)
      extMerc = .cropExtent(extMerc, extentMerc)
      if (missing(zoom)) {
          zoom = 1
          while (nTilesMerc(extMerc, zoom) <= maxTiles & zoom <= 
              18) {
              zoom = zoom + 1
          }
          zoom = min(c(18, max(c(1, zoom - 1))))
      }
      if (verbose) 
          cat("zoom is ", zoom, ", ", nTilesMerc(extMerc, zoom), 
              "tiles\n")
      result = NULL
      for (Dpath in rev(names(path))) {
          Durl = path[Dpath]
          if (verbose) {
              cat(Dpath, "\n")
              cat(Durl, "\n")
          }
          if (length(grep("nrcan\\.gc\\.ca|gov\\.bc\\.ca", Durl))) {
              suffix = ""
              tileNames = "zyx"
          }
          else if (length(grep("[.]arcgisonline[.]com", Durl))) {
              suffix = ".jpg"
              tileNames = "zyx"
          }
          else if (length(grep("heidelberg.de/tiles/(hybrid|adminb|roadsg|roads)/?$", 
              Durl)) | length(grep("&$", Durl))) {
              tileNames = "xyz="
              suffix = ""
          }
          else {
              suffix = ".png"
              tileNames = "zxy"
          }
          if (length(attributes(pathOrig)$tileNames)) 
              tileNames = attributes(pathOrig)$tileNames
          if (length(attributes(pathOrig)$suffix)) 
              suffix = attributes(pathOrig)$suffix
          thistile = try(getTilesMerc(extMerc, zoom = zoom, path = Durl, 
              verbose = verbose, suffix = suffix, tileNames = tileNames, 
              cachePath = cachePath), silent = !verbose)
          if (class(thistile) == "try-error") {
              message(paste(Durl, "not accessible"))
              thistile = NULL
          }
          else {
              if (length(names(thistile))) {
                  theprefix = strsplit(names(thistile), "([rR]ed|[gG]reen|[bB]lue)$", 
                    fixed = FALSE)[[1]]
                  names(thistile) = gsub(theprefix, paste(Dpath, 
                    "", sep = ""), names(thistile), fixed = TRUE)
              }
              ctable = NULL
              if (!is.null(thistile)) {
                  if (nlayers(thistile) == 1) 
                    ctable = thistile@legend@colortable
                  if (is.null(result)) {
                    result = stack(thistile)
                  }
                  else {
                    result = stack(result, thistile)
                  }
              }
          }
      }
      if (is.null(result)) {
          result = raster(extMerc, 1, 1, crs = crsMerc)
          values(result) = NA
          attributes(result)$openmap = list(tiles = NA, message = thistile, 
              path = path, zoom = zoom)
      }
      if (!is.na(crsOut)) {
          oldColorTable = list()
          for (D in names(result)) oldColorTable[[D]] = result[[D]]@legend@colortable
          if (verbose) 
              cat("reprojecting ", ncell(result), " cells...")
          if (!compareCRS(projection(result), crsOut)) {
              toRaster = projectExtent(result, crsOut)
              bboxx = try(bbox(extend(extent(x), buffer)), silent = TRUE)
              if (any(apply(bboxx, 1, diff) < .Machine$double.eps)) {
                  class(bboxx) = "try-error"
              }
              projx = try(proj4string(x), silent = TRUE)
              if (class(bboxx) != "try-error" & class(projx) != 
                  "try-error") {
                  if (identical(projx, crsOut)) {
                    bigExtent = extend(extent(x), buffer + abs(as.numeric(apply(bboxx, 
                      1, diff))/2))
                    toRaster = raster::crop(toRaster, bigExtent)
                  }
              }
              if (any(fact > 1)) {
                  res(toRaster) = res(toRaster)/rep_len(fact, 2)
              }
              resultProj1 = suppressWarnings(projectRaster(result, 
                  toRaster, method = "ngb"))
              resultProj = stack(resultProj1)
              for (D in names(resultProj)) resultProj[[D]]@legend@colortable = oldColorTable[[D]]
              if (verbose) 
                  cat("done\n")
          }
          else {
              if (any(fact < 1)) {
                  fact = pmax(1, round(1/fact))
                  if (any(fact > 1)) {
                    if (verbose) 
                      cat("aggregating tiles by ", fact, "\n")
                    resultProj = stack(aggregate(result, fact = fact, 
                      fun = min))
                    for (D in names(resultProj)) resultProj[[D]]@legend = result[[D]]@legend
                  }
              }
              else {
                  if (verbose) 
                    cat("tiles arrived in the desired projection\n")
                  resultProj = stack(result)
              }
          }
      }
      else {
          resultProj = stack(result)
      }
      for (D in names(resultProj)) {
          if (length(result[[D]]@legend@colortable)) {
              if (verbose) 
                  cat("copying colortable for ", D, "\n")
              resultProj[[D]]@legend@colortable = result[[D]]@legend@colortable
              if (any(values(resultProj[[D]]) == 0, na.rm = TRUE) | 
                  any(is.na(values(resultProj[[D]])))) {
                  resultProj[[D]]@legend@colortable = c("#FFFFFF00", 
                    resultProj[[D]]@legend@colortable)
                  values(resultProj[[D]]) = 1 + values(resultProj[[D]])
              }
          }
      }
      if (nlayers(resultProj) == 1) 
          resultProj = resultProj[[1]]
      attributes(resultProj)$tiles = attributes(thistile)$tiles
      attributes(resultProj)$tiles$path = path
      resultProj
  }
  <bytecode: 0x5619826608b0>
  <environment: namespace:mapmisc>
   --- function search by body ---
  Function openmap in namespace mapmisc has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1
Running the tests in ‘tests/worldMap.R’ failed.
Complete output:
  > #+ setup
  > library('mapmisc')
  Loading required package: sp
  Loading required package: raster
  map images will be cached in  /home/hornik/tmp/scratch/Rtmp3GNbLO/mapmiscCache
  > 
  > if(!exists('mapmiscCachePath'))
  +   mapmiscCachePath = system.file('extdata', package='mapmisc')
  > 
  > if(!exists('mapmiscCacheReadOnly'))
  +   mapmiscCacheReadOnly = TRUE
  > 
  > mapmiscCachePath
  [1] "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata"
  > 
  > options(
  +   mapmiscCachePath = mapmiscCachePath,
  +   mapmiscCacheReadOnly = mapmiscCacheReadOnly,
  +   mapmiscVerbose=TRUE)
  > 
  > getOption("mapmiscCachePath")
  [1] "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata"
  > getOption("mapmiscCacheReadOnly")
  [1] TRUE
  > #'
  > 
  > 
  > #+ themaps, fig.cap='some maps', fig.subcap = c('projectable region', 'projected, with bg','projected, with world countries','projectable madagascar','madagascar')
  > Spackages = c('rgdal', 'rgeos', 'geosphere')
  > 
  > if(all(unlist(mapply(requireNamespace, package=Spackages, MoreArgs=list(quietly=TRUE))))){
  + #	library('rgdal')
  + 
  + 	data("worldMap")
  + 
  + 	world = spTransform(worldMap, crsLL)
  + 	country='Japan'
  + 	Dcountry = grep(country, world$NAME)
  + 	x=world[Dcountry,]
  + 
  + 	myCrsO = moll(x, angle=25)
  + 
  +  plot(world)
  +  plot(attributes(myCrsO)$regionLL, 
  +  	border='red', col='#0000FF10', add=TRUE)
  +  
  +  myMap = openmap(myCrsO, zoom=1, fact=2)
  +  map.new(myMap)
  +  plot(myMap, add=TRUE)
  +  gridlinesWrap(myCrsO, lty=2, col='orange')
  + 
  +  xTcrop = wrapPoly(x=world, crs=myCrsO)
  + 
  + 	DcountryT  = grep(country, xTcrop$NAME)
  + 	
  + 	map.new(xTcrop, buffer=1000*1000)
  +  plot(attributes(myCrsO)$ellipse, add=TRUE, col='lightBlue', border='blue')
  + 	plot(xTcrop,add=TRUE, col='grey')
  + 	plot(xTcrop[DcountryT,], col='red', lty=0, add=TRUE)
  + 	
  + 	gridlinesWrap(myCrsO, lty=2, col='orange')
  + 	
  + 
  +  country='Madagascar'
  + 	Dcountry  = grep(country, world$NAME)
  + 	x=world[Dcountry,]
  + 	
  + 	myCrsMoll = moll(x, angle=100, flip= 'nwu' )
  + 	
  + 	plot(attributes(myCrsMoll)$ellipse)
  + 	
  + 	plot(world)
  + 	plot(attributes(myCrsMoll)$crop, border='red', col='#0000FF10', add=TRUE)
  + 	
  + 	xTcrop = wrapPoly(x=world, crs=myCrsMoll)
  + 	DcountryT  = grep(country, xTcrop$NAME)
  + 	
  + 	map.new(xTcrop)
  + 	plot(attributes(myCrsMoll)$ellipse, add=TRUE, col='lightBlue', border='blue')
  + 	plot(xTcrop,add=TRUE, col='grey')
  + 	plot(xTcrop[DcountryT,], col='green', add=TRUE)
  + 	
  + 	gridlinesWrap(crs=xTcrop, lty=2, col='red')
  + 
  + 	
  + 	
  + 	country='Iceland'
  + 	Dcountry  = grep(country, world$NAME)
  + 	x=world[Dcountry,]
  + 	
  + 	myCrsMoll = moll(x,  angle=0, flip= 'nwu' )
  + 	
  + 	plot(attributes(myCrsMoll)$ellipse)
  + 	
  + 	plot(world)
  + 	plot(attributes(myCrsMoll)$crop, border='red', col='#0000FF10', add=TRUE)
  + 	
  + 	xTcrop = wrapPoly(x=world, crs=myCrsMoll)
  + 	DcountryT  = grep(country, xTcrop$NAME)
  + 	
  + 	map.new(xTcrop)
  + 	plot(attributes(myCrsMoll)$ellipse, add=TRUE, col='lightBlue', border='blue')
  + 	plot(xTcrop,add=TRUE, col='grey')
  + 	plot(xTcrop[DcountryT,], col='green', add=TRUE)
  + 	
  + 	gridlinesWrap(crs=xTcrop, lty=2, col='red')
  + 	
  + 	
  + }
  zoom is  1 ,  4 tiles
  http://tile.openstreetmap.org/ 
  http://tile.openstreetmap.org/ 
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/1/0/0.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/1/0/1.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/1/1/0.png  cached
  tile  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/mapmisc/extdata/org/1/1/1.png  cached
  reprojecting  262144  cells... ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  mapmisc
   --- call from context --- 
  openmap(myCrsO, zoom = 1, fact = 2)
   --- call from argument --- 
  if (class(bboxx) != "try-error" & class(projx) != "try-error") {
      if (identical(projx, crsOut)) {
          bigExtent = extend(extent(x), buffer + abs(as.numeric(apply(bboxx, 
              1, diff))/2))
          toRaster = raster::crop(toRaster, bigExtent)
      }
  }
   --- R stacktrace ---
  where 1: openmap(myCrsO, zoom = 1, fact = 2)
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (x, zoom, path = "http://tile.openstreetmap.org/", maxTiles = 9, 
      crs = projection(x), buffer = 0, fact = 1, verbose = getOption("mapmiscVerbose"), 
      cachePath = getOption("mapmiscCachePath")) 
  {
      verbose = max(c(0, verbose))
      if (is.null(cachePath)) {
          cachePath = tempdir()
      }
      if (!nchar(cachePath)) {
          cachePath = "."
      }
      alltiles = osmTiles()
      pathOrig = path
      pathisname = gsub("-", ".", pathOrig) %in% gsub("-", ".", 
          names(alltiles))
      path[pathisname] = alltiles[path[pathisname]]
      if (length(grep("[[:punct:]]$", path, invert = TRUE))) 
          path[grep("[[:punct:]]$", path, invert = TRUE)] = paste(path[grep("[[:punct:]]$", 
              path, invert = TRUE)], "/", sep = "")
      if (length(grep("^http[s]*://", path, invert = TRUE))) 
          path[grep("^http[s]*://", path, invert = TRUE)] = paste("http://", 
              path[grep("^http[s]*://", path, invert = TRUE)], 
              sep = "")
      names(path) = pathOrig
      if (all(class(x) == "CRS")) {
          crs = x
          toCrop = attributes(x)$ellipse
          x = attributes(x)$regionLL
      }
      else {
          toCrop = NULL
      }
      crsOut = crs
      crsIn = crs(x)
      if (all(is.na(crsIn))) {
          if (is.vector(x)) {
              crsIn = crsLL
          }
          else {
              crsIn = crs
          }
      }
      extMerc = .getExtent(x, crsIn, buffer, crsMerc)
      extMerc = .cropExtent(extMerc, extentMerc)
      if (missing(zoom)) {
          zoom = 1
          while (nTilesMerc(extMerc, zoom) <= maxTiles & zoom <= 
              18) {
              zoom = zoom + 1
          }
          zoom = min(c(18, max(c(1, zoom - 1))))
      }
      if (verbose) 
          cat("zoom is ", zoom, ", ", nTilesMerc(extMerc, zoom), 
              "tiles\n")
      result = NULL
      for (Dpath in rev(names(path))) {
          Durl = path[Dpath]
          if (verbose) {
              cat(Dpath, "\n")
              cat(Durl, "\n")
          }
          if (length(grep("nrcan\\.gc\\.ca|gov\\.bc\\.ca", Durl))) {
              suffix = ""
              tileNames = "zyx"
          }
          else if (length(grep("[.]arcgisonline[.]com", Durl))) {
              suffix = ".jpg"
              tileNames = "zyx"
          }
          else if (length(grep("heidelberg.de/tiles/(hybrid|adminb|roadsg|roads)/?$", 
              Durl)) | length(grep("&$", Durl))) {
              tileNames = "xyz="
              suffix = ""
          }
          else {
              suffix = ".png"
              tileNames = "zxy"
          }
          if (length(attributes(pathOrig)$tileNames)) 
              tileNames = attributes(pathOrig)$tileNames
          if (length(attributes(pathOrig)$suffix)) 
              suffix = attributes(pathOrig)$suffix
          thistile = try(getTilesMerc(extMerc, zoom = zoom, path = Durl, 
              verbose = verbose, suffix = suffix, tileNames = tileNames, 
              cachePath = cachePath), silent = !verbose)
          if (class(thistile) == "try-error") {
              message(paste(Durl, "not accessible"))
              thistile = NULL
          }
          else {
              if (length(names(thistile))) {
                  theprefix = strsplit(names(thistile), "([rR]ed|[gG]reen|[bB]lue)$", 
                    fixed = FALSE)[[1]]
                  names(thistile) = gsub(theprefix, paste(Dpath, 
                    "", sep = ""), names(thistile), fixed = TRUE)
              }
              ctable = NULL
              if (!is.null(thistile)) {
                  if (nlayers(thistile) == 1) 
                    ctable = thistile@legend@colortable
                  if (is.null(result)) {
                    result = stack(thistile)
                  }
                  else {
                    result = stack(result, thistile)
                  }
              }
          }
      }
      if (is.null(result)) {
          result = raster(extMerc, 1, 1, crs = crsMerc)
          values(result) = NA
          attributes(result)$openmap = list(tiles = NA, message = thistile, 
              path = path, zoom = zoom)
      }
      if (!is.na(crsOut)) {
          oldColorTable = list()
          for (D in names(result)) oldColorTable[[D]] = result[[D]]@legend@colortable
          if (verbose) 
              cat("reprojecting ", ncell(result), " cells...")
          if (!compareCRS(projection(result), crsOut)) {
              toRaster = projectExtent(result, crsOut)
              bboxx = try(bbox(extend(extent(x), buffer)), silent = TRUE)
              if (any(apply(bboxx, 1, diff) < .Machine$double.eps)) {
                  class(bboxx) = "try-error"
              }
              projx = try(proj4string(x), silent = TRUE)
              if (class(bboxx) != "try-error" & class(projx) != 
                  "try-error") {
                  if (identical(projx, crsOut)) {
                    bigExtent = extend(extent(x), buffer + abs(as.numeric(apply(bboxx, 
                      1, diff))/2))
                    toRaster = raster::crop(toRaster, bigExtent)
                  }
              }
              if (any(fact > 1)) {
                  res(toRaster) = res(toRaster)/rep_len(fact, 2)
              }
              resultProj1 = suppressWarnings(projectRaster(result, 
                  toRaster, method = "ngb"))
              resultProj = stack(resultProj1)
              for (D in names(resultProj)) resultProj[[D]]@legend@colortable = oldColorTable[[D]]
              if (verbose) 
                  cat("done\n")
          }
          else {
              if (any(fact < 1)) {
                  fact = pmax(1, round(1/fact))
                  if (any(fact > 1)) {
                    if (verbose) 
                      cat("aggregating tiles by ", fact, "\n")
                    resultProj = stack(aggregate(result, fact = fact, 
                      fun = min))
                    for (D in names(resultProj)) resultProj[[D]]@legend = result[[D]]@legend
                  }
              }
              else {
                  if (verbose) 
                    cat("tiles arrived in the desired projection\n")
                  resultProj = stack(result)
              }
          }
      }
      else {
          resultProj = stack(result)
      }
      for (D in names(resultProj)) {
          if (length(result[[D]]@legend@colortable)) {
              if (verbose) 
                  cat("copying colortable for ", D, "\n")
              resultProj[[D]]@legend@colortable = result[[D]]@legend@colortable
              if (any(values(resultProj[[D]]) == 0, na.rm = TRUE) | 
                  any(is.na(values(resultProj[[D]])))) {
                  resultProj[[D]]@legend@colortable = c("#FFFFFF00", 
                    resultProj[[D]]@legend@colortable)
                  values(resultProj[[D]]) = 1 + values(resultProj[[D]])
              }
          }
      }
      if (nlayers(resultProj) == 1) 
          resultProj = resultProj[[1]]
      attributes(resultProj)$tiles = attributes(thistile)$tiles
      attributes(resultProj)$tiles$path = path
      resultProj
  }
  <bytecode: 0x5593fe25d038>
  <environment: namespace:mapmisc>
   --- function search by body ---
  Function openmap in namespace mapmisc has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1