Skip to content

Commit

Permalink
#181 readISO19139 -> readISO
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jan 2, 2025
1 parent f75d9b8 commit f0fdd3d
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: geometa
Type: Package
Title: Tools for Reading and Writing ISO/OGC Geographic Metadata
Version: 0.9
Date: 2024-12-30
Date: 2025-01-02
Authors@R: c(
person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-5870-5762")),
person("R Consortium", role = "fnd"))
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ export(getMappings)
export(getMetadataStandard)
export(pivot_converter)
export(pivot_format)
export(readISO)
export(readISO19139)
export(registerISOCodelist)
export(registerISOMetadataNamespace)
Expand Down
55 changes: 48 additions & 7 deletions R/readISO19139.R → R/readISO.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#' @name readISO19139
#' @aliases readISO19139
#' @title readISO19139
#' @name readISO
#' @aliases readISO
#' @title readISO
#' @export
#' @description \code{readISO19139} is a function to read a ISO 19139 from a file
#' @description \code{readISO} is a function to read a ISO metadata from a file
#' or url into an object in the \pkg{geometa} model.
#'
#' @usage readISO19139(file, url, raw)
#' @usage readISO(file, url, raw)
#'
#' @param file a valid file path, as object of class \code{character}
#' @param url a valid URL, as object of class \code{character}
Expand All @@ -18,12 +18,12 @@
#' @examples
#' \donttest{
#' mdfile <- system.file("extdata/examples", "metadata.xml", package = "geometa")
#' md <- readISO19139(mdfile)
#' md <- readISO(mdfile)
#' }
#'
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#'
readISO19139 <- function(file = NULL, url = NULL, raw = FALSE){
readISO <- function(file = NULL, url = NULL, raw = FALSE){

cacheISOClasses()

Expand Down Expand Up @@ -57,6 +57,16 @@ readISO19139 <- function(file = NULL, url = NULL, raw = FALSE){
if(raw){
out <- raw_xml
}else{
#inspect namespace
version <- switch(XML::xmlNamespace(raw_xml),
"http://www.isotc211.org/2005/gmd" = "19139",
"http://standards.iso.org/iso/19115/-3/mdb/2.0" = "19115-3",
"http://www.isotc211.org/2005/gfc" = "19139",
"http://standards.iso.org/iso/19110/gfc/1.1" = "19115-3",
"19139"
)
setMetadataStandard(version)
#instantiate object
iso_class <- ISOAbstractObject$getISOClassByNode(raw_xml)
if(!is.null(iso_class)){
out <- iso_class$new(xml = raw_xml)
Expand All @@ -66,3 +76,34 @@ readISO19139 <- function(file = NULL, url = NULL, raw = FALSE){
return(out)
}


#' @name readISO19139
#' @aliases readISO19139
#' @title readISO19139
#' @export
#' @description \code{readISO19139} is a function to read a ISO 19139 from a file
#' or url into an object in the \pkg{geometa} model.
#'
#' @usage readISO19139(file, url, raw)
#'
#' @param file a valid file path, as object of class \code{character}
#' @param url a valid URL, as object of class \code{character}
#' @param raw indicates if the function should return the raw XML. By
#' default this is set to \code{FALSE} and the function will try to map
#' the xml data to the \pkg{geometa} data model.
#'
#' @return a \pkg{geometa} object inheriting \code{ISOAbstractObject}
#'
#' @examples
#' \donttest{
#' mdfile <- system.file("extdata/examples", "metadata.xml", package = "geometa")
#' md <- readISO19139(mdfile)
#' }
#'
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#'
readISO19139 <- function(file = NULL, url = NULL, raw = FALSE){
warnings("'readISO19139' is deprecated, consider using 'readISO' function")
readISO(file = file, url = url, raw = raw)
}

34 changes: 34 additions & 0 deletions man/readISO.Rd

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

2 changes: 1 addition & 1 deletion man/readISO19139.Rd

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

0 comments on commit f0fdd3d

Please sign in to comment.