-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#187 SWE Category, Quantity, CountRange
- Loading branch information
Showing
15 changed files
with
457 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#' SWECategory | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE Category | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @references | ||
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
SWECategory <- R6Class("SWECategory", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "Category", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field codeSpace codeSpace | ||
codeSpace = NULL, | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = NA_character_, | ||
|
||
#'@description Initializes an object of class \link{SWECategory} | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param codeSpace codeSpace | ||
#'@param constraint constraint | ||
#'@param value value | ||
#'@param updatable updatable | ||
#'@param optional optional | ||
#'@param definition definition | ||
initialize = function(xml = NULL, | ||
codeSpace = NULL, constraint = NULL, value = NULL, | ||
updatable = NULL, optional = FALSE, definition = NULL){ | ||
super$initialize(xml, element = private$xmlElement, | ||
updatable = updatable, optional = optional, definition = definition) | ||
if(is.null(xml)){ | ||
self$setCodeSpace(codeSpace) | ||
self$setConstraint(constraint) | ||
self$setValue(value) | ||
} | ||
}, | ||
|
||
|
||
#'@description setCodeSpace | ||
#'@param codeSpace codeSpace | ||
setCodeSpace = function(codeSpace){ | ||
self$codeSpace <- codeSpace | ||
}, | ||
|
||
#'@description setConstraint | ||
#'@param constraint constraint | ||
setConstraint = function(constraint){ | ||
self$constraint <- constraint | ||
}, | ||
|
||
#'@description setValue | ||
#'@param value value | ||
setValue = function(value){ | ||
if(!is.character(value)){ | ||
stop("Values should be character") | ||
} | ||
self$value <- value | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' SWECountRange | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE CountRange | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @references | ||
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
SWECountRange <- R6Class("SWECountRange", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "CountRange", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = matrix(NA_integer_, 1, 2), | ||
|
||
#'@description Initializes an object of class \link{SWECountRange} | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param constraint constraint | ||
#'@param value value | ||
#'@param updatable updatable | ||
#'@param optional optional | ||
#'@param definition definition | ||
initialize = function(xml = NULL, | ||
constraint = NULL, value = NULL, | ||
updatable = NULL, optional = FALSE, definition = NULL){ | ||
super$initialize(xml, element = private$xmlElement, | ||
updatable = updatable, optional = optional, definition = definition) | ||
if(is.null(xml)){ | ||
self$setConstraint(constraint) | ||
self$setValue(value) | ||
} | ||
}, | ||
|
||
#'@description setConstraint | ||
#'@param constraint constraint | ||
setConstraint = function(constraint){ | ||
self$constraint <- constraint | ||
}, | ||
|
||
#'@description setValue | ||
#'@param value value | ||
setValue = function(value){ | ||
if(!is.integer(value)){ | ||
stop("Values should be integer") | ||
} | ||
if(is.vector(value)){ | ||
if(length(value)!="2"){ | ||
stop("Vector of values should of length 2") | ||
} | ||
}else if(is.matrix(value)){ | ||
if(!all(dim(value)==c(1,2))){ | ||
stop("Matrix of values should be of dimensions 1,2") | ||
} | ||
}else{ | ||
stop("Value should be either a vector or matrix") | ||
} | ||
self$value <- value | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' SWEQuantity | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE Quantity | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @references | ||
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
SWEQuantity <- R6Class("SWEQuantity", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "Quantity", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field uom uom | ||
uom = NULL, | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = NA_real_, | ||
|
||
#'@description Initializes an object of class \link{SWEQuantity} | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param uom uom | ||
#'@param constraint constraint | ||
#'@param value value | ||
#'@param updatable updatable | ||
#'@param optional optional | ||
#'@param definition definition | ||
initialize = function(xml = NULL, | ||
uom = NULL, constraint = NULL, value = NULL, | ||
updatable = NULL, optional = FALSE, definition = NULL){ | ||
super$initialize(xml, element = private$xmlElement, | ||
updatable = updatable, optional = optional, definition = definition) | ||
if(is.null(xml)){ | ||
self$setUom(uom) | ||
self$setConstraint(constraint) | ||
self$setValue(value) | ||
} | ||
}, | ||
|
||
#'@description setUom | ||
#'@param uom uom | ||
setUom = function(uom){ | ||
self$uom <- uom | ||
}, | ||
|
||
#'@description setConstraint | ||
#'@param constraint constraint | ||
setConstraint = function(constraint){ | ||
self$constraint <- constraint | ||
}, | ||
|
||
#'@description setValue | ||
#'@param value value | ||
setValue = function(value){ | ||
if(!is.numeric(value)){ | ||
stop("Values should be numeric") | ||
} | ||
self$value <- value | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.