Skip to content

Commit 3d98d0a

Browse files
authored
Clean up CRAN warnings (#848)
1 parent 668b6c0 commit 3d98d0a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

R/normalize-sp.R

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ sp_bbox <- function(x) {
8282
}
8383

8484
#' @export
85-
to_multipolygon_list.SpatialPolygons <- function(pgons) {
86-
lapply(pgons@polygons, to_multipolygon)
85+
to_multipolygon_list.SpatialPolygons <- function(x) {
86+
lapply(x@polygons, to_multipolygon)
8787
}
8888

8989
#' @export
90-
to_multipolygon.Polygons <- function(pgons) {
90+
to_multipolygon.Polygons <- function(x) {
91+
pgons <- x
9192
if (length(pgons@Polygons) > 1) {
9293
# If Polygons contains more than one Polygon, then we may be dealing with
9394
# a polygon with holes or a multipolygon (potentially with holes). We used
@@ -96,7 +97,7 @@ to_multipolygon.Polygons <- function(pgons) {
9697
comment <- comment(pgons)
9798
if (is.null(comment) || comment == "FALSE") {
9899
if (any(vapply(pgons@Polygons, methods::slot, logical(1), "hole"))) {
99-
if (!require("sf")) {
100+
if (!requireNamespace("sf")) {
100101
stop("You attempted to use an sp Polygons object that is missing hole ",
101102
"information. Leaflet can use the {sf} package to infer hole ",
102103
"assignments, but it is not installed. Please install the {sf} ",
@@ -107,7 +108,7 @@ to_multipolygon.Polygons <- function(pgons) {
107108
"assignments, but only with sf v1.0-10 and above. Please upgrade ",
108109
"the {sf} package, and try the operation again.")
109110
}
110-
x <- to_multipolygon_list(sf::st_geometry(sf::st_as_sf(SpatialPolygons(list(pgons)))))
111+
x <- to_multipolygon_list(sf::st_geometry(sf::st_as_sf(sp::SpatialPolygons(list(pgons)))))
111112
return(x[[1]])
112113
} else {
113114
comment <- paste(collapse = " ", rep_len("0", length(pgons@Polygons)))
@@ -127,21 +128,21 @@ to_multipolygon.Polygons <- function(pgons) {
127128
}
128129

129130
#' @export
130-
to_ring.Polygon <- function(pgon) {
131-
sp_coords(pgon)
131+
to_ring.Polygon <- function(x) {
132+
sp_coords(x)
132133
}
133134

134135
#' @export
135-
to_multipolygon_list.SpatialLines <- function(lines) {
136-
lapply(lines@lines, to_multipolygon)
136+
to_multipolygon_list.SpatialLines <- function(x) {
137+
lapply(x@lines, to_multipolygon)
137138
}
138139

139140
#' @export
140-
to_multipolygon.Lines <- function(lines) {
141-
lapply(lines@Lines, to_polygon)
141+
to_multipolygon.Lines <- function(x) {
142+
lapply(x@Lines, to_polygon)
142143
}
143144

144145
#' @export
145-
to_ring.Line <- function(line) {
146-
sp_coords(line)
146+
to_ring.Line <- function(x) {
147+
sp_coords(x)
147148
}

0 commit comments

Comments
 (0)