-
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
127 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#' SWEText | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE Text | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @references | ||
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
SWEText <- R6Class("SWEText", | ||
inherit = SWEAbstractSimpleComponent, | ||
private = list( | ||
xmlElement = "Text", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@field constraint constraint | ||
constraint = NULL, | ||
|
||
#'@field value value | ||
value = NULL, | ||
|
||
#'@description Initializes an object of class \link{SWEText} | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param constraint constraint | ||
#'@param value value | ||
initialize = function(xml = NULL, constraint = NULL, value = NULL){ | ||
super$initialize(xml, element = private$xmlElement) | ||
if(is.null(xml)){ | ||
self$constraint <- constraint | ||
self$value <- value | ||
} | ||
}, | ||
|
||
#'@description setConstraint | ||
#'@param constraint | ||
setConstraint = function(constraint){ | ||
self$constraint <- constraint | ||
}, | ||
|
||
#'@description setValue | ||
#'@param value | ||
setValue = function(value){ | ||
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.
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,23 @@ | ||
# test_SWEText.R | ||
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com> | ||
# | ||
# Description: Unit tests for classes inheriting SWEText.R | ||
#======================= | ||
require(geometa, quietly = TRUE) | ||
require(sf) | ||
require(testthat) | ||
|
||
context("SWEText") | ||
|
||
test_that("SWEText",{ | ||
testthat::skip_on_cran() | ||
#encoding | ||
txt <- SWEText$new(value = "some free text") | ||
xml <- txt$encode() | ||
expect_is(xml, "XMLInternalNode") | ||
#decoding | ||
txt2 <- SWEText$new(xml = xml) | ||
xml2 <- txt2$encode() | ||
#assert object identity | ||
expect_true(ISOAbstractObject$compare(txt, txt2)) | ||
}) |