Skip to content

Commit 513a5ed

Browse files
committed
fix merge conflict
2 parents 473f8d9 + c4bd595 commit 513a5ed

9 files changed

+54
-40
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: osmdata
22
Title: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects
3-
Version: 0.2.5.022
3+
Version: 0.2.5.023
44
Authors@R: c(
55
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
66
person("Bob", "Rudis", role = "aut"),

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
along with geometries (#338 thanks to @RegularnaMatrica)
1313
- Mention key-only feature requests in README (#342 thanks to @joostschouppe)
1414
- Merge any columns in `osmdata_sf()` with mixed-case duplicated names (#348)
15+
- Set encoding to UTF-8 for tags and user names (#347)
1516

1617

1718
0.2.5

R/get-osmdata-df.R

+13-7
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ osmdata_data_frame <- function (q,
7575
colClasses = "character", # osm_id doesn't fit in integer
7676
check.names = FALSE,
7777
comment.char = "",
78-
stringsAsFactors = stringsAsFactors
78+
stringsAsFactors = stringsAsFactors,
79+
encoding = "UTF-8"
7980
)
8081
} else if (isTRUE (obj$meta$query_type == "adiff")) {
8182
datetime_from <- obj$meta$datetime_from
@@ -122,13 +123,15 @@ xml_to_df <- function (doc, stringsAsFactors = FALSE) {
122123

123124
tags <- mapply (function (i, k) {
124125
i <- i [, k, drop = FALSE] # remove osm_id column if exists
126+
out <- matrix (
127+
NA_character_,
128+
nrow = nrow (i), ncol = length (keys),
129+
dimnames = list (NULL, keys)
130+
)
131+
out <- enc2utf8 (out)
125132
out <- data.frame (
126-
matrix (
127-
nrow = nrow (i), ncol = length (keys),
128-
dimnames = list (NULL, keys)
129-
),
130-
stringsAsFactors = stringsAsFactors,
131-
check.names = FALSE
133+
out,
134+
stringsAsFactors = stringsAsFactors, check.names = FALSE
132135
)
133136
out [, names (i)] <- i
134137
return (out)
@@ -214,6 +217,7 @@ xml_adiff_to_df <- function (doc,
214217
tags_u <- xml2::xml_find_all (osm_actions, xpath = ".//tag")
215218
col_names <- sort (unique (xml2::xml_attr (tags_u, attr = "k")))
216219
m <- matrix (
220+
NA_character_,
217221
nrow = length (osm_obj), ncol = length (col_names),
218222
dimnames = list (NULL, col_names)
219223
)
@@ -225,6 +229,7 @@ xml_adiff_to_df <- function (doc,
225229
tagV <- vapply (tag, function (x) x, FUN.VALUE = character (2))
226230
m [i, tagV [1, ]] <- tagV [2, ]
227231
}
232+
m <- enc2utf8 (m)
228233

229234
osm_type <- xml2::xml_name (osm_obj)
230235
osm_id <- xml2::xml_attr (osm_obj, "id")
@@ -325,6 +330,7 @@ get_meta_from_xml <- function (osm_obj) {
325330
osm_uid = xml2::xml_attr (osm_obj, attr = "uid"),
326331
osm_user = xml2::xml_attr (osm_obj, attr = "user")
327332
)
333+
out$osm_user <- enc2utf8 (out$osm_user)
328334

329335
} else {
330336
out <- matrix (nrow = length (osm_obj), ncol = 0)

R/get-osmdata-sc.R

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ osmdata_sc <- function (q, doc, quiet = TRUE) {
7575
overpass_version = temp$obj$meta$overpass_version
7676
)
7777

78+
has_tags <- c ("nodes", "relation_properties", "object")
79+
obj [has_tags] <- lapply(obj [has_tags], function (x) {
80+
x [, c ("key", "value")] <- setenc_utf8 (x [, c ("key", "value")])
81+
x
82+
})
83+
7884
if (!missing (q)) {
7985
if (!is.character (q)) {
8086
obj$meta$bbox <- q$bbox

R/get-osmdata-sf.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ osmdata_sf <- function (q, doc, quiet = TRUE, stringsAsFactors = FALSE) { # noli
6262
if (!"osm_id" %in% names (res$polygons_kv) [1]) {
6363
res <- fill_kv (res, "polygons_kv", "polygons", stringsAsFactors)
6464
}
65-
kv_df <- grep ("_kv$", names (res))
65+
kv_df <- grep ("_kv$", names (res)) # objects with tags
6666
res [kv_df] <- fix_columns_list (res [kv_df])
67+
res [kv_df] <- lapply (res [kv_df], setenc_utf8)
6768

6869
if (missing (q)) {
6970
obj$bbox <- paste (res$bbox, collapse = " ")

R/get-osmdata-sp.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ osmdata_sp <- function (q, doc, quiet = TRUE) {
7171
obj$osm_multipolygons <- res$multipolygons
7272

7373
osm_items <- grep ("^osm_", names (obj))
74-
obj[osm_items] <- fix_columns_list (obj[osm_items])
74+
obj [osm_items] <- fix_columns_list (obj [osm_items])
75+
obj [osm_items] <- lapply (obj [osm_items], function (x) {
76+
x@data <- setenc_utf8 (x@data)
77+
x
78+
})
7579
class (obj) <- c (class (obj), "osmdata_sp")
7680

7781
return (obj)

R/get-osmdata.R

+16
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,19 @@ get_center_from_cpp_output <- function (res, what = "points") {
344344

345345
return (as.data.frame (this))
346346
}
347+
348+
349+
#' Set encoding to UTF-8
350+
#'
351+
#' @param x a data.frame or a list.
352+
#'
353+
#' @return `x` with all the columns or items of type character with UTF-8 encoding set.
354+
#' @noRd
355+
setenc_utf8 <- function (x) {
356+
char_cols <- which (vapply (x, is.character, FUN.VALUE = logical (1)))
357+
x [char_cols] <- lapply (x [char_cols], function (y) {
358+
enc2utf8 (y)
359+
})
360+
361+
return (x)
362+
}

R/getbb.R

+2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ getbb <- function (place_name,
229229
)
230230

231231
if (format_out == "data.frame") {
232+
utf8cols <- c ("licence", "name", "display_name")
233+
obj [, utf8cols] <- setenc_utf8 (obj [, utf8cols])
232234
return (obj)
233235
}
234236

codemeta.json

+8-30
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44
"identifier": "osmdata",
55
"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'.",
66
"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"],
118
"codeRepository": "https://github.com/ropensci/osmdata/",
129
"issueTracker": "https://github.com/ropensci/osmdata/issues",
1310
"license": "https://spdx.org/licenses/GPL-3.0",
14-
"version": "0.2.5.022",
11+
"version": "0.2.5.23",
1512
"programmingLanguage": {
1613
"@type": "ComputerLanguage",
1714
"name": "R",
1815
"url": "https://r-project.org"
1916
},
20-
"runtimePlatform": "R version 4.3.1 (2023-06-16)",
17+
"runtimePlatform": "R version 4.4.1 (2024-06-14)",
2118
"provider": {
2219
"@id": "https://cran.r-project.org",
2320
"@type": "Organization",
@@ -348,25 +345,12 @@
348345
},
349346
"sameAs": "https://CRAN.R-project.org/package=xml2"
350347
},
351-
"SystemRequirements": {}
348+
"SystemRequirements": null
352349
},
353350
"applicationCategory": "DataAccess",
354351
"isPartOf": "https://ropensci.org",
355-
"keywords": [
356-
"open0street0map",
357-
"openstreetmap",
358-
"overpass0API",
359-
"OSM",
360-
"overpass-api",
361-
"r",
362-
"cpp",
363-
"rstats",
364-
"osm",
365-
"osm-data",
366-
"r-package",
367-
"peer-reviewed"
368-
],
369-
"fileSize": "2467.715KB",
352+
"keywords": ["open0street0map", "openstreetmap", "overpass0API", "OSM", "overpass-api", "r", "cpp", "rstats", "osm", "osm-data", "r-package", "peer-reviewed"],
353+
"fileSize": "17525.157KB",
370354
"citation": [
371355
{
372356
"@type": "ScholarlyArticle",
@@ -400,10 +384,7 @@
400384
"issueNumber": "14",
401385
"datePublished": "2017",
402386
"isPartOf": {
403-
"@type": [
404-
"PublicationVolume",
405-
"Periodical"
406-
],
387+
"@type": ["PublicationVolume", "Periodical"],
407388
"volumeNumber": "2",
408389
"name": "Journal of Open Source Software"
409390
}
@@ -412,10 +393,7 @@
412393
],
413394
"releaseNotes": "https://github.com/ropensci/osmdata/blob/master/NEWS.md",
414395
"readme": "https://github.com/ropensci/osmdata/blob/main/README.md",
415-
"contIntegration": [
416-
"https://github.com/ropensci/osmdata/actions?query=workflow%3AR-CMD-check",
417-
"https://app.codecov.io/gh/ropensci/osmdata"
418-
],
396+
"contIntegration": ["https://github.com/ropensci/osmdata/actions?query=workflow%3AR-CMD-check", "https://app.codecov.io/gh/ropensci/osmdata"],
419397
"developmentStatus": "https://www.repostatus.org/#active",
420398
"review": {
421399
"@type": "Review",

0 commit comments

Comments
 (0)