-
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
10 changed files
with
167 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ Package: geometa | |
Type: Package | ||
Title: Tools for Reading and Writing ISO/OGC Geographic Metadata | ||
Version: 0.7-1 | ||
Date: 2022-09-29 | ||
Date: 2022-10-02 | ||
Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-5870-5762"))) | ||
Maintainer: Emmanuel Blondel <[email protected]> | ||
Description: Provides facilities to handle reading and writing of geographic metadata | ||
|
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,74 @@ | ||
#' SWETimeRange | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE Time Range | ||
#' @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> | ||
#' | ||
SWETimeRange <- R6Class("SWETimeRange", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "TimeRange", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field uom uom | ||
uom = NULL, | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = matrix(NA_real_, 1, 2), | ||
|
||
#'@description Initializes an object of class \link{SWETimeRange} | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param uom uom | ||
#'@param constraint constraint | ||
#'@param start start time | ||
#'@param end end time | ||
#'@param updatable updatable | ||
#'@param optional optional | ||
#'@param definition definition | ||
initialize = function(xml = NULL, | ||
uom = NULL, constraint = NULL, start = NULL, end = 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(start = start, end = end) | ||
} | ||
}, | ||
|
||
#'@description setUom | ||
#'@param uom uom | ||
setUom = function(uom){ | ||
uomElem <- SWEElement$create(element = "uom") | ||
uomElem$setAttr("code", uom) | ||
self$uom <- uomElem | ||
}, | ||
|
||
#'@description setConstraint | ||
#'@param constraint constraint | ||
setConstraint = function(constraint){ | ||
self$constraint <- constraint | ||
}, | ||
|
||
#'@description setValue | ||
#'@param start start time | ||
#'@param end end time | ||
setValue = function(start, end){ | ||
self$value <- matrix(list(start, end), nrow = 1, ncol = 2, byrow = TRUE) | ||
} | ||
) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# test_SWETimeRange.R | ||
# Author: Emmanuel Blondel <[email protected]> | ||
# | ||
# Description: Unit tests for classes inheriting SWETimeRange.R | ||
#======================= | ||
require(geometa, quietly = TRUE) | ||
require(sf) | ||
require(testthat) | ||
|
||
context("SWETimeRange") | ||
|
||
test_that("SWETimeRange",{ | ||
testthat::skip_on_cran() | ||
#encoding | ||
time <- SWETimeRange$new() | ||
time$setValue(start = Sys.time(), end = Sys.time()+3600) | ||
time$setAttr("definition", "http://mmisw.org/ont/ioos/swe_element_type/observationTimeRange") | ||
xml <- time$encode() #TODO check how to rencode properly as ISO 8601 datetimes | ||
expect_is(xml, "XMLInternalNode") | ||
#decoding | ||
time2 <- SWETimeRange$new(xml = xml) | ||
xml2 <- time2$encode() | ||
#assert object identity | ||
expect_true(ISOAbstractObject$compare(time, time2)) | ||
}) |