@@ -82,12 +82,13 @@ sp_bbox <- function(x) {
82
82
}
83
83
84
84
# ' @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 )
87
87
}
88
88
89
89
# ' @export
90
- to_multipolygon.Polygons <- function (pgons ) {
90
+ to_multipolygon.Polygons <- function (x ) {
91
+ pgons <- x
91
92
if (length(pgons @ Polygons ) > 1 ) {
92
93
# If Polygons contains more than one Polygon, then we may be dealing with
93
94
# a polygon with holes or a multipolygon (potentially with holes). We used
@@ -96,7 +97,7 @@ to_multipolygon.Polygons <- function(pgons) {
96
97
comment <- comment(pgons )
97
98
if (is.null(comment ) || comment == " FALSE" ) {
98
99
if (any(vapply(pgons @ Polygons , methods :: slot , logical (1 ), " hole" ))) {
99
- if (! require (" sf" )) {
100
+ if (! requireNamespace (" sf" )) {
100
101
stop(" You attempted to use an sp Polygons object that is missing hole " ,
101
102
" information. Leaflet can use the {sf} package to infer hole " ,
102
103
" assignments, but it is not installed. Please install the {sf} " ,
@@ -107,7 +108,7 @@ to_multipolygon.Polygons <- function(pgons) {
107
108
" assignments, but only with sf v1.0-10 and above. Please upgrade " ,
108
109
" the {sf} package, and try the operation again." )
109
110
}
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 )))))
111
112
return (x [[1 ]])
112
113
} else {
113
114
comment <- paste(collapse = " " , rep_len(" 0" , length(pgons @ Polygons )))
@@ -127,21 +128,21 @@ to_multipolygon.Polygons <- function(pgons) {
127
128
}
128
129
129
130
# ' @export
130
- to_ring.Polygon <- function (pgon ) {
131
- sp_coords(pgon )
131
+ to_ring.Polygon <- function (x ) {
132
+ sp_coords(x )
132
133
}
133
134
134
135
# ' @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 )
137
138
}
138
139
139
140
# ' @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 )
142
143
}
143
144
144
145
# ' @export
145
- to_ring.Line <- function (line ) {
146
- sp_coords(line )
146
+ to_ring.Line <- function (x ) {
147
+ sp_coords(x )
147
148
}
0 commit comments