From d3f1609dc94d6b4228aa86726446b47edf5c2c0c Mon Sep 17 00:00:00 2001 From: eblondel Date: Mon, 3 Feb 2025 21:16:19 +0100 Subject: [PATCH] support #140 --- DESCRIPTION | 2 +- R/CSWGetRecordById.R | 43 ++++++++++++++++++++++++++++++++++++++++--- R/CSWGetRecords.R | 30 ++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7a19d1c..96f7505 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ows4R Version: 0.5 -Date: 2025-01-31 +Date: 2025-02-03 Title: Interface to OGC Web-Services (OWS) Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")), person("Alexandre", "Bennici", role = c("ctb"), comment = c(ORCID = "0000-0003-2160-3487")), diff --git a/R/CSWGetRecordById.R b/R/CSWGetRecordById.R index e0d8882..c7bb803 100644 --- a/R/CSWGetRecordById.R +++ b/R/CSWGetRecordById.R @@ -79,17 +79,30 @@ CSWGetRecordById <- R6Class("CSWGetRecordById", #check response in case of ISO ns <- getOWSNamespace(private$xmlNamespacePrefix) outputSchema <- self$attrs$outputSchema - isoSchemas <- c("http://www.isotc211.org/2005/gmd","http://www.isotc211.org/2005/gfc") + isoSchemas <- c( + "http://www.isotc211.org/2005/gmd", + "http://standards.iso.org/iso/19115/-3/mdb/2.0", + "http://www.isotc211.org/2005/gfc", + "http://standards.iso.org/iso/19110/gfc/1.1" + ) if(outputSchema %in% isoSchemas){ xmltxt <- as(private$response, "character") isMetadata <- regexpr("MD_Metadata", xmltxt)>0 isFeatureCatalogue <- regexpr("FC_FeatureCatalogue", xmltxt)>0 - if(isMetadata && outputSchema == isoSchemas[2]){ + if(isMetadata && outputSchema == isoSchemas[3]){ outputSchema <- isoSchemas[1] message(sprintf("Metadata detected! Switch to schema '%s'!", outputSchema)) } - if(isFeatureCatalogue && outputSchema == isoSchemas[1]){ + if(isMetadata && outputSchema == isoSchemas[4]){ outputSchema <- isoSchemas[2] + message(sprintf("Metadata detected! Switch to schema '%s'!", outputSchema)) + } + if(isFeatureCatalogue && outputSchema == isoSchemas[1]){ + outputSchema <- isoSchemas[3] + message(sprintf("FeatureCatalogue detected! Switch to schema '%s'!", outputSchema)) + } + if(isFeatureCatalogue && outputSchema == isoSchemas[2]){ + outputSchema <- isoSchemas[4] message(sprintf("FeatureCatalogue detected! Switch to schema '%s'!", outputSchema)) } } @@ -101,6 +114,18 @@ CSWGetRecordById <- R6Class("CSWGetRecordById", xmlObjs <- getNodeSet(private$response, "//ns:MD_Metadata", c(ns = outputSchema)) if(length(xmlObjs)>0){ xmlObj <- xmlObjs[[1]] + geometa::setMetadataStandard("19139") + out <- geometa::ISOMetadata$new() + out$decode(xml = xmlObj) + } + out + }, + "http://standards.iso.org/iso/19115/-3/mdb/2.0" = { + out <- NULL + xmlObjs <- getNodeSet(private$response, "//ns:MD_Metadata", c(ns = outputSchema)) + if(length(xmlObjs)>0){ + xmlObj <- xmlObjs[[1]] + geometa::setMetadataStandard("19115-3") out <- geometa::ISOMetadata$new() out$decode(xml = xmlObj) } @@ -111,6 +136,18 @@ CSWGetRecordById <- R6Class("CSWGetRecordById", xmlObjs <- getNodeSet(private$response, "//ns:FC_FeatureCatalogue", c(ns = outputSchema)) if(length(xmlObjs)>0){ xmlObj <- xmlObjs[[1]] + geometa::setMetadataStandard("19139") + out <- geometa::ISOFeatureCatalogue$new() + out$decode(xml = xmlObj) + } + out + }, + "http://standards.iso.org/iso/19110/gfc/1.1" = { + out <- NULL + xmlObjs <- getNodeSet(private$response, "//ns:FC_FeatureCatalogue", c(ns = outputSchema)) + if(length(xmlObjs)>0){ + xmlObj <- xmlObjs[[1]] + geometa::setMetadataStandard("19115-3") out <- geometa::ISOFeatureCatalogue$new() out$decode(xml = xmlObj) } diff --git a/R/CSWGetRecords.R b/R/CSWGetRecords.R index 88cc0c7..9c5d634 100644 --- a/R/CSWGetRecords.R +++ b/R/CSWGetRecords.R @@ -95,7 +95,9 @@ CSWGetRecords <- R6Class("CSWGetRecords", #typeNames value to pass to CSWQuery typeNames <- switch(self$attrs$outputSchema, "http://www.isotc211.org/2005/gmd" = "gmd:MD_Metadata", + "http://standards.iso.org/iso/19115/-3/mdb/2.0" = "mdb:MD_Metadata", "http://www.isotc211.org/2005/gfc" = "gfc:FC_FeatureCatalogue", + "http://standards.iso.org/iso/19110/gfc/1.1" = "gfc:FC_FeatureCatalogue", "http://www.opengis.net/cat/csw/2.0.2" = "csw:Record", "http://www.opengis.net/cat/csw/3.0" = "csw30:Record", "http://www.w3.org/ns/dcat#" = "dcat" @@ -150,6 +152,20 @@ CSWGetRecords <- R6Class("CSWGetRecords", attributes(out) <- searchResultsAttrs out }, + "http://standards.iso.org/iso/19115/-3/mdb/2.0" = { + out <- NULL + xmlObjs <- getNodeSet(private$response, "//ns:MD_Metadata", c(ns = outputSchema)) + if(length(xmlObjs)>0){ + out <- lapply(xmlObjs,function(xmlObj){ + geometa::setMetadataStandard("19115-3") + out.obj <- geometa::ISOMetadata$new() + out.obj$decode(xml = xmlObj) + return(out.obj) + }) + } + attributes(out) <- searchResultsAttrs + out + }, "http://www.isotc211.org/2005/gfc" = { out <- NULL xmlObjs <- getNodeSet(private$response, "//ns:FC_FeatureCatalogue", c(ns = outputSchema)) @@ -163,6 +179,20 @@ CSWGetRecords <- R6Class("CSWGetRecords", attributes(out) <- searchResultsAttrs out }, + "http://standards.iso.org/iso/19110/gfc/1.1" = { + out <- NULL + xmlObjs <- getNodeSet(private$response, "//ns:FC_FeatureCatalogue", c(ns = outputSchema)) + if(length(xmlObjs)>0){ + out <- lapply(xmlObjs,function(xmlObj){ + geometa::setMetadataStandard("19115-3") + out.obj <- geometa::ISOFeatureCatalogue$new() + out.obj$decode(xml = xmlObj) + return(out.obj) + }) + } + attributes(out) <- searchResultsAttrs + out + }, "http://www.opengis.net/cat/csw/2.0.2" = { warnMsg <- sprintf("R Dublin Core binding not yet supported for '%s'", outputSchema) warnings(warnMsg)