Skip to content

Commit

Permalink
support #140
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Feb 3, 2025
1 parent 15aaf00 commit d3f1609
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", comment = c(ORCID = "0000-0002-5870-5762")),
person("Alexandre", "Bennici", role = c("ctb"), comment = c(ORCID = "0000-0003-2160-3487")),
Expand Down
43 changes: 40 additions & 3 deletions R/CSWGetRecordById.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
30 changes: 30 additions & 0 deletions R/CSWGetRecords.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down

0 comments on commit d3f1609

Please sign in to comment.