Skip to content

Commit

Permalink
#152 MI_Event --> ISOImageryEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jun 4, 2019
1 parent 7463cc2 commit aaa6f90
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export(ISOImageryBandDefinition)
export(ISOImageryContext)
export(ISOImageryCoverageDescription)
export(ISOImageryEnvironmentalRecord)
export(ISOImageryEvent)
export(ISOImageryGeometryType)
export(ISOImageryImageDescription)
export(ISOImageryInstrument)
Expand Down
200 changes: 200 additions & 0 deletions R/ISOImageryEvent.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#' ISOImageryEvent
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO imagery event
#' @return Object of \code{\link{R6Class}} for modelling an ISO imagery event
#' @format \code{\link{R6Class}} object.
#'
#' @field identifier [\code{\link{ISOMetaIdentifier}}]
#' @field trigger [\code{\link{ISOImageryTrigger}}]
#' @field context [\code{\link{ISOImageryContext}}]
#' @field sequence [\code{\link{ISOImagerySequence}}]
#' @field time [\code{\link{POSIXt}}]
#' @field relatedPass [\code{\link{ISOImageryPlatformPass}}]
#' @field relatedSensor [\code{list} of \code{\link{ISOImageryInstrument}}]
#' @field expectedObjective [\code{list} of \code{\link{ISOImageryObjective}}]

#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml)}}{
#' This method is used to instantiate an \code{\link{ISOImageryEvent}}
#' }
#' \item{\code{setIdentifier(identifier)}}{
#' Sets an identifier, object of class \code{character} or \code{\link{ISOMetaIdentifier}}
#' }
#' \item{\code{setTrigger(trigger)}}{
#' Set the trigger, object of class \code{\link{ISOImageryTrigger}}, or 'character' among
#' values given by \code{ISOImageryTrigger$values()}, or free text.
#' }
#' \item{\code{setContext(context)}}{
#' Set the context, object of class \code{\link{ISOImageryContext}}, or 'character' among
#' values given by \code{ISOImageryContext$values()}, or free text.
#' }
#' \item{\code{setSequence(sequence)}}{
#' Set the sequence, object of class \code{\link{ISOImagerySequence}}, or 'character' among
#' values given by \code{ISOImagerySequence$values()}, or free text.
#' }
#' \item{\code{setTime(time)}}{
#' Set the time, object of class \code{\link{POSIXt}}.
#' }
#' \item{\code{setPlatformPass(platformPass)}}{
#' Set the platform pass, object of class \code{\link{ISOImageryPlatformPass}}
#' }
#' \item{\code{addSensor(sensor)}}{
#' Adds a sensor, object of class \code{\link{ISOImageryInstrument}}.
#' }
#' \item{\code{delSensor(sensor)}}{
#' Deletes a sensor, object of class \code{\link{ISOImageryInstrument}}
#' }
#' \item{\code{addObjective(objective)}}{
#' Adds an objective, object of class \code{\link{ISOImageryObjective}}
#' }
#' \item{\code{delObjective(objective)}}{
#' Deletes an objective, object of class \code{\link{ISOImageryObjective}}
#' }
#' }
#'
#' @examples
#' md <- ISOImageryEvent$new()
#' md$setIdentifier("event_1")
#' md$setTrigger("manual")
#' md$setContext("pass")
#' md$setSequence("instantaneaous")
#' md$setTime(Sys.time())
#'
#' xml <- md$encode()
#'
#' @references
#' ISO 19115-2:2009 - Geographic information -- Metadata Part 2: Extensions for imagery and gridded data
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOImageryEvent <- R6Class("ISOImageryEvent",
inherit = ISOAbstractObject,
private = list(
xmlElement = "MI_Event",
xmlNamespacePrefix = "GMI"
),
public = list(

#+ identifier [1..1]: ISOMetaIdentifier
identifier = NULL,
#+ trigger [1..1]: ISOImageryTrigger
trigger = NULL,
#+ context [1..1]: ISOImageryContext
context = NULL,
#+ sequence [1..1]: ISOImagerySequence
sequence = NULL,
#+ time [1..1]: POSIXt
time = NULL,
#+ relatedPass [0..1]: ISOImageryPlatformPass
relatedPass = NULL,
#+ relatedSensor [0..*]: ISOImageryInstrument
relatedSensor = list(),
#+ expectedObjective [0..*]: ISOImageryObjective
expectedObjective = list(),

initialize = function(xml = NULL){
super$initialize(xml = xml)
},

#setIdentifier
setIdentifier = function(identifier){
if(is(identifier, "character")){
identifier <- ISOMetaIdentifier$new(code = identifier)
}else{
if(!is(identifier, "ISOMetaIdentifier")){
stop("The argument should be an object of class 'character' or 'ISOMetaIdentifier'")
}
}
self$identifier <- identifier
},

#setTrigger
setTrigger = function(trigger){
if(is(trigger,"character")){
trigger <- ISOImageryTrigger$new(value = trigger)
}else{
if(!is(trigger, "ISOImageryTrigger")){
stop("The argument should be an object of class 'character' or'ISOImageryTrigger'")
}
}
self$trigger <- trigger
},

#setContext
setContext = function(context){
if(is(context,"character")){
context <- ISOImageryContext$new(value = context)
}else{
if(!is(context, "ISOImageryContext")){
stop("The argument should be an object of class 'character' or'ISOImageryContext'")
}
}
self$context <- context
},

#setSequence
setSequence = function(sequence){
if(is(sequence, "character")){
sequence <- ISOImagerySequence$new(value = sequence)
}else{
if(!is(sequence, "ISOImagerySequence")){
stop("The argument should be an object of class 'character' or 'ISOImagerySequence'")
}
}
self$sequence <- sequence
},

#setTime
setTime = function(time){
if(!is(time, "POSIXt")){
stop("The argument should be an object of class 'POSIXt'")
}
self$time <- time
},

#setPlatformPass
setPlatformPass = function(platformPass){
if(!is(platformPass, "ISOImageryPlatformPass")){
stop("The argument should be an object of class 'ISOImageryPlatformPass'")
}
self$relatedPass <- platformPass
},

#addSensor
addSensor = function(sensor){
if(!is(sensor, "ISOImageryInstrument")){
stop("The argument should be an object of class 'ISOImageryInstrument'")
}
return(self$addListElement("relatedSensor", sensor))
},

#delSensor
delSensor = function(sensor){
if(!is(sensor, "ISOImageryInstrument")){
stop("The argument should be an object of class 'ISOImageryInstrument'")
}
return(self$delListElement("relatedSensor", sensor))
},

#addObjective
addObjective = function(objective){
if(!is(objective, "ISOImageryObjective")){
stop("The argument should be an object of class 'ISOImageryObjective'")
}
return(self$addListElement("expectedObjective", objective))
},

#delObjective
delObjective = function(objective){
if(!is(objective, "ISOImageryObjective")){
stop("The argument should be an object of class 'ISOImageryObjective'")
}
return(self$delListElement("expectedObjective", objective))
}
)
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ We thank in advance people that use ``geometa`` for citing it in their work / pu
|:------------------------------------|:-----------------------------------------------------------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------|---------:|-------:|
|ISO/TC211 19110:2005 |Geographic Information - Methodology for feature cataloguing |GFC |[![ISO/TC211 19110:2005](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 17| 0|
|ISO/TC211 19115-1:2003 |Geographic Information - Metadata |GMD |[![ISO/TC211 19115-1:2003](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 132| 0|
|ISO/TC211 19115-2:2009 |Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data |GMI |[![ISO/TC211 19115-2:2009](https://img.shields.io/badge/-55%25-f9ae2c.svg)](https://github.com/eblondel/geometa) | 22| 18|
|ISO/TC211 19115-2:2009 |Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data |GMI |[![ISO/TC211 19115-2:2009](https://img.shields.io/badge/-58%25-f9ae2c.svg)](https://github.com/eblondel/geometa) | 23| 17|
|ISO/TC211 19119:2005 |Geographic Information - Service Metadata |SRV |[![ISO/TC211 19119:2005](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 7| 12|
|ISO/TC211 19139:2007 |Geographic Metadata XML Schema |GMX |[![ISO/TC211 19139:2007](https://img.shields.io/badge/-6%25-ad0f0f.svg)](https://github.com/eblondel/geometa) | 4| 62|
|ISO/TS 19103:2005 |Geographic Common extensible markup language |GCO |[![ISO/TS 19103:2005](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 22| 0|
Expand Down
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 @@ -161,7 +161,7 @@
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_ContextCode","ISOImageryContext",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_CoverageDescription","ISOImageryCoverageDescription",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_EnvironmentalRecord","ISOImageryEnvironmentalRecord",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_Event","<missing>",FALSE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_Event","ISOImageryEvent",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GCP","<missing>",FALSE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GCPCollection","<missing>",FALSE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GeometryTypeCode","ISOImageryGeometryType",TRUE
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
@@ -1,7 +1,7 @@
"Standard","Title","Namespace","Supported","Missing","Coverage"
"ISO/TC211 19110:2005","Geographic Information - Methodology for feature cataloguing","GFC",17,0,100
"ISO/TC211 19115-1:2003","Geographic Information - Metadata","GMD",132,0,100
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI",22,18,55
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI",23,17,57.5
"ISO/TC211 19119:2005","Geographic Information - Service Metadata","SRV",7,12,36.84
"ISO/TC211 19139:2007","Geographic Metadata XML Schema","GMX",4,62,6.06
"ISO/TS 19103:2005","Geographic Common extensible markup language","GCO",22,0,100
Expand Down
98 changes: 98 additions & 0 deletions man/ISOImageryEvent.Rd

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

32 changes: 32 additions & 0 deletions tests/testthat/test_ISOImageryEvent.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# test_ISOImageryEvent.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Unit tests for ISOImageryEvent.R
#=======================
require(geometa, quietly = TRUE)
require(testthat)

context("ISOImageryEvent")

test_that("encoding",{
testthat::skip_on_cran()
testthat::skip_on_travis()
#encoding
md <- ISOImageryEvent$new()
md$setIdentifier("event_1")
md$setTrigger("manual")
md$setContext("pass")
md$setSequence("instantaneous")
md$setTime(Sys.time())

expect_is(md, "ISOImageryEvent")
xml <- md$encode()
expect_is(xml, "XMLInternalNode")

#decoding
md2 <- ISOImageryEvent$new(xml = xml)
xml2 <- md2$encode()

expect_true(ISOAbstractObject$compare(md, md2))

})

0 comments on commit aaa6f90

Please sign in to comment.