Skip to content

Commit

Permalink
refactor abstract model + base support of GML model + GML units #55 #47
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jun 20, 2017
1 parent 17a477d commit 427e1aa
Show file tree
Hide file tree
Showing 239 changed files with 2,136 additions and 1,990 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Date: 2017-06-16
Author: Emmanuel Blondel <[email protected]>
Maintainer: Emmanuel Blondel <[email protected]>
Description: Provides facilities to handle reading and writing of geographic metadata
defined with OGC/ISO 19115 and 19139 (XML) standards.
defined with OGC/ISO 19115 and 19110 geographic information metadata standards, and
encoded using the ISO 19139 (XML) standard.
Depends: R (>= 3.1.0)
Imports: R6, XML
Suggests: testthat, roxygen2
Expand Down
28 changes: 13 additions & 15 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Generated by roxygen2 (4.1.1): do not edit by hand

export(GMLTemporalPrimitive)
export(GMLAbstractGML)
export(GMLAbstractObject)
export(GMLAbstractTimeGeometricPrimitive)
export(GMLAbstractTimeObject)
export(GMLAbstractTimePrimitive)
export(GMLBaseUnit)
export(GMLConventionalUnit)
export(GMLDefinition)
export(GMLDerivedUnit)
export(GMLElement)
export(GMLTimePeriod)
export(GMLUnitDefinition)
export(ISOAbstractObject)
export(ISOAddress)
export(ISOAngle)
export(ISOAssociationRole)
Expand All @@ -13,13 +24,12 @@ export(ISOBaseDateTime)
export(ISOBaseDecimal)
export(ISOBaseInteger)
export(ISOBaseReal)
export(ISOBaseTimeBeginPosition)
export(ISOBaseTimeEndPosition)
export(ISOBrowseGraphic)
export(ISOCellGeometry)
export(ISOCharacterSet)
export(ISOCitation)
export(ISOClassification)
export(ISOCodeListValue)
export(ISOCodelist)
export(ISOConformanceResult)
export(ISOConstraint)
Expand Down Expand Up @@ -70,8 +80,6 @@ export(ISOMeasure)
export(ISOMemberName)
export(ISOMetaIdentifier)
export(ISOMetadata)
export(ISOMetadataCodelistElement)
export(ISOMetadataElement)
export(ISOMetadataNamespace)
export(ISOMultiplicity)
export(ISOMultiplicityRange)
Expand Down Expand Up @@ -103,17 +111,7 @@ export(ISOTopicCategory)
export(ISOTopologyLevel)
export(ISOTypeName)
export(ISOURL)
export(ISOUnitOfMeasure)
export(ISOUnlimitedInteger)
export(ISOUomAngle)
export(ISOUomArea)
export(ISOUomCurrency)
export(ISOUomLength)
export(ISOUomScale)
export(ISOUomTime)
export(ISOUomVelocity)
export(ISOUomVolume)
export(ISOUomWeight)
export(ISOVectorSpatialRepresentation)
export(ISOVerticalExtent)
export(fetchISOCodelists)
Expand Down
92 changes: 92 additions & 0 deletions R/GMLAbstractGML.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#' GMLAbstractGML
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML
#' @return Object of \code{\link{R6Class}} for modelling an GML abstract GML
#' @format \code{\link{R6Class}} object.
#'
#' @field descriptionReference
#' @field identifier
#' @field name
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, element, attrs, defaults)}}{
#' This method is used to instantiate a GML abstract GML
#' }
#' \item{\code{setDescriptionReference(descriptionReference)}}{
#' Set the descriptionReference
#' }
#' \item{\code{setIdentifier(identifier)}}{
#' Set the identifier
#' }
#' \item{\code{addName(name)}}{
#' Adds a name
#' }
#' \item{\code{delName(name)}}{
#' Deletes a name
#' }
#' }
#'
#' @note Class used internally by geometa
#'
#' @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 <emmanuel.blondel1@@gmail.com>
#'
GMLAbstractGML <- R6Class("GMLAbstractGML",
inherit = GMLAbstractObject,
private = list(
xmlElement = "AbstractGML",
xmlNamespacePrefix = "GML"
),
public = list(
#+ descriptionReference [0..1]: character
descriptionReference = NULL,
#+ identifier [0..1]: character
identifier = NULL,
#+ name [0..*]: character
name = list(),
initialize = function(xml = NULL, element = NULL, attrs = list(), defaults = list()){
if(is.null(element)) element <- private$xmlElement
super$initialize(xml, element = element, attrs = attrs, defaults = defaults)
},

#setDescriptionReference
setDescriptionReference = function(descriptionReference){
gmlElem <- GMLElement$new(element = "descriptionReference")
gmlElem$setHref(descriptionReference)
self$descriptionReference <- gmlElem
},

#setIdentifier
setIdentifier = function(identifier, codeSpace){
gmlElem <- GMLElement$new(element = "identifier")
gmlElem$setValue(identifier)
gmlElem$setCodeSpace(codeSpace)
self$identifier <- gmlElem
},

#addName
addName = function(name, codeSpace = NULL){
gmlElem <- GMLElement$new(element = "name")
if(!is.null(codeSpace)) gmlElem$setCodeSpace(codeSpace)
gmlElem$setValue(name)
return(self$addListElement("name", gmlElem))
},

#delName
delName = function(name, codeSpace = NULL){
gmlElem <- GMLElement$new(element = "name")
if(!is.null(codeSpace)) gmlElem$setCodeSpace(codeSpace)
gmlElem$setValue(name)
return(self$delListElement("name", gmlElem))
}
)
)
42 changes: 42 additions & 0 deletions R/GMLAbstractObject.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#' GMLAbstractObject
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML
#' @return Object of \code{\link{R6Class}} for modelling an GML abstract object
#' @format \code{\link{R6Class}} object.
#'
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, element, attrs, defaults)}}{
#' This method is used to instantiate an ISOTemporalPrimitive
#' }
#' }
#'
#' @note Class used internally by geometa
#'
#' @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 <emmanuel.blondel1@@gmail.com>
#'
GMLAbstractObject <- R6Class("GMLAbstractObject",
inherit = ISOAbstractObject,
private = list(
xmlElement = "AbstractObject",
xmlNamespacePrefix = "GML"
),
public = list(
initialize = function(xml = NULL, element = NULL, attrs = list(), defaults = list()){
if(is.null(element)) element <- private$xmlElement
super$initialize(xml, element, namespace = private$xmlNamespacePrefix,
attrs = attrs, defaults = defaults,
wrap = FALSE)
}
)
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' GMLTemporalPrimitive
#' GMLAbstractTimeGeometricPrimitive
#'
#' @docType class
#' @importFrom R6 R6Class
Expand All @@ -11,7 +11,7 @@
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, element, namespace, defaults)}}{
#' This method is used to instantiate an ISOTemporalPrimitive
#' This method is used to instantiate an ISOAbstractTimeGeometricPrimitive
#' }
#' }
#'
Expand All @@ -22,15 +22,15 @@
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
GMLTemporalPrimitive <- R6Class("GMLTemporalPrimitive",
inherit = ISOMetadataElement,
GMLAbstractTimeGeometricPrimitive <- R6Class("GMLAbstractTimeGeometricPrimitive",
inherit = GMLAbstractTimePrimitive,
private = list(
xmlElement = "TM_Primitive",
xmlElement = "AbstractTimeGeometricPrimitive",
xmlNamespacePrefix = "GML"
),
public = list(
initialize = function(xml = NULL, element, namespace, defaults = list()){
super$initialize(xml, element, namespace, defaults)
initialize = function(xml = NULL, defaults = list()){
super$initialize(xml, defaults)
}
)
)
47 changes: 47 additions & 0 deletions R/GMLAbstractTimeObject.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#' GMLAbstractTimeObject
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML time object abstract
#' @return Object of \code{\link{R6Class}} for modelling an GML AbstractTimeObject
#' @format \code{\link{R6Class}} object.
#'
#' @field remarks
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, defaults)}}{
#' This method is used to instantiate a GML AbstractTimeObject
#' }
#' \item{\code{setId(id)}}{
#' Sets the id
#' }
#' \item{\code{addRemark(remark)}}{
#' Adds a remark
#' }
#' \item{\code{delRemark(remark)}}{
#' Deletes a remark
#' }
#' }
#'
#' @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 <emmanuel.blondel1@@gmail.com>
#'
GMLAbstractTimeObject <- R6Class("GMLAbstractTimeObject",
inherit = GMLAbstractGML,
private = list(
xmlElement = "AbstractTimeObject",
xmlNamespacePrefix = "GML"
),
public = list(
initialize = function(xml = NULL, defaults = list()){
super$initialize(xml, element = private$xmlElement, defaults)
}
)
)
68 changes: 68 additions & 0 deletions R/GMLAbstractTimePrimitive.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#' GMLAbstractTimePrimitive
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML time primitive abstract
#' @return Object of \code{\link{R6Class}} for modelling an GML AbstractTimePrimitive
#' @format \code{\link{R6Class}} object.
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, defaults)}}{
#' This method is used to instantiate a GML AbstractTimePrimitive
#' }
#' \item{\code{setId(id)}}{
#' Sets the id
#' }
#' \item{\code{addRelatedTime(time)}}{
#' Adds related time, object of class among \code{GMLTimeInstant}, \code{GMLTimePeriod},
#' \code{GMLTimeNode} or \code{GMLTimeEdge}
#' }
#' \item{\code{delRelatedTime(time)}}{
#' Deletes related time
#' }
#' }
#'
#' @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 <emmanuel.blondel1@@gmail.com>
#'
GMLAbstractTimePrimitive <- R6Class("GMLAbstractTimePrimitive",
inherit = GMLAbstractTimeObject,
private = list(
xmlElement = "AbstractTimePrimitive",
xmlNamespacePrefix = "GML"
),
public = list(
initialize = function(xml = NULL, defaults = list()){
super$initialize(xml, defaults)
},

#addRelatedTime
addRelatedTime = function(time){
allowedClasses <- c("GMLTimeInstant", "GMLTimePeriod",
"GMLTimeNode", "GMLTimeEdge")
if(!(class(time)[1] %in% allowedClasses)){
stop(sprintf("The argument value should an object of class among the following classes %s",
paste(allowedClasses, collapse=", ")))
}
return(self$addListElement("relatedTime", time))
},

#delRelatedTime
delRelatedTime = function(time){
allowedClasses <- c("GMLTimeInstant", "GMLTimePeriod",
"GMLTimeNode", "GMLTimeEdge")
if(!(class(time)[1] %in% allowedClasses)){
stop(sprintf("The argument value should an object of class among the following classes %s",
paste(allowedClasses, collapse=", ")))
}
return(self$delListElement("relatedTime", time))
}
)
)
Loading

0 comments on commit 427e1aa

Please sign in to comment.