R package for downloading OpenStreetMap data

Restore the use of slot() and remove unused import from utils::read.table()

@mpadge: There are some conditions under which x <- x@polygons does not
give the same result as x <- slot (x, "polygons"), and that the latter is
a more stable and thus preferable.

+33 -35
+1
DESCRIPTION
··· 32 32 Imports: 33 33 curl, 34 34 httr2, 35 + methods, 35 36 Rcpp (>= 0.12.4), 36 37 rvest, 37 38 tibble,
+1 -1
NAMESPACE
··· 45 45 export(unique_osmdata) 46 46 export(unname_osmdata_sf) 47 47 importFrom(Rcpp,evalCpp) 48 + importFrom(methods,slot) 48 49 importFrom(utils,browseURL) 49 - importFrom(utils,read.table) 50 50 useDynLib(osmdata, .registration = TRUE)
+1 -1
R/opq.R
··· 710 710 # nocov start 711 711 u <- paste0 ("https://openstreetmap.org/", type [1], "/", id) 712 712 for (i in u) { 713 - browseURL (i) 713 + utils::browseURL (i) 714 714 } 715 715 # nocov end 716 716 }
+2 -1
R/osmdata-package.R
··· 50 50 #' @family package 51 51 #' @author Joan Maspons, Mark Padgham, Bob Rudis, Robin Lovelace, Maëlle Salmon 52 52 #' @keywords internal 53 + #' @importFrom methods slot 53 54 #' @importFrom Rcpp evalCpp 54 - #' @importFrom utils browseURL read.table 55 + #' @importFrom utils browseURL 55 56 #' @useDynLib osmdata, .registration = TRUE 56 57 "_PACKAGE"
+3 -3
R/trim-osmdata.R
··· 154 154 #' @export 155 155 bb_poly_to_mat.SpatialPolygonsDataFrame <- function (x) { # nolint 156 156 157 - x <- x@polygons 157 + x <- slot (x, "polygons") 158 158 if (length (x) > 1) { 159 159 more_than_one () 160 160 } 161 - x <- x [[1]]@Polygons 161 + x <- slot (x [[1]], "Polygons") 162 162 if (length (x) > 1) { 163 163 more_than_one () 164 164 } 165 - x [[1]]@coords 165 + slot (x [[1]], "coords") 166 166 } 167 167 168 168 #' @export
+11 -11
R/unique-osmdata.R
··· 79 79 #' @noRd 80 80 unique_points_sp <- function (dat) { 81 81 82 - pts <- rownames (dat$osm_points@data) 82 + pts <- rownames (slot (dat$osm_points, "data")) 83 83 84 - lns <- dat$osm_lines@lines 84 + lns <- slot (dat$osm_lines, "lines") 85 85 lns_pts <- lapply (lns, function (i) { 86 - rownames (i@Lines [[1]]@coords) 86 + rownames (slot (slot (i, "Lines") [[1]], "coords")) 87 87 }) 88 88 lns_pts <- unlist (lns_pts) 89 89 names (lns_pts) <- NULL 90 90 lns_pts <- unique (lns_pts) 91 91 92 - polys <- dat$osm_polygons@polygons 92 + polys <- slot (dat$osm_polygons, "polygons") 93 93 poly_pts <- lapply (polys, function (i) { 94 - rownames (i@Polygons [[1]]@coords) 94 + rownames (slot (slot (i, "Polygons") [[1]], "coords")) 95 95 }) 96 96 poly_pts <- unlist (poly_pts) 97 97 names (poly_pts) <- NULL ··· 119 119 #' @noRd 120 120 unique_lines_sp <- function (dat) { 121 121 122 - lns <- rownames (dat$osm_lines@data) 122 + lns <- rownames (slot (dat$osm_lines, "data")) 123 123 124 - mlns <- dat$osm_multilines@lines [[1]] 125 - mlns <- names (mlns@Lines) 124 + mlns <- slot (dat$osm_multilines, "lines") [[1]] 125 + mlns <- names (slot (mlns, "Lines")) 126 126 mlns <- unique (mlns) 127 127 128 128 which (!lns %in% mlns) ··· 149 149 #' @noRd 150 150 unique_polygons_sp <- function (dat) { 151 151 152 - polys <- rownames (dat$osm_polygons@data) 152 + polys <- rownames (slot (dat$osm_polygons, "data")) 153 153 154 - mpolys <- dat$osm_multipolygon@polygons 154 + mpolys <- slot (dat$osm_multipolygons, "polygons") 155 155 mpolys <- unlist (lapply (mpolys, function (i) { 156 - names (i@Polygons) 156 + names (slot (i, "Polygons")) 157 157 })) 158 158 names (mpolys) <- NULL 159 159 mpolys <- unique (mpolys)
+14 -18
codemeta.json
··· 4 4 "identifier": "osmdata", 5 5 "description": "Download and import of 'OpenStreetMap' ('OSM') data as 'sf' or 'sp' objects. 'OSM' data are extracted from the 'Overpass' web server (<https://overpass-api.de/>) and processed with very fast 'C++' routines for return to 'R'.", 6 6 "name": "osmdata: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects", 7 - "relatedLink": [ 8 - "https://docs.ropensci.org/osmdata/", 9 - "https://CRAN.R-project.org/package=osmdata" 10 - ], 7 + "relatedLink": ["https://docs.ropensci.org/osmdata/", "https://CRAN.R-project.org/package=osmdata"], 11 8 "codeRepository": "https://github.com/ropensci/osmdata", 12 9 "issueTracker": "https://github.com/ropensci/osmdata/issues", 13 10 "license": "https://spdx.org/licenses/GPL-3.0", ··· 257 254 }, 258 255 "4": { 259 256 "@type": "SoftwareApplication", 257 + "identifier": "methods", 258 + "name": "methods" 259 + }, 260 + "5": { 261 + "@type": "SoftwareApplication", 260 262 "identifier": "Rcpp", 261 263 "name": "Rcpp", 262 264 "version": ">= 0.12.4", ··· 268 270 }, 269 271 "sameAs": "https://CRAN.R-project.org/package=Rcpp" 270 272 }, 271 - "5": { 273 + "6": { 272 274 "@type": "SoftwareApplication", 273 275 "identifier": "rvest", 274 276 "name": "rvest", ··· 280 282 }, 281 283 "sameAs": "https://CRAN.R-project.org/package=rvest" 282 284 }, 283 - "6": { 285 + "7": { 284 286 "@type": "SoftwareApplication", 285 287 "identifier": "tibble", 286 288 "name": "tibble", ··· 292 294 }, 293 295 "sameAs": "https://CRAN.R-project.org/package=tibble" 294 296 }, 295 - "7": { 297 + "8": { 296 298 "@type": "SoftwareApplication", 297 299 "identifier": "utils", 298 300 "name": "utils" 299 301 }, 300 - "8": { 302 + "9": { 301 303 "@type": "SoftwareApplication", 302 304 "identifier": "xml2", 303 305 "name": "xml2", ··· 309 311 }, 310 312 "sameAs": "https://CRAN.R-project.org/package=xml2" 311 313 }, 312 - "SystemRequirements": {} 314 + "SystemRequirements": null 313 315 }, 314 316 "applicationCategory": "DataAccess", 315 317 "isPartOf": "https://ropensci.org", 316 318 "keywords": ["open0street0map", "openstreetmap", "overpass0API", "OSM", "overpass-api", "r", "cpp", "rstats", "osm", "osm-data", "r-package", "peer-reviewed"], 317 - "fileSize": "38074.553KB", 319 + "fileSize": "38075.219KB", 318 320 "citation": [ 319 321 { 320 322 "@type": "ScholarlyArticle", ··· 348 350 "issueNumber": "14", 349 351 "datePublished": "2017", 350 352 "isPartOf": { 351 - "@type": [ 352 - "PublicationVolume", 353 - "Periodical" 354 - ], 353 + "@type": ["PublicationVolume", "Periodical"], 355 354 "volumeNumber": "2", 356 355 "name": "Journal of Open Source Software" 357 356 } ··· 360 359 ], 361 360 "releaseNotes": "https://github.com/ropensci/osmdata/blob/main/NEWS.md", 362 361 "readme": "https://github.com/ropensci/osmdata/blob/main/README.md", 363 - "contIntegration": [ 364 - "https://github.com/ropensci/osmdata/actions?query=workflow%3AR-CMD-check", 365 - "https://app.codecov.io/gh/ropensci/osmdata" 366 - ], 362 + "contIntegration": ["https://github.com/ropensci/osmdata/actions?query=workflow%3AR-CMD-check", "https://app.codecov.io/gh/ropensci/osmdata"], 367 363 "developmentStatus": "https://www.repostatus.org/#active", 368 364 "review": { 369 365 "@type": "Review",