Skip to content

Commit

Permalink
#187 SWE encoding elements, Rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Oct 3, 2022
1 parent 5d9a5fa commit ec3f45e
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 14 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export(ISOUsage)
export(ISOVectorSpatialRepresentation)
export(ISOVerticalExtent)
export(SWEAbstractDataComponent)
export(SWEAbstractEncoding)
export(SWEAbstractObject)
export(SWEAbstractSWE)
export(SWEAbstractSimpleComponent)
Expand All @@ -333,8 +334,10 @@ export(SWENilValues)
export(SWEQuantity)
export(SWEQuantityRange)
export(SWEText)
export(SWETextEncoding)
export(SWETime)
export(SWETimeRange)
export(SWEXMLEncoding)
export(cacheISOClasses)
export(convert_metadata)
export(geometaLogger)
Expand Down
31 changes: 31 additions & 0 deletions R/SWEAbstractEncoding.R
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)
}
)
)
1 change: 0 additions & 1 deletion R/SWENilValues.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SWENilValues <- R6Class("SWENilValues",

#'@description Initializes a SWE Nil Values object
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML}
#'@param values vector of numerical values to consider as nil values
initialize = function(xml = NULL){
super$initialize(xml, element = private$xmlElement,
attrs = list(), defaults = list(),
Expand Down
43 changes: 43 additions & 0 deletions R/SWETextEncoding.R
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)
}
}
)
)
29 changes: 29 additions & 0 deletions R/SWEXMLEncoding.R
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)
}
)
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ We thank in advance people that use ``geometa`` for citing it in their work / pu
|GML 3.2.1 (ISO 19136) |Geographic Markup Language |GML |[![GML 3.2.1 (ISO 19136)](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 63| 106|
|GML 3.2.1 Coverage (OGC GMLCOV) |OGC GML Coverage Implementation Schema |GMLCOV |[![GML 3.2.1 Coverage (OGC GMLCOV)](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 1| 0|
|GML 3.3 Referenceable Grid (OGC GML) |OGC GML Referenceable Grid |GMLRGRID |[![GML 3.3 Referenceable Grid (OGC GML)](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 5| 0|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-50%25-f9ae2c.svg)](https://github.com/eblondel/geometa) | 15| 15|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-60%25-f2eb24.svg)](https://github.com/eblondel/geometa) | 18| 12|
6 changes: 3 additions & 3 deletions inst/extdata/coverage/geometa_coverage_inventory.csv
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
"GML 3.3 Referenceable Grid (OGC GML)","OGC GML Referenceable Grid","GMLRGRID","ReferenceableGridByTransformation","GMLReferenceableGridByTransformation",TRUE
"GML 3.3 Referenceable Grid (OGC GML)","OGC GML Referenceable Grid","GMLRGRID","ReferenceableGridByVectors","GMLReferenceableGridByVectors",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractDataComponent","SWEAbstractDataComponent",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractEncoding","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractEncoding","SWEAbstractEncoding",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractObject","SWEAbstractObject",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractSimpleComponent","SWEAbstractSimpleComponent",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","AbstractSWE","SWEAbstractSWE",TRUE
Expand All @@ -497,8 +497,8 @@
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Quantity","SWEQuantity",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","QuantityRange","SWEQuantityRange",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Text","SWEText",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","TextEncoding","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","TextEncoding","SWETextEncoding",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Time","SWETime",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","TimeRange","SWETimeRange",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Vector","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","XMLEncoding","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","XMLEncoding","SWEXMLEncoding",TRUE
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_summary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"GML 3.2.1 (ISO 19136)","Geographic Markup Language","GML",63,106,37.28
"GML 3.2.1 Coverage (OGC GMLCOV)","OGC GML Coverage Implementation Schema","GMLCOV",1,0,100
"GML 3.3 Referenceable Grid (OGC GML)","OGC GML Referenceable Grid","GMLRGRID",5,0,100
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE",15,15,50
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE",18,12,60
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
|GML 3.2.1 (ISO 19136) |Geographic Markup Language |GML |[![GML 3.2.1 (ISO 19136)](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 63| 106|
|GML 3.2.1 Coverage (OGC GMLCOV) |OGC GML Coverage Implementation Schema |GMLCOV |[![GML 3.2.1 Coverage (OGC GMLCOV)](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 1| 0|
|GML 3.3 Referenceable Grid (OGC GML) |OGC GML Referenceable Grid |GMLRGRID |[![GML 3.3 Referenceable Grid (OGC GML)](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 5| 0|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-50%25-f9ae2c.svg)](https://github.com/eblondel/geometa) | 15| 15|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-60%25-f2eb24.svg)](https://github.com/eblondel/geometa) | 18| 12|
8 changes: 4 additions & 4 deletions man/SWEAbstractDataComponent.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/SWEAbstractEncoding.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/SWENilValues.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions man/SWETextEncoding.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/SWETimeRange.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/SWEXMLEncoding.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions tests/testthat/test_SWE_encodings.R
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))
})

0 comments on commit ec3f45e

Please sign in to comment.