Skip to content

Commit

Permalink
#9 consolidate getCoverage
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Mar 7, 2022
1 parent c3f5560 commit 25a79ff
Showing 1 changed file with 47 additions and 20 deletions.
67 changes: 47 additions & 20 deletions R/WCSGetCoverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,58 @@ WCSGetCoverage <- R6Class("WCSGetCoverage",
i <- which(subsetParams == subset)
dimension <- dims[sapply(dims, function(x){x$label == subset})][[1]]
subsetKvp <- NULL
if(dimension$type == "geographic"){
subsetKvp <- sprintf("%s(%s,%s)",subset, unlist(envelope$lowerCorner[,i]), unlist(envelope$upperCorner[,i]))
}else{
value <- switch(dimension$type,
"temporal" = time,
"elevation" = elevation,
envelope$lowerCorner[,i]
)
if(!is.null(value)){
if(is(value, "numeric")){
if(length(value)==1){
subsetKvp <- sprintf("%s(%s)",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(%s,%s)",subset, value, value)
if(!is.null(dimension)){
if(dimension$type == "geographic"){
subsetKvp <- sprintf("%s(%s,%s)",subset, unlist(envelope$lowerCorner[,i]), unlist(envelope$upperCorner[,i]))
}else{
value <- switch(dimension$type,
"temporal" = time,
"elevation" = elevation,
envelope$lowerCorner[,i]
)
if(!is.null(value)){
if(is(value, "numeric")){
if(length(value)==1){
subsetKvp <- sprintf("%s(%s)",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(%s,%s)",subset, value, value)
}

}else{
if(length(value)==1){
subsetKvp <- sprintf("%s(\"%s\")",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(\"%s\",\"%s\")",subset, value, value)
}
}

}else{
if(length(value)==1){
subsetKvp <- sprintf("%s(\"%s\")",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(\"%s\",\"%s\")",subset, value, value)
}
}
}else{
subsetKvp <- sprintf("%s(%s,%s)",subset, unlist(envelope$lowerCorner[,i]), unlist(envelope$upperCorner[,i]))
if(tolower(subset) %in% c("time","elevation")){
value <- NULL
if(tolower(subset)=="time") value <- time
if(tolower(subset)=="elevation") value <- elevation
if(is.null(value)) value <- envelope$lowerCorner[,i]
if(!is.null(value)){
if(is(value, "numeric")){
if(length(value)==1){
subsetKvp <- sprintf("%s(%s)",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(%s,%s)",subset, value, value)
}

}else{
if(length(value)==1){
subsetKvp <- sprintf("%s(\"%s\")",subset, value)
}else if(length(value)==2){
subsetKvp <- sprintf("%s(\"%s\",\"%s\")",subset, value, value)
}
}
}
}
}

if(!is.null(subsetKvp)) subsetKvp = URLencode(subsetKvp)
return(subsetKvp)
})
Expand Down

0 comments on commit 25a79ff

Please sign in to comment.