-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' SWEAbstractEncoding | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE abstract encoding 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> | ||
#' | ||
SWEAbstractEncoding <- R6Class("SWEAbstractEncoding", | ||
inherit = SWEAbstractSWE, | ||
private = list( | ||
xmlElement = "AbstractEncoding", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@description Initializes a SWE Nil Values object | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
initialize = function(xml = NULL){ | ||
super$initialize(xml, element = private$xmlElement, | ||
attrs = list(), defaults = list(), | ||
wrap = TRUE) | ||
} | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#' SWETextEncoding | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE text encoding 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> | ||
#' | ||
SWETextEncoding <- R6Class("SWETextEncoding", | ||
inherit = SWEAbstractEncoding, | ||
private = list( | ||
xmlElement = "TextEncoding", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@description Initializes a SWE Text Encoding element | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
#'@param collapseWhiteSpaces Indicates whether white spaces (i.e. space, tab, CR, LF) | ||
#' should be collapsed with separators when parsing the data stream. Default is \code{TRUE} | ||
#'@param decimalSeparator Character used as the decimal separator. Default is \code{TRUE} | ||
#'@param tokenSeparator Character sequence used as the token separator (i.e. between two successive values). Required | ||
#'@param blockSeparator Character sequence used as the block separator (i.e. between two successive blocks in the data set. | ||
#' The end of a block is reached once all values from the data tree have been encoded once). Required | ||
#' | ||
initialize = function(xml = NULL, collapseWhiteSpaces = TRUE, decimalSeparator = ".", | ||
tokenSeparator = NULL, blockSeparator = NULL){ | ||
super$initialize(xml = xml) | ||
if(is.null(xml)){ | ||
self$setAttr("collapseWhiteSpaces", tolower(collapseWhiteSpaces)) | ||
self$setAttr("decimalSeparator", decimalSeparator) | ||
self$setAttr("tokenSeparator", tokenSeparator) | ||
self$setAttr("blockSeparator", blockSeparator) | ||
} | ||
} | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' SWEXMLEncoding | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
#' @keywords ISO SWE | ||
#' @return Object of \code{\link{R6Class}} for modelling an SWE XML encoding 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> | ||
#' | ||
SWEXMLEncoding <- R6Class("SWEXMLEncoding", | ||
inherit = SWEAbstractEncoding, | ||
private = list( | ||
xmlElement = "XMLEncoding", | ||
xmlNamespacePrefix = "SWE" | ||
), | ||
public = list( | ||
|
||
#'@description Initializes a SWE XML Encoding element | ||
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML} | ||
initialize = function(xml = NULL){ | ||
super$initialize(xml = xml) | ||
} | ||
) | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# test_SWE_encodings.R | ||
# Author: Emmanuel Blondel <[email protected]> | ||
# | ||
# Description: Unit tests for classes inheriting SWEAbstractEncoding.R | ||
#======================= | ||
require(geometa, quietly = TRUE) | ||
require(sf) | ||
require(testthat) | ||
|
||
context("SWE encodings") | ||
|
||
test_that("SWEXMLEncoding",{ | ||
testthat::skip_on_cran() | ||
#encoding | ||
enc <- SWEXMLEncoding$new() | ||
xml <- enc$encode() | ||
expect_is(xml, "XMLInternalNode") | ||
#decoding | ||
enc2 <- SWEXMLEncoding$new(xml = xml) | ||
xml2 <- enc2$encode() | ||
#assert object identity | ||
expect_true(ISOAbstractObject$compare(enc, enc2)) | ||
}) | ||
|
||
test_that("SWETextEncoding",{ | ||
testthat::skip_on_cran() | ||
#encoding | ||
enc <- SWETextEncoding$new(tokenSeparator = " ", blockSeparator = ",") | ||
xml <- enc$encode() | ||
expect_is(xml, "XMLInternalNode") | ||
#decoding | ||
enc2 <- SWETextEncoding$new(xml = xml) | ||
xml2 <- enc2$encode() | ||
#assert object identity | ||
expect_true(ISOAbstractObject$compare(enc, enc2)) | ||
}) |