Running 'test-all.R' [5s/5s]
Running the tests in 'tests/test-all.R' failed.
Complete output:
  > library(testthat)
  > test_check("cleangeo")
  Loading required package: cleangeo
  Loading required package: rgeos
  Loading required package: sp
  rgeos version: 0.5-2, (SVN revision 621)
   GEOS runtime version: 3.8.0-CAPI-1.13.1 
   Linking to sp version: 1.3-2 
   Polygon checking: TRUE 
  
  Loading required package: maptools
  Checking rgeos availability: TRUE
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  cleangeo
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(l.coords) != "matrix") {
      l.coords <- data.frame(x = l.coords[1], y = l.coords[2], 
          intersect = FALSE, linestart = TRUE, stringsAsFactors = FALSE)
  } else {
      l.coords <- data.frame(x = l.coords[, 1], y = l.coords[, 
          2], intersect = c(FALSE, rep(TRUE, nrow(l.coords) - 1)), 
          linestart = c(TRUE, rep(FALSE, nrow(l.coords) - 1)), 
          stringsAsFactors = FALSE)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(spNewLines, function(i) {
      l.coords <- slot(slot(i, "lines")[[1]], "Lines")[[1]]@coords
      l.coords <- l.coords[1:(nrow(l.coords) - 1), ]
      if (class(l.coords) != "matrix") {
          l.coords <- data.frame(x = l.coords[1], y = l.coords[2], 
              intersect = FALSE, linestart = TRUE, stringsAsFactors = FALSE)
      }
      else {
          l.coords <- data.frame(x = l.coords[, 1], y = l.coords[, 
              2], intersect = c(FALSE, rep(TRUE, nrow(l.coords) - 
              1)), linestart = c(TRUE, rep(FALSE, nrow(l.coords) - 
              1)), stringsAsFactors = FALSE)
      }
      return(l.coords)
  })
  where 3: do.call("rbind", lapply(spNewLines, function(i) {
      l.coords <- slot(slot(i, "lines")[[1]], "Lines")[[1]]@coords
      l.coords <- l.coords[1:(nrow(l.coords) - 1), ]
      if (class(l.coords) != "matrix") {
          l.coords <- data.frame(x = l.coords[1], y = l.coords[2], 
              intersect = FALSE, linestart = TRUE, stringsAsFactors = FALSE)
      }
      else {
          l.coords <- data.frame(x = l.coords[, 1], y = l.coords[, 
              2], intersect = c(FALSE, rep(TRUE, nrow(l.coords) - 
              1)), linestart = c(TRUE, rep(FALSE, nrow(l.coords) - 
              1)), stringsAsFactors = FALSE)
      }
      return(l.coords)
  }))
  where 4: getAllCoords()
  where 5: clgeo_CleanByPolygonation.Polygon(polygon, verbose)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(1:length(polygons), function(i) {
      out <- NULL
      polygon <- polygons[[i]]
      tempsp <- SpatialPolygons(Srl = list(Polygons(srl = list(polygon), 
          ID = "1")))
      po <- polygon
      isValid <- clgeo_IsValid(tempsp, verbose)
      if (!isValid) {
          po <- clgeo_CleanByPolygonation.Polygon(polygon, verbose)
      }
      if (!is.null(po)) {
          if (!is.list(po)) 
              po <- list(po)
          po <- po[!sapply(po, is.null)]
          po <- lapply(po, function(x) {
              outpo <- x
              if (nrow(unique(slot(x, "coords"))) < 3) 
                  outpo <- NULL
              return(outpo)
          })
          po <- po[!sapply(po, is.null)]
          if (!is.null(po) && length(po) > 0) {
              poly <- Polygons(srl = po, ID = as.character(ID))
              if (slot(poly, "area") > 0) 
                  out <- poly
              if (!is.null(out)) {
                  if (slot(poly, "area") >= (1/rgeos::getScale())) {
                    ID <<- ID + 1
                  }
                  else {
                    out <- NULL
                  }
              }
          }
      }
      return(out)
  })
  where 8: FUN(X[[i]], ...)
  where 9: lapply(sp@polygons, clgeo_CleanByPolygonation.Polygons, verbose)
  where 10: unlist(lapply(sp@polygons, clgeo_CleanByPolygonation.Polygons, 
      verbose))
  where 11: clgeo_CleanByPolygonation.SpatialPolygons(polygon, verbose)
  where 12: FUN(X[[i]], ...)
  where 13: lapply(X, FUN, ...)
  where 14: applyHandler(1:length(sp), function(x) {
      polygon <- slot(sp, "polygons")[[x]]
      ID <- slot(polygon, "ID")
      if (!all(is.na(nv))) {
          if (x %in% nv) {
              polygons <- slot(polygon, "Polygons")
              poly.nb <- length(polygons)
              removedHoles <- vector()
              if (poly.nb > 0) {
                  newpolygons <- list()
                  for (i in 1:poly.nb) {
                    if (slot(polygons[[i]], "hole")) {
                      if (dim(unique(slot(polygons[[i]], "coords")))[1] < 
                        3) {
                        if (length(removedHoles) == 0 & verbose) {
                          logger.info(sprintf("Cleaning orphaned holes at index %s", 
                            x))
                        }
                        removedHoles <- c(removedHoles, i)
                      }
                      else {
                        newpolygon <- polygons[[i]]
                        slot(newpolygon, "hole") <- TRUE
                        newpolygons <- c(newpolygons, newpolygon)
                      }
                    }
                    else {
                      newpolygon <- polygons[[i]]
                      slot(newpolygon, "hole") <- FALSE
                      newpolygons <- c(newpolygons, newpolygon)
                    }
                  }
                  slot(polygon, "Polygons") <- newpolygons
              }
              polygon <- SpatialPolygons(Srl = list(polygon))
              isValid <- report[x, ]$valid
              if (length(removedHoles) > 0) {
                  if (verbose) {
                    logger.info(sprintf("Checking geometry validity at index %s", 
                      x))
                  }
                  tryCatch({
                    slot(polygon, "polygons") <<- lapply(slot(polygon, 
                      "polygons"), checkPolygonsHoles)
                  }, warning = function(msg) {
                    if (verbose) 
                      logger.info(sprintf("Catched MAPTOOLS warning '%s'", 
                        msg))
                  }, error = function(err) {
                    if (verbose) 
                      logger.info(sprintf("Catched MAPTOOLS error '%s'", 
                        err))
                  })
                  isValid <<- clgeo_IsValid(polygon, verbose)
              }
              if (is.null(errors.only) & !isValid) {
                  if (verbose) {
                    report.msg <- NULL
                    if (!is.na(report[x, "error_msg"])) {
                      report.msg <- report[x, "error_msg"]
                    }
                    else if (!is.na(report[x, "warning_msg"])) {
                      report.msg <- report[x, "warning_msg"]
                    }
                    logger.info(sprintf("Cleaning geometry at index %s (%s)", 
                      x, report.msg))
                  }
                  if (strategy == "POLYGONATION") {
                    polygon <- clgeo_CleanByPolygonation.SpatialPolygons(polygon, 
                      verbose)
                  }
                  else if (strategy == "BUFFER") {
                    attempt <- 1
                    polygon <- gBuffer(polygon, id = ID, width = 0)
                    while (attempt < 3) {
                      if (!clgeo_IsValid(polygon, verbose)) {
                        attempt <- attempt + 1
                        polygon <- gBuffer(polygon, id = ID, width = 0)
                      }
                      else {
                        break
                      }
                    }
                  }
              }
              if (!is.null(polygon)) {
                  polygon <- polygon@polygons[[1]]
                  slot(polygon, "ID") <- ID
              }
              else {
                  if (verbose) {
                    logger.info(sprintf("Removing false polygon at index %s", 
                      x))
                  }
              }
          }
      }
      return(polygon)
  })
  where 15 at testthat/test_Clean.R#69: clgeo_Clean(sp)
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 26: test_code(desc, code, env = parent.frame())
  where 27 at testthat/test_Clean.R#66: test_that("Clean - 'bowtie' polygons", {
      wkt <- "POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))"
      sp <- rgeos::readWKT(wkt)
      sp.clean <- clgeo_Clean(sp)
      expect_false(gIsValid(sp))
      expect_true(gIsValid(sp.clean))
  })
  where 28: eval(code, test_env)
  where 29: eval(code, test_env)
  where 30: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 31: doTryCatch(return(expr), name, parentenv, handler)
  where 32: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 33: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 34: doTryCatch(return(expr), name, parentenv, handler)
  where 35: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 36: tryCatchList(expr, classes, parentenv, handlers)
  where 37: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 38: test_code(NULL, exprs, env)
  where 39: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 40: force(code)
  where 41: doWithOneRestart(return(expr), restart)
  where 42: withOneRestart(expr, restarts[[1L]])
  where 43: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 44: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 45: FUN(X[[i]], ...)
  where 46: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 47: force(code)
  where 48: doWithOneRestart(return(expr), restart)
  where 49: withOneRestart(expr, restarts[[1L]])
  where 50: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 51: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 52: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 53: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 54: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: test_check("cleangeo")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (i) 
  {
      l.coords <- slot(slot(i, "lines")[[1]], "Lines")[[1]]@coords
      l.coords <- l.coords[1:(nrow(l.coords) - 1), ]
      if (class(l.coords) != "matrix") {
          l.coords <- data.frame(x = l.coords[1], y = l.coords[2], 
              intersect = FALSE, linestart = TRUE, stringsAsFactors = FALSE)
      }
      else {
          l.coords <- data.frame(x = l.coords[, 1], y = l.coords[, 
              2], intersect = c(FALSE, rep(TRUE, nrow(l.coords) - 
              1)), linestart = c(TRUE, rep(FALSE, nrow(l.coords) - 
              1)), stringsAsFactors = FALSE)
      }
      return(l.coords)
  }
  <bytecode: 0x5362f68>
  <environment: 0x61bb7d8>
   --- function search by body ---
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1