Skip to content

Commit

Permalink
#187 work on SWE NilValues decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 29, 2022
1 parent 1b2d8e1 commit c0006c6
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,14 @@ export(ISOVectorSpatialRepresentation)
export(ISOVerticalExtent)
export(SWEAbstractDataComponent)
export(SWEAbstractObject)
export(SWEAbstractSWE)
export(SWEAbstractSimpleComponent)
export(SWECategory)
export(SWECategoryRange)
export(SWECount)
export(SWECountRange)
export(SWEDataRecord)
export(SWENilValues)
export(SWEQuantity)
export(SWEQuantityRange)
export(SWEText)
Expand Down
35 changes: 35 additions & 0 deletions R/SWEAbstractSWE.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#' SWEAbstractSWE
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML
#' @return Object of \code{\link{R6Class}} for modelling an SWE abstract SWE object
#' @format \code{\link{R6Class}} object.
#'
#' @note Class used internally by geometa
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
SWEAbstractSWE <- R6Class("SWEAbstractSWE",
inherit = ISOAbstractObject,
private = list(
xmlElement = "AbstractSWE",
xmlNamespacePrefix = "SWE"
),
public = list(

#'@description Initializes an object of class \link{SWEAbstractSWE}
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML}
#'@param element element
#'@param attrs attrs
#'@param defaults defaults
#'@param wrap wrap
initialize = function(xml = NULL, element = NULL, attrs = list(), defaults = list(), wrap = FALSE){
if(is.null(element)) element <- private$xmlElement
super$initialize(xml, element, namespace = private$xmlNamespacePrefix,
attrs = attrs, defaults = defaults,
wrap = wrap, value_as_field = TRUE)
}
)
)
9 changes: 9 additions & 0 deletions R/SWEAbstractSimpleComponent.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ SWEAbstractSimpleComponent <- R6Class("SWEAbstractSimpleComponent",
),
public = list(

#'@field nilValues nil values
nilValues = NULL,

#'@description Initializes an object of class \link{SWEAbstractSimpleComponent}
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML}
#'@param element element
Expand All @@ -29,6 +32,12 @@ SWEAbstractSimpleComponent <- R6Class("SWEAbstractSimpleComponent",
initialize = function(xml = NULL, element = NULL, updatable = NULL, optional = FALSE, definition = NULL){
if(is.null(element)) element <- private$xmlElement
super$initialize(xml, element = element, updatable = updatable, optional = optional, definition = definition)
},

#'@description Set nil value and its reason (optional)
#'@param nilValue value to set as nil Value. object of class \code{numeric}
setNilValues = function(nilvalue){
self$nilValues = SWENilValues$new(value = nilValue)
}
)
)
33 changes: 33 additions & 0 deletions R/SWENilValues.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#' SWENilValues
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO SWE
#' @return Object of \code{\link{R6Class}} for modelling an SWE nil values object
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' SWE Common Data Model Encoding Standard. https://www.ogc.org/standards/swecommon
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
SWENilValues <- R6Class("SWENilValues",
inherit = SWEAbstractSWE,
private = list(
xmlElement = "NilValues",
xmlNamespacePrefix = "SWE"
),
public = list(

#'@field nilValue nil value
nilValue = matrix(NA_real_, 1, 1),

initialize = function(xml = NULL, value = NULL){
super$initialize(xml, element = private$xmlElement,
attrs = list(), defaults = list(),
wrap = FALSE)
if(!is.null(value)) self$nilValue = value
}
)
)
34 changes: 34 additions & 0 deletions man/SWEAbstractSWE.Rd

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

10 changes: 10 additions & 0 deletions man/SWEAbstractSimpleComponent.Rd

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

29 changes: 29 additions & 0 deletions man/SWENilValues.Rd

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

0 comments on commit c0006c6

Please sign in to comment.