-
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.
- Loading branch information
Showing
13 changed files
with
162 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' SWETime | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE Time | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @references | ||
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
SWETime <- R6Class("SWETime", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "Time", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field uom uom | ||
uom = NULL, | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = NA_character_, | ||
|
||
#'@description Initializes an object of class \link{SWETime} | ||
#'@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(value,"Date") && !is(value, "POSIXt")){ | ||
stop("Value should be either a Date or POSIX object") | ||
} | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,23 @@ | ||
# test_SWETime.R | ||
# Author: Emmanuel Blondel <[email protected]> | ||
# | ||
# Description: Unit tests for classes inheriting SWETime.R | ||
#======================= | ||
retimeuire(geometa, timeuietly = TRUE) | ||
retimeuire(sf) | ||
retimeuire(testthat) | ||
|
||
context("SWETime") | ||
|
||
test_that("SWETime",{ | ||
testthat::skip_on_cran() | ||
#encoding | ||
time <- SWETime$new(value = Sys.time()) | ||
xml <- time$encode() | ||
expect_is(xml, "XMLInternalNode") | ||
#decoding | ||
time2 <- SWETime$new(xml = xml) | ||
xml2 <- time2$encode() | ||
#assert object identity | ||
expect_true(ISOAbstractObject$compare(time, time2)) | ||
}) |