Skip to content

Commit

Permalink
stick with generic as method
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 26, 2019
1 parent aff0ea6 commit 87104a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 60 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated by roxygen2: do not edit by hand

S3method(as_ISOMetadata,emld)
S3method(as_ISOMetadata,ncdf4)
export(GMLAbstractCRS)
export(GMLAbstractCoordinateOperation)
export(GMLAbstractCoordinateSystem)
Expand Down Expand Up @@ -278,7 +276,6 @@ export(ISOUnlimitedInteger)
export(ISOUsage)
export(ISOVectorSpatialRepresentation)
export(ISOVerticalExtent)
export(as_ISOMetadata)
export(geometaLogger)
export(geometa_coverage)
export(getGeometaOption)
Expand Down
41 changes: 6 additions & 35 deletions R/geometa_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,8 @@ registerMappings <- function(x){

#setters

#' Convert foreign metadata object to an \code{\link{ISOMetadata}} object
#'
#' Convert foreign metadata object to an \code{\link{ISOMetadata}} object
#' @param x object to convert
#' @param ... further arguments
#' @name as_ISOMetadata
#' @export
as_ISOMetadata = function(x, ...) UseMethod("as_ISOMetadata")

#' @name as_ISOMetadata
#' @export
as_ISOMetadata.emld <- function(from){
setOldClass("emld")
setAs("emld", "ISOMetadata", function(from){
if(!requireNamespace("EML", quietly = TRUE))
stop("package EML required, please install it first")
if(!requireNamespace("emld", quietly = TRUE))
Expand All @@ -781,36 +771,17 @@ as_ISOMetadata.emld <- function(from){
out_md <- convert_metadata(in_from, from = "eml", to = "geometa",
mappings = .geometa.mappings$rules, verbose = FALSE)
return(out_md)
}
})

#' @name as_ISOMetadata
#' @export
as_ISOMetadata.ncdf4 <- function(from){
setOldClass("ncdf4")
setAs("ncdf4", "ISOMetadata", function(from){
if(!requireNamespace("ncdf4", quietly = TRUE))
stop("package ncdf4 required, please install it first")
out_md <- convert_metadata(from, from = "eml", to = "geometa",
mappings = .geometa.mappings$rules, verbose = FALSE)
return(out_md)
}

setOldClass("emld")
#' @name as
#' @rdname coerce-methods
#' @aliases coerce,emld,ISOMetadata-method
setAs("emld", "ISOMetadata", function(from) as_ISOMetadata(from))



setOldClass("ncdf4")
#' @name as
#' @rdname coerce-methods
#' @aliases coerce,ncdf4,ISOMetadata-method
setAs("ncdf4", "ISOMetadata", function(from) as_ISOMetadata(from))

})

#' @name as
#' @rdname coerce-methods
#' @aliases coerce,ISOMetadata,emld-method
setAs("ISOMetadata", "emld", function(from){
if(!requireNamespace("EML", quietly = TRUE))
stop("package EML required, please install it first")
Expand Down
22 changes: 0 additions & 22 deletions man/as_ISOMetadata.Rd

This file was deleted.

0 comments on commit 87104a4

Please sign in to comment.