diff --git a/NAMESPACE b/NAMESPACE index 1d1541df..bac329c8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ export(GMLEllipsoidalCS) export(GMLGeodeticCRS) export(GMLLinearCS) export(GMLObliqueCartesianCS) +export(GMLOperationMethod) export(GMLOperationParameter) export(GMLOperationParameterGroup) export(GMLPolarCS) diff --git a/R/GMLAbstractGeneralOperationParameter.R b/R/GMLAbstractGeneralOperationParameter.R new file mode 100644 index 00000000..c94b7bc1 --- /dev/null +++ b/R/GMLAbstractGeneralOperationParameter.R @@ -0,0 +1,55 @@ +#' GMLAbstractGeneralOperationParameter +#' +#' @docType class +#' @importFrom R6 R6Class +#' @export +#' @keywords ISO GML abstract general operation parameter +#' @return Object of \code{\link{R6Class}} for modelling an GMLAbstractGeneralOperationParameter +#' @format \code{\link{R6Class}} object. +#' +#' @field minimumOccurs +#' +#' @section Inherited methods from \code{GMLDefinition} +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xml, defaults, id)}}{ +#' This method is used to instantiate a GML AbstractGeneralOperationParameter +#' } +#' \item{\code{setMinimumOccurs(minimumOccurs)}}{ +#' Sets the minimum occurs, object of class \code{integer} +#' } +#' } +#' +#' @references +#' ISO 19136:2007 Geographic Information -- Geographic Markup Language. +#' http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 +#' +#' OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +#' +#' @author Emmanuel Blondel +#' +GMLAbstractGeneralOperationParameter <- R6Class("GMLAbstractGeneralOperationParameter", + inherit = GMLDefinition, + private = list( + xmlElement = "AbstractGeneralOperationParameter", + xmlNamespacePrefix = "GML" + ), + public = list( + + #+ minimumOccurs [0..1]: integer + minimumOccurs = NULL, + + #setMinimumOccurs + setMinimumOccurs = function(minimumOccurs){ + if(!is(minimumOccurs, "integer")){ + minimumOccurs <- as.integer(minimumOccurs) + if(is.na(minimumOccurs)){ + stop("The argument value should be an object of class 'integer'") + } + } + self$minimumOccurs <- GMLElement$create("minimumOccurs", value = minimumOccurs) + } + + ) +) \ No newline at end of file diff --git a/R/GMLOperationMethod.R b/R/GMLOperationMethod.R new file mode 100644 index 00000000..60914842 --- /dev/null +++ b/R/GMLOperationMethod.R @@ -0,0 +1,112 @@ +#' GMLOperationMethod +#' +#' @docType class +#' @importFrom R6 R6Class +#' @export +#' @keywords ISO GML operation method +#' @return Object of \code{\link{R6Class}} for modelling an GMLOperationMethod +#' @format \code{\link{R6Class}} object. +#' +#' @field formulaCitation +#' @field sourceDimensions +#' @field targetDimensions +#' +#' @section Inherited methods from \code{GMLDefinition} +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xml, defaults, id)}}{ +#' This method is used to instantiate a GML OperationMethod +#' } +#' \item{\code{setFormulaCitation(citation)}}{ +#' Sets the formula citation, object of class \code{ISOCitation} +#' } +#' \item{\code{setSourceDimensions(value)}}{ +#' Sets the number of source dimensions, object of class \code{integer} +#' } +#' \item{\code{setTargetDimensions(value)}}{ +#' Sets the number of target dimensions, object of class \code{integer} +#' } +#' \item{\code{addParameter(parameter)}}{ +#' Adds a parameter or parameter group, object of class \code{GMLOperationParameter} +#' or \code{GMLOperationParameterGroup} +#' } +#' \item{\code{delParameter(parameter)}}{ +#' Deletes a parameter or parameter group, object of class \code{GMLOperationParameter} +#' or \code{GMLOperationParameterGroupo} +#' } +#' } +#' +#' @references +#' ISO 19136:2007 Geographic Information -- Geographic Markup Language. +#' http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 +#' +#' OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +#' +#' @author Emmanuel Blondel +#' +GMLOperationMethod <- R6Class("GMLOperationMethod", + inherit = GMLDefinition, + private = list( + xmlElement = "OperationMethod", + xmlNamespacePrefix = "GML" + ), + public = list( + + #+ formulaCitation [1..1]: ISOCitation + formulaCitation = NA, + #+ sourceDimensions [0..1]: integer + sourceDimensions = NULL, + #+ targetDimensions [0..1]: integer + targetDimensions = NULL, + #+ parameter [0..*]: GMLOperationParameter or GMLOperationParameterGroup + parameter = list(), + + #setFormulaCitation + setFormulaCitation = function(citation){ + if(!is(citation, "ISOCitation")){ + stop("The argument value should be an object of class 'ISOCitation'") + } + self$formulaCitation <- GMLElement$create("formulaCitation", value = citation) + }, + + #setSourceDimensions + setSourceDimensions = function(value){ + if(!is(value, "integer")){ + value <- as.integer(value) + if(is.na(value)){ + stop("The argument value should an object of class or coerceable to 'integer'") + } + } + self$sourceDimensions <- GMLElement$create("sourceDimensions", value = value) + }, + + #setTargetDimensions + setTargetDimensions = function(value){ + if(!is(value, "integer")){ + value <- as.integer(value) + if(is.na(value)){ + stop("The argument value should an object of class or coerceable to 'integer'") + } + } + self$targetDimensions <- GMLElement$create("targetDimensions", value = value) + }, + + #addParameter + addParameter = function(param){ + if(!inherits(param, "GMLAbstractGeneralOperationParameter")){ + stop("The argument value should be an object of class 'GMLOperationParameter' or 'GMLOperationParameterGroup'") + } + return(self$addListElement("parameter", GMLElement$create("parameter", value = param))) + }, + + #delParameter + delParameter = function(param){ + if(!inherits(param, "GMLAbstractGeneralOperationParameter")){ + stop("The argument value should be an object of class 'GMLOperationParameter' or 'GMLOperationParameterGroup'") + } + return(self$delListElement("parameter", GMLElement$create("parameter", value = param))) + } + + ) +) \ No newline at end of file diff --git a/R/GMLOperationParameter.R b/R/GMLOperationParameter.R new file mode 100644 index 00000000..87658201 --- /dev/null +++ b/R/GMLOperationParameter.R @@ -0,0 +1,34 @@ +#' GMLOperationParameter +#' +#' @docType class +#' @importFrom R6 R6Class +#' @export +#' @keywords ISO GML operation parameter +#' @return Object of \code{\link{R6Class}} for modelling an GMLOperationParameter +#' @format \code{\link{R6Class}} object. +#' +#' @section Inherited methods from \code{GMLAbstractGeneralOperationParameter} +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xml, defaults, id)}}{ +#' This method is used to instantiate a GML OperationParameter +#' } +#' } +#' +#' @references +#' ISO 19136:2007 Geographic Information -- Geographic Markup Language. +#' http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 +#' +#' OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +#' +#' @author Emmanuel Blondel +#' +GMLOperationParameter <- R6Class("GMLOperationParameter", + inherit = GMLAbstractGeneralOperationParameter, + private = list( + xmlElement = "OperationParameter", + xmlNamespacePrefix = "GML" + ), + public = list() +) \ No newline at end of file diff --git a/R/GMLOperationParameterGroup.R b/R/GMLOperationParameterGroup.R new file mode 100644 index 00000000..b39838cf --- /dev/null +++ b/R/GMLOperationParameterGroup.R @@ -0,0 +1,82 @@ +#' GMLOperationParameterGroup +#' +#' @docType class +#' @importFrom R6 R6Class +#' @export +#' @keywords ISO GML operation parameter group +#' @return Object of \code{\link{R6Class}} for modelling an GMLOperationParameterGroup +#' @format \code{\link{R6Class}} object. +#' +#' @field maximumOccurs +#' @field parameter +#' +#' @section Inherited methods from \code{GMLAbstractGeneralOperationParameter} +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xml, defaults, id)}}{ +#' This method is used to instantiate a GML OperationParameterGroup +#' } +#' \item{\code{setMaximumOccurs(maximumOccurs)}}{ +#' Sets the maximum occurs, object of class \code{integer} +#' } +#' \item{\code{addParameter(parameter)}}{ +#' Adds a parameter or parameter group, object of class \code{GMLOperationParameter} +#' or \code{GMLOperationParameterGroup} +#' } +#' \item{\code{delParameter(parameter)}}{ +#' Deletes a parameter or parameter group, object of class \code{GMLOperationParameter} +#' or \code{GMLOperationParameterGroupo} +#' } +#' } +#' +#' @references +#' ISO 19136:2007 Geographic Information -- Geographic Markup Language. +#' http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 +#' +#' OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +#' +#' @author Emmanuel Blondel +#' +GMLOperationParameterGroup <- R6Class("GMLOperationParameterGroup", + inherit = GMLAbstractGeneralOperationParameter, + private = list( + xmlElement = "OperationParameterGroup", + xmlNamespacePrefix = "GML" + ), + public = list( + + #+ maximumOccurs [0..1]: integer + maximumOccurs = NULL, + #+ parameter [2..*]: GMLOperationParameter / GMLOperationParameterGroup + parameter = list(), + + #setMaximumOccurs + setMaximumOccurs = function(maximumOccurs){ + if(!is(maximumOccurs, "integer")){ + maximumOccurs <- as.integer(maximumOccurs) + if(is.na(maximumOccurs)){ + stop("The argument value should be an object of class 'integer'") + } + } + self$maximumOccurs <- GMLElement$create("maximumOccurs", value = maximumOccurs) + }, + + #addParameter + addParameter = function(param){ + if(!inherits(param, "GMLAbstractGeneralOperationParameter")){ + stop("The argument value should be an object of class 'GMLOperationParameter' or 'GMLOperationParameterGroup'") + } + return(self$addListElement("parameter", GMLElement$create("parameter", value = param))) + }, + + #delParameter + delParameter = function(param){ + if(!inherits(param, "GMLAbstractGeneralOperationParameter")){ + stop("The argument value should be an object of class 'GMLOperationParameter' or 'GMLOperationParameterGroup'") + } + return(self$delListElement("parameter", GMLElement$create("parameter", value = param))) + } + + ) +) \ No newline at end of file diff --git a/man/GMLAbstractGeneralOperationParameter.Rd b/man/GMLAbstractGeneralOperationParameter.Rd new file mode 100644 index 00000000..386ba11b --- /dev/null +++ b/man/GMLAbstractGeneralOperationParameter.Rd @@ -0,0 +1,52 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/GMLAbstractGeneralOperationParameter.R +\docType{class} +\name{GMLAbstractGeneralOperationParameter} +\alias{GMLAbstractGeneralOperationParameter} +\title{GMLAbstractGeneralOperationParameter} +\format{\code{\link{R6Class}} object.} +\usage{ +GMLAbstractGeneralOperationParameter +} +\value{ +Object of \code{\link{R6Class}} for modelling an GMLAbstractGeneralOperationParameter +} +\description{ +GMLAbstractGeneralOperationParameter +} +\section{Fields}{ + +\describe{ +\item{\code{minimumOccurs}}{} +}} +\section{Inherited methods from \code{GMLDefinition}}{ + +} + +\section{Methods}{ + +\describe{ + \item{\code{new(xml, defaults, id)}}{ + This method is used to instantiate a GML AbstractGeneralOperationParameter + } + \item{\code{setMinimumOccurs(minimumOccurs)}}{ + Sets the minimum occurs, object of class \code{integer} + } +} +} +\author{ +Emmanuel Blondel +} +\references{ +ISO 19136:2007 Geographic Information -- Geographic Markup Language. + http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 + + OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +} +\keyword{GML} +\keyword{ISO} +\keyword{abstract} +\keyword{general} +\keyword{operation} +\keyword{parameter} + diff --git a/man/GMLOperationMethod.Rd b/man/GMLOperationMethod.Rd new file mode 100644 index 00000000..a69d8e44 --- /dev/null +++ b/man/GMLOperationMethod.Rd @@ -0,0 +1,68 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/GMLOperationMethod.R +\docType{class} +\name{GMLOperationMethod} +\alias{GMLOperationMethod} +\title{GMLOperationMethod} +\format{\code{\link{R6Class}} object.} +\usage{ +GMLOperationMethod +} +\value{ +Object of \code{\link{R6Class}} for modelling an GMLOperationMethod +} +\description{ +GMLOperationMethod +} +\section{Fields}{ + +\describe{ +\item{\code{formulaCitation}}{} + +\item{\code{sourceDimensions}}{} + +\item{\code{targetDimensions}}{} +}} +\section{Inherited methods from \code{GMLDefinition}}{ + +} + +\section{Methods}{ + +\describe{ + \item{\code{new(xml, defaults, id)}}{ + This method is used to instantiate a GML OperationMethod + } + \item{\code{setFormulaCitation(citation)}}{ + Sets the formula citation, object of class \code{ISOCitation} + } + \item{\code{setSourceDimensions(value)}}{ + Sets the number of source dimensions, object of class \code{integer} + } + \item{\code{setTargetDimensions(value)}}{ + Sets the number of target dimensions, object of class \code{integer} + } + \item{\code{addParameter(parameter)}}{ + Adds a parameter or parameter group, object of class \code{GMLOperationParameter} + or \code{GMLOperationParameterGroup} + } + \item{\code{delParameter(parameter)}}{ + Deletes a parameter or parameter group, object of class \code{GMLOperationParameter} + or \code{GMLOperationParameterGroupo} + } +} +} +\author{ +Emmanuel Blondel +} +\references{ +ISO 19136:2007 Geographic Information -- Geographic Markup Language. + http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 + + OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +} +\keyword{GML} +\keyword{ISO} +\keyword{method} +\keyword{operation} + diff --git a/man/GMLOperationParameter.Rd b/man/GMLOperationParameter.Rd new file mode 100644 index 00000000..b9e79242 --- /dev/null +++ b/man/GMLOperationParameter.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/GMLOperationParameter.R +\docType{class} +\name{GMLOperationParameter} +\alias{GMLOperationParameter} +\title{GMLOperationParameter} +\format{\code{\link{R6Class}} object.} +\usage{ +GMLOperationParameter +} +\value{ +Object of \code{\link{R6Class}} for modelling an GMLOperationParameter +} +\description{ +GMLOperationParameter +} +\section{Inherited methods from \code{GMLAbstractGeneralOperationParameter}}{ + +} + +\section{Methods}{ + +\describe{ + \item{\code{new(xml, defaults, id)}}{ + This method is used to instantiate a GML OperationParameter + } +} +} +\author{ +Emmanuel Blondel +} +\references{ +ISO 19136:2007 Geographic Information -- Geographic Markup Language. + http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 + + OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +} +\keyword{GML} +\keyword{ISO} +\keyword{operation} +\keyword{parameter} + diff --git a/man/GMLOperationParameterGroup.Rd b/man/GMLOperationParameterGroup.Rd new file mode 100644 index 00000000..a7a8e01e --- /dev/null +++ b/man/GMLOperationParameterGroup.Rd @@ -0,0 +1,61 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/GMLOperationParameterGroup.R +\docType{class} +\name{GMLOperationParameterGroup} +\alias{GMLOperationParameterGroup} +\title{GMLOperationParameterGroup} +\format{\code{\link{R6Class}} object.} +\usage{ +GMLOperationParameterGroup +} +\value{ +Object of \code{\link{R6Class}} for modelling an GMLOperationParameterGroup +} +\description{ +GMLOperationParameterGroup +} +\section{Fields}{ + +\describe{ +\item{\code{maximumOccurs}}{} + +\item{\code{parameter}}{} +}} +\section{Inherited methods from \code{GMLAbstractGeneralOperationParameter}}{ + +} + +\section{Methods}{ + +\describe{ + \item{\code{new(xml, defaults, id)}}{ + This method is used to instantiate a GML OperationParameterGroup + } + \item{\code{setMaximumOccurs(maximumOccurs)}}{ + Sets the maximum occurs, object of class \code{integer} + } + \item{\code{addParameter(parameter)}}{ + Adds a parameter or parameter group, object of class \code{GMLOperationParameter} + or \code{GMLOperationParameterGroup} + } + \item{\code{delParameter(parameter)}}{ + Deletes a parameter or parameter group, object of class \code{GMLOperationParameter} + or \code{GMLOperationParameterGroupo} + } +} +} +\author{ +Emmanuel Blondel +} +\references{ +ISO 19136:2007 Geographic Information -- Geographic Markup Language. + http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554 + + OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml +} +\keyword{GML} +\keyword{ISO} +\keyword{group} +\keyword{operation} +\keyword{parameter} + diff --git a/tests/testthat/test_GMLOperationParameter.R b/tests/testthat/test_GMLOperationParameter.R new file mode 100644 index 00000000..2f0c706d --- /dev/null +++ b/tests/testthat/test_GMLOperationParameter.R @@ -0,0 +1,85 @@ +# test_GMLOperationParameter.R +# Author: Emmanuel Blondel +# +# Description: Unit tests for GMLOperationParameter.R +#======================= +require(geometa, quietly = TRUE) +require(testthat) +require(XML) + +context("GMLAstractGeneralOperationParameter") + +test_that("GMLAbstractGeneralOperationParameter",{ + + #encoding + gml <- GMLAbstractGeneralOperationParameter$new() + gml$setDescriptionReference("someref") + gml$setIdentifier("identifier", "codespace") + gml$addName("name1", "codespace") + gml$addName("name2", "codespace") + gml$setMinimumOccurs(2L) + xml <- gml$encode(validate=F) + expect_is(xml, "XMLInternalNode") + #decoding + gml2 <- GMLAbstractGeneralOperationParameter$new(xml = xml) + xml2 <- gml2$encode(validate=F) + #identity + expect_true(ISOAbstractObject$compare(gml, gml2)) + +}) + +test_that("GMLOperationParameter",{ + + #encoding + gml <- GMLOperationParameter$new() + gml$setDescriptionReference("someref") + gml$setIdentifier("identifier", "codespace") + gml$addName("name1", "codespace") + gml$addName("name2", "codespace") + gml$setMinimumOccurs(2L) + xml <- gml$encode() + expect_is(xml, "XMLInternalNode") + #decoding + gml2 <- GMLOperationParameter$new(xml = xml) + xml2 <- gml2$encode() + #identity + expect_true(ISOAbstractObject$compare(gml, gml2)) + +}) + +test_that("GMLOperationParameterGroup",{ + + #encoding + gml <- GMLOperationParameterGroup$new() + gml$setDescriptionReference("someref") + gml$setIdentifier("identifier", "codespace") + gml$addName("name1", "codespace") + gml$addName("name2", "codespace") + gml$setMinimumOccurs(2L) + gml$setMaximumOccurs(4L) + + param1 <- GMLOperationParameter$new(id = "ID1") + param1$setDescriptionReference("someref") + param1$setIdentifier("identifier", "codespace") + param1$addName("name1", "codespace") + param1$addName("name2", "codespace") + param1$setMinimumOccurs(2L) + gml$addParameter(param1) + + param2 <- GMLOperationParameter$new(id = "ID2") + param2$setDescriptionReference("someref") + param2$setIdentifier("identifier", "codespace") + param2$addName("name1", "codespace") + param2$addName("name2", "codespace") + param2$setMinimumOccurs(2L) + gml$addParameter(param2) + + xml <- gml$encode() + expect_is(xml, "XMLInternalNode") + #decoding + gml2 <- GMLOperationParameterGroup$new(xml = xml) + xml2 <- gml2$encode() + #identity + expect_true(ISOAbstractObject$compare(gml, gml2)) + +}) \ No newline at end of file