Skip to content

Commit

Permalink
#9 check envelopes starting with other dims than lat/lon
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Feb 25, 2022
1 parent 1c0b7f1 commit 66bd7e4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions R/WCSCoverageSummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,23 @@ WCSCoverageSummary <- R6Class("WCSCoverageSummary",
if(substr(private$version,1,1)=="2"){
refEnvelope <- self$getDescription()$boundedBy
axisLabels <- unlist(strsplit(refEnvelope$attrs$axisLabels, " "))
if(axisLabels[1]=="Lat") bbox <- rbind(bbox[2,],bbox[1,])
axisLatIdx <- which(axisLabels == "Lat")
axisLonIdx <- which(axisLabels == "Lon")
if(axisLatIdx < axisLonIdx) bbox <- rbind(bbox[2,],bbox[1,])
envelope <- GMLEnvelope$new(bbox = bbox)
if(as.numeric(refEnvelope$attrs$srsDimension)>2){
#TODO and what if geo coordinates are not the first dims defined in envelope?
envelope$lowerCorner <- cbind(envelope$lowerCorner, refEnvelope$lowerCorner[,3:length(refEnvelope$lowerCorner)])
envelope$upperCorner <- cbind(envelope$upperCorner, refEnvelope$upperCorner[,3:length(refEnvelope$upperCorner)])
lowerCorner <- NULL
upperCorner <- NULL
if(axisLatIdx == 1 || axisLonIdx == 1){
lowerCorner <- cbind(envelope$lowerCorner, refEnvelope$lowerCorner[,3:length(refEnvelope$lowerCorner)])
upperCorner <- cbind(envelope$upperCorner, refEnvelope$upperCorner[,3:length(refEnvelope$upperCorner)])
}else{
lowerCorner <- cbind(refEnvelope$lowerCorner[,1:(length(refEnvelope$lowerCorner)-2)], envelope$lowerCorner)
upperCorner <- cbind(refEnvelope$upperCorner[,1:(length(refEnvelope$upperCorner)-2)], envelope$upperCorner)
}

envelope$lowerCorner <- lowerCorner
envelope$upperCorner <- upperCorner
}
if(is(refEnvelope, "GMLEnvelopeWithTimePeriod")){
envelope$lowerCorner <- cbind(envelope$lowerCorner, format(refEnvelope$beginPosition$value, "%Y-%m-%dT%H:%M:%S"))
Expand All @@ -489,7 +500,7 @@ WCSCoverageSummary <- R6Class("WCSCoverageSummary",
}

#dimensions
dims <- self$getDimensions() #TODO and for other versions of WCS?
dims <- self$getDimensions()
if(!is.null(dims)){

#TODO geographic dimension checks?
Expand Down

0 comments on commit 66bd7e4

Please sign in to comment.