Skip to content

Commit

Permalink
fixes #1515
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed May 23, 2024
1 parent 6fbdf63 commit b42fcd7
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions R/SpatVectorCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ setMethod("svc", signature(x="list"),
r@ptr$push_back(x[[i]]@ptr)
}
}
messages(r, "svc")
r <- messages(r, "svc")
names(r) <- names(x)
r
}
)

Expand Down Expand Up @@ -108,8 +110,29 @@ function(x, i, j, drop=TRUE) {
messages(x, "`[`")
})


setMethod("[[", c("SpatVectorCollection", "character", "missing"),
function(x, i, j, drop=TRUE) {
i <- na.omit(match(i, names(x)))
if (length(i) == 0) {
error("[[", "no matching names")
}
x[i, drop=drop]
})


setMethod("$", c("SpatVectorCollection"),
function(x, name) {
i <- na.omit(grep(name, names(x)))
if (length(i) == 0) {
error("$", "no matching names")
}
x[i,drop=TRUE]
})


setMethod("[[", c("SpatVectorCollection", "numeric", "missing"),
function(x, i, drop=TRUE) {
function(x, i, j, drop=TRUE) {
x[i,drop=drop]
})

Expand Down

0 comments on commit b42fcd7

Please sign in to comment.