Skip to content

Commit

Permalink
#181 support M5 - MDB class + main test for ISOMetadata in ISO 19115-3
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Dec 8, 2024
1 parent aea94cc commit 53276e2
Show file tree
Hide file tree
Showing 48 changed files with 5,478 additions and 2,167 deletions.
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ export(ISOCoverageDescription)
export(ISODCPList)
export(ISODataFile)
export(ISODataIdentification)
export(ISODataIdentification19115_3)
export(ISODataIdentification19139)
export(ISODataQuality)
export(ISODataQualityAbstractElement)
export(ISODataQualityScope)
Expand Down Expand Up @@ -222,7 +224,8 @@ export(ISOGeoreferenceable)
export(ISOGridSpatialRepresentation)
export(ISOGriddedDataPositionalAccuracy)
export(ISOIdentification)
export(ISOIdentifier)
export(ISOIdentification19115_3)
export(ISOIdentification19139)
export(ISOImageDescription)
export(ISOImageryAbstractGeolocationInformation)
export(ISOImageryAcquisitionInformation)
Expand Down
38 changes: 29 additions & 9 deletions R/ISOCitation.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOCitation<- R6Class("ISOCitation",
inherit = ISOAbstractObject,
inherit = ISOAbstractCitation,
private = list(
xmlElement = "CI_Citation",
xmlNamespacePrefix = list(
Expand Down Expand Up @@ -262,24 +262,44 @@ ISOCitation<- R6Class("ISOCitation",
},

#'@description Adds cited responsible party
#'@param rp cited responsible party, object of class \link{ISOResponsibleParty}
#'@param rp cited responsible party, object of class \link{ISOResponsibleParty} (in ISO 19139) or
#'\link{ISOResponsibility} (in ISO 19115-3)
#'@param locales list of localized responsible parties. Default is \code{NULL}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addCitedResponsibleParty = function(rp){
if(!is(rp, "ISOResponsibleParty")){
stop("The argument should be a 'ISOResponsibleParty' object")
}
switch(getMetadataStandard(),
"19139" = {
if(!is(rp, "ISOResponsibleParty")){
stop("The argument should be a 'ISOResponsibleParty' object")
}
},
"19115-3" = {
if(!is(rp, "ISOResponsibility")){
stop("The argument should be a 'ISOResponsibility' object")
}
}
)
return(self$addListElement("citedResponsibleParty", rp))
},

#'@description Deletes cited responsible party
#'@param rp cited responsible party, object of class \link{ISOResponsibleParty}
#'@param rp cited responsible party, object of class \link{ISOResponsibleParty} (in ISO 19139) or
#'\link{ISOResponsibility} (in ISO 19115-3)
#'@param locales list of localized responsible parties. Default is \code{NULL}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delCitedResponsibleParty = function(rp){
if(!is(rp, "ISOResponsibleParty")){
stop("The argument should be a 'ISOResponsibleParty' object")
}
switch(getMetadataStandard(),
"19139" = {
if(!is(rp, "ISOResponsibleParty")){
stop("The argument should be a 'ISOResponsibleParty' object")
}
},
"19115-3" = {
if(!is(rp, "ISOResponsibility")){
stop("The argument should be a 'ISOResponsibility' object")
}
}
)
return(self$delListElement("citedResponsibleParty", rp))
},

Expand Down
2 changes: 1 addition & 1 deletion R/ISOCodeListValue.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ISOCodeListValue <- R6Class("ISOCodeListValue",

if(!is.null(value) & length(clEntry)>0){
clEntry <- clEntry[[1]]
clValue <- clEntry$identifier
clValue <- if(is(clEntry$identifier, "ISOScopedName")) clEntry$identifier$value else clEntry$identifier
clName <- clEntry$description
clDescription <- clEntry$description
if(setValueDescription) clDescription <- clEntry$description
Expand Down
7 changes: 7 additions & 0 deletions R/ISOCodelist.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ getISOCodelist <- function(id){
codelist <<- cl
}
}))
if(getMetadataStandard()=="19115-3" & is.null(codelist)){
invisible(lapply(getISOInternalCodelists()[["19139"]], function(cl){
if(cl$identifier$value == id){
codelist <<- cl
}
}))
}
return(codelist)
}

Expand Down
93 changes: 87 additions & 6 deletions R/ISOContact.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,124 @@ ISOContact <- R6Class("ISOContact",
),
public = list(
#'@field phone phone
phone = NULL,
phone = list(),
#'@field address address
address = NULL,
address = list(),
#'@field onlineResource online resource
onlineResource = NULL,
onlineResource = list(),
#'@field hoursOfService hours of service
hoursOfService = list(),
#'@field contactInstructions contact instructions
contactInstructions = NULL,
#'@field contactType contact type
contactType = NULL,

#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
initialize = function(xml = NULL){
super$initialize(xml = xml)
},

#'@description Set phone
#'@description Set phone (with ISO 19139)
#'@param phone object of class \link{ISOTelephone}
setPhone = function(phone){
self$stopIfMetadataStandardIsNot("19139")
if(!is(phone, "ISOTelephone")){
stop("The argument should be a 'ISOTelephone' object")
}
self$phone = phone
},

#'@description Set address
#'@description Adds phone (with ISO 19115-3)
#'@param phone object tof class \link{ISOTelephone}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addPhone = function(phone){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(phone, "ISOTelephone")){
stop("The argument should be a 'ISOTelephone' object")
}
if(is.null(self$phone)) self$phone = list()
return(self$addListElement("phone", phone))
},

#'@description Deletes phone (with ISO 19115-3)
#'@param phone object tof class \link{ISOTelephone}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delPhone = function(phone){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(phone, "ISOTelephone")){
stop("The argument should be a 'ISOTelephone' object")
}
if(is.null(self$phone)) self$phone = list()
return(self$delListElement("phone", phone))
},

#'@description Set address (with ISO 19139)
#'@param address object of class \link{ISOAddress}
setAddress = function(address){
self$stopIfMetadataStandardIsNot("19139")
if(!is(address, "ISOAddress")){
stop("The argument should be a 'ISOAddress' object")
}
self$address = address
},

#'@description Set online resource
#'@description Adds address (with ISO 19115-3)
#'@param address object of class \link{ISOAddress}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addAddress = function(address){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(address, "ISOAddress")){
stop("The argument should be a 'ISOAddress' object")
}
if(is.null(self$address)) self$address = list()
return(self$addListElement("address", address))
},

#'@description Deletes address (with ISO 19115-3)
#'@param address object of class \link{ISOAddress}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delAddress = function(address){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(address, "ISOAddress")){
stop("The argument should be a 'ISOAddress' object")
}
if(is.null(self$address)) self$address = list()
return(self$delListElement("address", address))
},

#'@description Set online resource (with ISO 19139)
#'@param onlineResource online resource, object of class \link{ISOOnlineResource}
setOnlineResource = function(onlineResource){
self$stopIfMetadataStandardIsNot("19139")
if(!is(onlineResource, "ISOOnlineResource")){
stop("The argument should be a 'ISOOnlineResource' object")
}
self$onlineResource = onlineResource
},

#'@description Adds online resource (with ISO 19115-3)
#'@param onlineResource online resource, object of class \link{ISOOnlineResource}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addOnlineResource = function(onlineResource){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(onlineResource, "ISOOnlineResource")){
stop("The argument should be a 'ISOOnlineResource' object")
}
if(is.null(self$onlineResource)) self$onlineResource = list()
return(self$addListElement("onlineResource", onlineResource))
},

#'@description Deletes online resource (with ISO 19115-3)
#'@param onlineResource online resource, object of class \link{ISOOnlineResource}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delOnlineResource = function(onlineResource){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(onlineResource, "ISOOnlineResource")){
stop("The argument should be a 'ISOOnlineResource' object")
}
if(is.null(self$onlineResource)) self$onlineResource = list()
return(self$delListElement("onlineResource", onlineResource))
}
)
)
Loading

0 comments on commit 53276e2

Please sign in to comment.