Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed May 24, 2024
1 parent cc5df9c commit 76c927d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/names.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ setMethod("names", signature(x="SpatRasterCollection"),
setMethod("names<-", signature(x="SpatRasterCollection"),
function(x, value) {
x@ptr <- x@ptr$deepcopy()
if (is.null(value)) {
value <- rep("", length(x))
}
x@ptr$names <- enc2utf8(as.character(value))
x
}
Expand Down Expand Up @@ -99,6 +102,9 @@ setMethod("names", signature(x="SpatRasterDataset"),
setMethod("names<-", signature(x="SpatRasterDataset"),
function(x, value) {
x@ptr <- x@ptr$deepcopy()
if (is.null(value)) {
value <- rep("", length(x))
}
x@ptr$names <- enc2utf8(as.character(value))
x
}
Expand Down Expand Up @@ -154,6 +160,7 @@ setMethod("names<-", signature(x="SpatVector"),
if (length(value) != ncol(x)) {
error("names<-,SpatVector", "incorrect number of names")
}

value <- enc2utf8(as.character(value))
x@ptr <- x@ptr$deepcopy()
x@ptr$names <- value
Expand Down Expand Up @@ -242,6 +249,9 @@ setMethod("names", signature(x="SpatVectorCollection"),
setMethod("names<-", signature(x="SpatVectorCollection"),
function(x, value) {
x@ptr <- x@ptr$deepcopy()
if (is.null(value)) {
value <- rep("", length(x))
}
x@ptr$setNames(enc2utf8(as.character(value)), FALSE)
x
}
Expand Down

0 comments on commit 76c927d

Please sign in to comment.