Skip to content

Commit

Permalink
patch for #125
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Feb 28, 2024
1 parent 162dcea commit bdff730
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/WFSFeatureType.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ WFSFeatureType <- R6Class("WFSFeatureType",
namespaces <- OWSUtils$getNamespaces(xmlObj)
xsdNs <- OWSUtils$findNamespace(namespaces, "XMLSchema")
elementXML <- getNodeSet(xmlObj, "//ns:sequence/ns:element", xsdNs)
elements <- lapply(elementXML, WFSFeatureTypeElement$new)
elements <- lapply(elementXML, WFSFeatureTypeElement$new, namespaces)
self$description <- elements
out <- self$description
if(pretty){
Expand Down
13 changes: 8 additions & 5 deletions R/WFSFeatureTypeElement.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ WFSFeatureTypeElement <- R6Class("WFSFeatureTypeElement",
geometry = FALSE,

#fetchElement
fetchElement = function(xmlObj){
fetchElement = function(xmlObj, namespaces){

#minOccurs
elementMinOccurs <- xmlGetAttr(xmlObj, "minOccurs")
Expand All @@ -46,8 +46,10 @@ WFSFeatureTypeElement <- R6Class("WFSFeatureTypeElement",
if(is.null(type)){
stop(sprintf("Unknown data type for type '%s' while parsing FeatureType description!", type))
}
if(attr(regexpr("gml", type), "match.length") > 0){
elementType <- unlist(strsplit(unlist(strsplit(type, "gml:"))[2], "PropertyType"))[1]

gml_xmlns = namespaces[namespaces$uri =="http://www.opengis.net/gml",]$id
if(attr(regexpr(gml_xmlns, type), "match.length") > 0){
elementType <- unlist(strsplit(unlist(strsplit(type, paste0(gml_xmlns,":")))[2], "PropertyType"))[1]
geometry <- TRUE
}else{
baseType <- tolower(type)
Expand Down Expand Up @@ -86,8 +88,9 @@ WFSFeatureTypeElement <- R6Class("WFSFeatureTypeElement",

#'@description Initializes a \link{WFSFeatureTypeElement}
#'@param xmlObj object of class \link{XMLInternalNode-class} from \pkg{XML}
initialize = function(xmlObj){
element = private$fetchElement(xmlObj)
#'@param namespaces namespaces definitions inherited from parent XML, as \code{data.frame}
initialize = function(xmlObj, namespaces){
element = private$fetchElement(xmlObj, namespaces)
private$minOccurs = element$minOccurs
private$maxOccurs = element$maxOccurs
private$nillable = element$nillable
Expand Down

0 comments on commit bdff730

Please sign in to comment.