Skip to content

Commit

Permalink
#43 support decoding of WMS layer dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jun 3, 2021
1 parent d30c1c7 commit ea65af3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ows4R
Version: 0.2
Date: 2021-01-27
Date: 2021-06-03
Title: Interface to OGC Web-Services (OWS)
Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")),
person("Norbert", "Billet", role = c("ctb")))
Expand Down
64 changes: 63 additions & 1 deletion R/WMSLayer.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@
#' \item{\code{getKeywords()}}{
#' Get layer keywords
#' }
#' \item{\code{getDefaultCRS()}}{
#' Get layer default CRS
#' }
#' \item{\code{getBoundingBox()}}{
#' Get layer bounding box
#' }
#' \item{\code{getBoundingBoxSRS()}}{
#' Get layer bounding box SRS
#' }
#' \item{\code{getBoundingBoxCRS()}}{
#' Get layer bounding box CRS
#' }
#' \item{\code{getStyle()}}{
#' Get layer style
#' }
#' \item{\code{getDimensions()}}{
#' Get layer dimensions
#' }
#' \item{\code{getTimeDimension()}}{
#' Get layer time dimension
#' }
#' \item{\code{getElevationDimension()}}{
#' Get layer elevation dimension
#' }
#' \item{\code{getFeatureInfo(srs, styles, feature_count,
#' x, y, width, height, bbox, info_format)}}{
#' Get layer feature info
#' }
#' }
#'
#' @note Abstract class used by \pkg{ows4R}
Expand All @@ -46,6 +74,7 @@ WMSLayer <- R6Class("WMSLayer",
boundingBoxSRS = NA,
boundingBoxCRS = NA,
style = NA,
dimensions = list(),

#fetchLayer
fetchLayer = function(xmlObj, version){
Expand Down Expand Up @@ -110,6 +139,22 @@ WMSLayer <- R6Class("WMSLayer",
layerStyle <- xmlValue(xmlChildren(styleXML)$Name)
}

dimensions <- list()
dimensionXML <- children[names(children)=="Dimension"]
if(!is.null(dimensionXML)){
dimensions <- lapply(dimensionXML, function(dimXML){
return(list(
name = xmlGetAttr(dimXML, "name"),
units = xmlGetAttr(dimXML, "units"),
multipleValues = xmlGetAttr(dimXML, "multipleValues") == "true",
current = xmlGetAttr(dimXML, "current") == "true",
default = xmlGetAttr(dimXML, "default"),
values = unlist(strsplit(gsub("\n", "", gsub(" ", "", xmlValue(dimXML))),","))
))
})
names(dimensions) <- sapply(dimensionXML, xmlGetAttr, "name")
}

layer <- list(
name = layerName,
title = layerTitle,
Expand All @@ -119,7 +164,8 @@ WMSLayer <- R6Class("WMSLayer",
boundingBox = layerBoundingBox,
boundingBoxSRS = layerSRS,
boundingBoxCRS = layerCRS,
style = layerStyle
style = layerStyle,
dimensions = dimensions
)

return(layer)
Expand Down Expand Up @@ -147,6 +193,7 @@ WMSLayer <- R6Class("WMSLayer",
private$boundingBoxSRS = layer$boundingBoxSRS
private$boundingBoxCRS = layer$boundingBoxCRS
private$style = layer$style
private$dimensions = layer$dimensions

},

Expand Down Expand Up @@ -195,6 +242,21 @@ WMSLayer <- R6Class("WMSLayer",
return(private$style)
},

#getDimensions
getDimensions = function(){
return(private$dimensions)
},

#getTimeDimension
getTimeDimension = function(){
return(private$dimensions[["time"]])
},

#getElevationDimension
getElevationDimension = function(){
return(private$dimensions[["elevation"]])
},

#getFeatureInfo
getFeatureInfo = function(srs = NULL, styles = NULL, feature_count = 1,
x, y, width, height, bbox,
Expand Down
2 changes: 1 addition & 1 deletion R/ows4R.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' Type: \tab Package\cr
#' Version
#' : \tab 0.2\cr
#' Date: \tab 2021-01-27\cr
#' Date: \tab 2021-05-03\cr
#' License: \tab MIT\cr
#' LazyLoad: \tab yes\cr
#' }
Expand Down
28 changes: 28 additions & 0 deletions man/WMSLayer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ows4R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea65af3

Please sign in to comment.