mdsumner / gibble

Compare 78269c4 ... +1 ... 3d3a983

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 5 files from the diff.
Other files ignored by Codecov
gibble.Rproj has changed.
NEWS.md has changed.
DESCRIPTION has changed.

@@ -1,50 +1,64 @@
Loading
1 -
#' @name gibble
2 -
#' @export
3 -
gibble.POINT <- function(x, ...) {x <- tibble::as_tibble(ibble(x)); dplyr::mutate(x, type = names(types)[x$type])}
4 -
#' @name gibble
5 -
#' @export
6 -
gibble.MULTIPOINT <- function(x, ...) {dm <- dim(unclass(x)); tibble::tibble(nrow = dm[1], ncol = dm[2])} %>% dplyr::mutate(type = "MULTIPOINT")
7 -
#' @name gibble
8 -
#' @export
9 -
gibble.LINESTRING  <- function(x, ...) {dm <- dim(unclass(x)); tibble::tibble(nrow = dm[1], ncol = dm[2])} %>% dplyr::mutate(type = "LINESTRING")
10 -
#' @name gibble
11 -
#' @export
12 -
gibble.MULTILINESTRING <- function(x, ...) lapply(unclass(x), gibble.MULTIPOINT) %>% dplyr::bind_rows() %>% dplyr::mutate(type = "MULTILINESTRING")
13 -
#' @name gibble
14 -
#' @export
15 -
gibble.POLYGON <- function(x, ...) lapply(unclass(x), gibble.MULTIPOINT) %>% dplyr::bind_rows() %>% dplyr::mutate(type = "POLYGON")
16 -
gibble.POLYPART <- function(x, subobject = 1L, ...) {
17 -
  lapply(x, gibble.MULTIPOINT) %>%
18 -
    dplyr::bind_rows() %>%
19 -
    dplyr::mutate(subobject = subobject)
20 -
}
21 -
#' @name gibble
22 -
#' @export
23 -
gibble.MULTIPOLYGON <- function(x, ...) {
24 -
  x <- unclass(x)
25 -
  lapply(seq_along(x), function(a) gibble.POLYPART(x[[a]], subobject = a)) %>%
26 -
    dplyr::bind_rows() %>%
27 -
    dplyr::mutate(type = "MULTIPOLYGON")
28 -
}
29 -
#' @name gibble
30 -
#' @export
31 -
gibble.list <- function(x, ...) {
32 -
  ## this is a bit heinous, but basically we've been given an unclassed list
33 -
  ## and it *might* be a sfc, and some time in the future we will need a more
34 -
  ## nuanced approach to list-cols, because note that not only do we
35 -
  ## not have have other ibble class-methods, we are not dispatching on sfc here ...
36 -
  out <- try(ibble.sfc(x), silent = TRUE)
37 -
  if (inherits(out, "try-error")) stop("we tried to interpret as an sf/sfc list-column but failed")
38 -
  dplyr::mutate(tibble::as_tibble(out), type = names(types)[out[, "type", drop = TRUE]])
39 -
}
40 -
#' @name gibble
41 -
#' @export
42 -
gibble.sfc <- function(x, ...) {
43 -
  x <- tibble::as_tibble(ibble(x))
44 -
  dplyr::mutate(x, type = names(types)[x$type])
45 -
}
46 -
#' @name gibble
47 -
#' @export
48 -
gibble.sf <- function(x, ...) {
49 -
  gibble(x[[attr(x, "sf_column")]])
50 -
}
1 +
#' @name gibble
2 +
#' @export
3 +
gibble.POINT <- function(x, ...) {x <- tibble::as_tibble(ibble(x)); dplyr::mutate(x, type = names(types)[x$type])}
4 +
#' @name gibble
5 +
#' @export
6 +
gibble.MULTIPOINT <- function(x, ...) {dm <- dim(unclass(x)); tibble::tibble(nrow = dm[1], ncol = dm[2])} %>% dplyr::mutate(type = "MULTIPOINT")
7 +
#' @name gibble
8 +
#' @export
9 +
gibble.LINESTRING  <- function(x, ...) {dm <- dim(unclass(x)); tibble::tibble(nrow = dm[1], ncol = dm[2])} %>% dplyr::mutate(type = "LINESTRING")
10 +
#' @name gibble
11 +
#' @export
12 +
gibble.MULTILINESTRING <- function(x, ...) lapply(unclass(x), gibble.MULTIPOINT) %>% dplyr::bind_rows() %>% dplyr::mutate(type = "MULTILINESTRING")
13 +
#' @name gibble
14 +
#' @export
15 +
gibble.POLYGON <- function(x, ...) lapply(unclass(x), gibble.MULTIPOINT) %>% dplyr::bind_rows() %>% dplyr::mutate(type = "POLYGON")
16 +
gibble.POLYPART <- function(x, subobject = 1L, ...) {
17 +
  lapply(x, gibble.MULTIPOINT) %>%
18 +
    dplyr::bind_rows() %>%
19 +
    dplyr::mutate(subobject = subobject)
20 +
}
21 +
#' @name gibble
22 +
#' @export
23 +
gibble.MULTIPOLYGON <- function(x, ...) {
24 +
  x <- unclass(x)
25 +
  lapply(seq_along(x), function(a) gibble.POLYPART(x[[a]], subobject = a)) %>%
26 +
    dplyr::bind_rows() %>%
27 +
    dplyr::mutate(type = "MULTIPOLYGON")
28 +
}
29 +
#' @name gibble
30 +
#' @export
31 +
gibble.list <- function(x, ...) {
32 +
  ## this is a bit heinous, but basically we've been given an unclassed list
33 +
  ## and it *might* be a sfc, and some time in the future we will need a more
34 +
  ## nuanced approach to list-cols, because note that not only do we
35 +
  ## not have have other ibble class-methods, we are not dispatching on sfc here ...
36 +
  out <- try(ibble.sfc(x), silent = TRUE)
37 +
  if (inherits(out, "try-error")) stop("we tried to interpret as an sf/sfc list-column but failed")
38 +
  dplyr::mutate(tibble::as_tibble(out), type = names(types)[out[, "type", drop = TRUE]])
39 +
}
40 +
#' @name gibble
41 +
#' @export
42 +
gibble.sfc <- function(x, ...) {
43 +
44 +
  xout <- tibble::as_tibble(ibble(x))
45 +
46 +
   ## handle unknown type, which we presume is GEOMETRYCOLLECTION
47 +
  if (xout[["type"]][1L] == 11L) {
48 +
    classes <- unlist(lapply(x, function(xa) lapply(xa, function(xb) rev(class(xb))[2L])))
49 +
    if (length(classes) == dim(xout)[1L]) {
50 +
      xout[["type"]] <- classes
51 +
    }
52 +
  }
53 +
  if (is.numeric(xout[["type"]][1L])) {
54 +
    xout[["type"]] <- names(types)[xout[["type"]]]
55 +
  }
56 +
57 +
  xout
58 +
}
59 +
#' @name gibble
60 +
#' @export
61 +
gibble.sf <- function(x, ...) {
62 +
  gibble(x[[attr(x, "sf_column")]])
63 +
}
64 +

@@ -1,43 +1,57 @@
Loading
1 -
types <- c(POINT = 1L, MULTIPOINT = 2L, LINESTRING = 3L, MULTILINESTRING = 4L, POLYGON = 5L, MULTIPOLYGON = 6L, Polygons = 7L, Lines = 8L, Points = 9L, MultiPoints = 10L)
2 -
3 -
ibble.POINT <- function(x, ...) cbind(nrow = 1, ncol = length(unclass(x)), type = 1L)
4 -
ibble.MULTITHING <- function(x, ...) {dm <- dim(unclass(x)); if (is.null(dm)) {dm <- cbind(0, 0)};  cbind(nrow = dm[1L], ncol = dm[2], type = 2L)}
5 -
ibble.MULTIPOINT <- function(x, ...) {dm <- dim(unclass(x)); cbind(nrow = rep(1L, dm[1]), ncol = dm[2], type = 2L)}
6 -
ibble.LINESTRING  <- function(x, ...) {dm <- dim(unclass(x)); cbind(nrow = dm[1], ncol = dm[2], type = 3L)}
7 -
8 -
9 -
ibble.MULTILINESTRING <- function(x, ...) {
10 -
  out <- do.call(rbind, lapply(unclass(x), ibble.MULTITHING))
11 -
  out <- cbind(out, subobject =  1L)
12 -
  out[, "type"] <- 4L
13 -
  out
14 -
}
15 -
ibble.POLYGON <- function(x, ...) {
16 -
  out <- cbind(do.call(rbind, lapply(unclass(x), ibble.MULTITHING)), subobject = 1L)
17 -
  ## untested, but works for multipolygon
18 -
  if (length(out) == 0L) out <- cbind(nrow = 0, ncol = NA_integer_, type = NA_integer_)
19 -
  out[, "type"] <- 5L
20 -
  out
21 -
}
22 -
ibble.POLYPART <- function(x, subobject = 1L, ...) {
23 -
 out <- do.call(rbind, lapply(x, ibble.MULTITHING))
24 -
25 -
 cbind(out, subobject = subobject)
26 -
}
27 -
ibble.MULTIPOLYGON <- function(x, ...) {
28 -
  x <- unclass(x)
29 -
  out <- do.call(rbind, lapply(seq_along(x), function(a) ibble.POLYPART(x[[a]], subobject = a)))
30 -
  if (length(out) == 0L) out <- cbind(nrow = 0, ncol = NA_integer_, type = NA_integer_, subobject = 1L)
31 -
  out[, "type"] <- 6L
32 -
  out
33 -
}
34 -
35 -
ibble.sfc <- function(x, ...) {
36 -
  x <- unclass(x)
37 -
  out <- do.call(rbind,lapply(seq_along(x), function(gi) cbind(ibble(x[[gi]]), object = gi)))
38 -
  out
39 -
}
40 -
ibble.sf <- function(x, ...) {
41 -
  ibble(x[[attr(x, "sf_column")]])
42 -
}
43 -
1 +
types <- c(POINT = 1L, MULTIPOINT = 2L, LINESTRING = 3L,
2 +
           MULTILINESTRING = 4L, POLYGON = 5L, MULTIPOLYGON = 6L,
3 +
           Polygons = 7L, Lines = 8L, Points = 9L, MultiPoints = 10L,
4 +
           UNKNOWN = 11L)
5 +
6 +
ibble.POINT <- function(x, ...) cbind(nrow = 1, ncol = length(unclass(x)), type = 1L)
7 +
ibble.MULTITHING <- function(x, ...) {dm <- dim(unclass(x)); if (is.null(dm)) {dm <- cbind(0, 0)};  cbind(nrow = dm[1L], ncol = dm[2], type = 2L)}
8 +
ibble.MULTIPOINT <- function(x, ...) {dm <- dim(unclass(x)); cbind(nrow = rep(1L, dm[1]), ncol = dm[2], type = 2L)}
9 +
ibble.LINESTRING  <- function(x, ...) {dm <- dim(unclass(x)); cbind(nrow = dm[1], ncol = dm[2], type = 3L)}
10 +
11 +
12 +
ibble.MULTILINESTRING <- function(x, ...) {
13 +
  out <- do.call(rbind, lapply(unclass(x), ibble.MULTITHING))
14 +
  out <- cbind(out, subobject =  1L)
15 +
  out[, "type"] <- 4L
16 +
  out
17 +
}
18 +
ibble.POLYGON <- function(x, ...) {
19 +
  out <- cbind(do.call(rbind, lapply(unclass(x), ibble.MULTITHING)), subobject = 1L)
20 +
  ## untested, but works for multipolygon
21 +
  if (length(out) == 0L) out <- cbind(nrow = 0, ncol = NA_integer_, type = NA_integer_)
22 +
  out[, "type"] <- 5L
23 +
  out
24 +
}
25 +
ibble.POLYPART <- function(x, subobject = 1L, ...) {
26 +
 out <- do.call(rbind, lapply(x, ibble.MULTITHING))
27 +
28 +
 cbind(out, subobject = subobject)
29 +
}
30 +
ibble.MULTIPOLYGON <- function(x, ...) {
31 +
  x <- unclass(x)
32 +
  out <- do.call(rbind, lapply(seq_along(x), function(a) ibble.POLYPART(x[[a]], subobject = a)))
33 +
  if (length(out) == 0L) out <- cbind(nrow = 0, ncol = NA_integer_, type = NA_integer_, subobject = 1L)
34 +
  out[, "type"] <- 6L
35 +
  out
36 +
}
37 +
ibble.sfc_GEOMETRYCOLLECTION <- function(x, ...) {
38 +
#  browser()
39 +
    out <- do.call(rbind, lapply(seq_along(x), function(xi) do.call(rbind, lapply(unlist(x[[xi]], recursive = FALSE),
40 +
                                                                   function(xa) cbind(ibble.LINESTRING(xa), object  = xi)))))
41 +
    out[, "type"] <- 11L
42 +
    out
43 +
}
44 +
ibble.GEOMETRYCOLLECTION <- function(x, ...) {
45 +
  out <- do.call(rbind, lapply(x, function(xa) lapply(xa, ibble.POLYPART)))
46 +
  out[, "type"] <- 11L
47 +
  out
48 +
}
49 +
ibble.sfc <- function(x, ...) {
50 +
  x <- unclass(x)
51 +
  out <- do.call(rbind,lapply(seq_along(x), function(gi) cbind(ibble(x[[gi]]), object = gi)))
52 +
  out
53 +
}
54 +
ibble.sf <- function(x, ...) {
55 +
  ibble(x[[attr(x, "sf_column")]])
56 +
}
57 +

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R/gibble-sf.R -2.78% 58.33%
R/gibble-silicate.R 83.33%
R/gibble-sp-comment.R 0.00%
R/gibble-sp.R 66.67%
R/gibble.R 50.00%
R/ibble-sf.R -14.20% 46.67%
R/ibble-sp.R 0.00%
Project Totals (7 files) 45.45%
Loading