Skip to content

Commit

Permalink
#187 SWECategoryRange
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 12, 2022
1 parent 63cc3cf commit 62f0dc8
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export(ISOVerticalExtent)
export(SWEAbstractDataComponent)
export(SWEAbstractObject)
export(SWEAbstractSimpleComponent)
export(SWECategoryRange)
export(SWECount)
export(SWEQuantityRange)
export(SWEText)
Expand Down
84 changes: 84 additions & 0 deletions R/SWECategoryRange.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#' SWECategoryRange
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO SWE
#' @return Object of \code{\link{R6Class}} for modelling an SWE CategoryRange
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
SWECategoryRange <- R6Class("SWECategoryRange",
inherit = SWEAbstractSimpleComponent,
private = list(
xmlElement = "CategoryRange",
xmlNamespacePrefix = "SWE"
),
public = list(

#'@field codeSpace codeSpace
codeSpace = NULL,

#'@field constraint constraint
constraint = NULL,

#'@field value value
value = matrix(NA_character_, 1, 2),

#'@description Initializes an object of class \link{SWECategoryRange}
#'@param xml object of class \link{XMLInternalNode-class} from \pkg{XML}
#'@param codeSpace codeSpace
#'@param constraint constraint
#'@param value value
#'@param updatable updatable
#'@param optional optional
#'@param definition definition
initialize = function(xml = NULL,
codeSpace = 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$setCodeSpace(codeSpace)
self$setConstraint(constraint)
self$setValue(value)
}
},

#'@description setCodeSpace
#'@param codeSpace codeSpace
setCodeSpace = function(codeSpace){
self$codeSpace <- codeSpace
},

#'@description setConstraint
#'@param constraint constraint
setConstraint = function(constraint){
self$constraint <- constraint
},

#'@description setValue
#'@param value value
setValue = function(value){
if(!is.character(value)){
stop("Values should be character")
}
if(is.vector(value)){
if(length(value)!="2"){
stop("Vector of values should of length 2")
}
}else if(is.matrix(value)){
if(!all(dim(value)==c(1,2))){
stop("Matrix of values should be of dimensions 1,2")
}
}else{
stop("Value should be either a vector or matrix")
}
self$value <- value
}
)
)
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/-20%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 6| 24|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-23%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 7| 23|
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_inventory.csv
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","BinaryEncoding","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Block","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Category","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","CategoryRange","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","CategoryRange","SWECategoryRange",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Component","<missing>",FALSE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","Count","SWECount",TRUE
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE","CountRange","<missing>",FALSE
Expand Down
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",6,24,20
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE",7,23,23.33
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/-20%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 6| 24|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-23%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 7| 23|
54 changes: 54 additions & 0 deletions man/SWECategoryRange.Rd

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

23 changes: 23 additions & 0 deletions tests/testthat/test_SWECategoryRange.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# test_SWECategoryRange.R
# Author: Emmanuel Blondel <[email protected]>
#
# Description: Unit tests for classes inheriting SWECategoryRange.R
#=======================
require(geometa, quietly = TRUE)
require(sf)
require(testthat)

context("SWECategoryRange")

test_that("SWECategoryRange",{
testthat::skip_on_cran()
#encoding
cr <- SWECategoryRange$new(value = matrix(c("string1","string2"),1,2))
xml <- cr$encode()
expect_is(xml, "XMLInternalNode")
#decoding
cr2 <- SWECategoryRange$new(xml = xml)
xml2 <- cr2$encode()
#assert object identity
expect_true(ISOAbstractObject$compare(cr, cr2))
})

0 comments on commit 62f0dc8

Please sign in to comment.