Skip to content

Commit

Permalink
#187 SWE Time
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 12, 2022
1 parent a71b78a commit 99bf090
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 8 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export(SWECountRange)
export(SWEQuantity)
export(SWEQuantityRange)
export(SWEText)
export(SWETime)
export(cacheISOClasses)
export(convert_metadata)
export(geometaLogger)
Expand Down
2 changes: 1 addition & 1 deletion R/SWECategory.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SWECategory <- R6Class("SWECategory",
#'@param value value
setValue = function(value){
if(!is.character(value)){
stop("Values should be character")
stop("Value should be character")
}
self$value <- value
}
Expand Down
3 changes: 3 additions & 0 deletions R/SWECount.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ SWECount <- R6Class("SWECount",
#'@description setValue
#'@param value value
setValue = function(value){
if(!is.integer(value)){
stop("Value should be integer")
}
self$value <- value
}
)
Expand Down
2 changes: 1 addition & 1 deletion R/SWECountRange.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SWECountRange <- R6Class("SWECountRange",
#'@description setValue
#'@param value value
setValue = function(value){
if(!is.integer(value)){
if(!is.numeric(value)){
stop("Values should be integer")
}
if(is.vector(value)){
Expand Down
2 changes: 1 addition & 1 deletion R/SWEQuantity.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SWEQuantity <- R6Class("SWEQuantity",
#'@param value value
setValue = function(value){
if(!is.numeric(value)){
stop("Values should be numeric")
stop("Value should be numeric")
}
self$value <- value
}
Expand Down
73 changes: 73 additions & 0 deletions R/SWETime.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#' SWETime
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO SWE
#' @return Object of \code{\link{R6Class}} for modelling an SWE Time
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' OGC Geography Markup Language. https://www.ogc.org/standards/swecommon
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
SWETime <- R6Class("SWETime",
inherit = SWEAbstractSimpleComponent,
private = list(
xmlElement = "Time",
xmlNamespacePrefix = "SWE"
),
public = list(

#'@field uom uom
uom = NULL,

#'@field constraint constraint
constraint = NULL,

#'@field value value
value = NA_character_,

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

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

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

#'@description setValue
#'@param value value
setValue = function(value){
if(!is(value,"Date") && !is(value, "POSIXt")){
stop("Value should be either a Date or POSIX object")
}
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/-33%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 10| 20|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 11| 19|
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 @@ -498,7 +498,7 @@
"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","Time","<missing>",FALSE
"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","<missing>",FALSE
"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
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",10,20,33.33
"SWE 2.0","Sensor Web Enablement (SWE) Common Data Model","SWE",11,19,36.67
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/-33%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 10| 20|
|SWE 2.0 |Sensor Web Enablement (SWE) Common Data Model |SWE |[![SWE 2.0](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 11| 19|
54 changes: 54 additions & 0 deletions man/SWETime.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test_SWECategory.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require(testthat)
context("SWECategory")

test_that("SWECategory",{
testthat::skip_on_categan()
testthat::skip_on_cran()
#encoding
categ <- SWECategory$new(value = "string1")
xml <- categ$encode()
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test_SWETime.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# test_SWETime.R
# Author: Emmanuel Blondel <[email protected]>
#
# Description: Unit tests for classes inheriting SWETime.R
#=======================
retimeuire(geometa, timeuietly = TRUE)
retimeuire(sf)
retimeuire(testthat)

context("SWETime")

test_that("SWETime",{
testthat::skip_on_cran()
#encoding
time <- SWETime$new(value = Sys.time())
xml <- time$encode()
expect_is(xml, "XMLInternalNode")
#decoding
time2 <- SWETime$new(xml = xml)
xml2 <- time2$encode()
#assert object identity
expect_true(ISOAbstractObject$compare(time, time2))
})

0 comments on commit 99bf090

Please sign in to comment.