@@ -75,7 +75,8 @@ osmdata_data_frame <- function (q,
75
75
colClasses = " character" , # osm_id doesn't fit in integer
76
76
check.names = FALSE ,
77
77
comment.char = " " ,
78
- stringsAsFactors = stringsAsFactors
78
+ stringsAsFactors = stringsAsFactors ,
79
+ encoding = " UTF-8"
79
80
)
80
81
} else if (isTRUE (obj $ meta $ query_type == " adiff" )) {
81
82
datetime_from <- obj $ meta $ datetime_from
@@ -122,13 +123,15 @@ xml_to_df <- function (doc, stringsAsFactors = FALSE) {
122
123
123
124
tags <- mapply (function (i , k ) {
124
125
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 )
125
132
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
132
135
)
133
136
out [, names (i )] <- i
134
137
return (out )
@@ -214,6 +217,7 @@ xml_adiff_to_df <- function (doc,
214
217
tags_u <- xml2 :: xml_find_all (osm_actions , xpath = " .//tag" )
215
218
col_names <- sort (unique (xml2 :: xml_attr (tags_u , attr = " k" )))
216
219
m <- matrix (
220
+ NA_character_ ,
217
221
nrow = length (osm_obj ), ncol = length (col_names ),
218
222
dimnames = list (NULL , col_names )
219
223
)
@@ -225,6 +229,7 @@ xml_adiff_to_df <- function (doc,
225
229
tagV <- vapply (tag , function (x ) x , FUN.VALUE = character (2 ))
226
230
m [i , tagV [1 , ]] <- tagV [2 , ]
227
231
}
232
+ m <- enc2utf8 (m )
228
233
229
234
osm_type <- xml2 :: xml_name (osm_obj )
230
235
osm_id <- xml2 :: xml_attr (osm_obj , " id" )
@@ -325,6 +330,7 @@ get_meta_from_xml <- function (osm_obj) {
325
330
osm_uid = xml2 :: xml_attr (osm_obj , attr = " uid" ),
326
331
osm_user = xml2 :: xml_attr (osm_obj , attr = " user" )
327
332
)
333
+ out $ osm_user <- enc2utf8 (out $ osm_user )
328
334
329
335
} else {
330
336
out <- matrix (nrow = length (osm_obj ), ncol = 0 )
0 commit comments