Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/eblondel/ows4R
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jul 9, 2021
2 parents 2e78fa8 + 5b9410f commit 5d18338
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions R/WMSLayer.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,30 @@ WMSLayer <- R6Class("WMSLayer",
saveXML(obj, destfile)
}else if(destext == "json"){
write(obj, destfile)
}
# }else if(destext == "xml"){
# write(obj, destfile)
}

ftFeatures <- NULL
if(destext == "xml"){
xml<- xmlParse(obj)
rootname <- xmlName(xmlChildren(xml)[[1]])
if(rootname == "FeatureInfoResponse"){
#TODO build sf(s) based on a FeatureInfoResponse xml (eg. case of Thredds data servers)
xml_list <- xmlToList(xml)
if("FIELDS" %in% names(xml_list)){
variables = lapply(xml_list[["FIELDS"]], function(x){
outvar <- x
name <- names(x)
attr(outvar, "description") <- name
return(outvar)
})
ftFeatures<-data.frame(variables)
}else{
#THREDDS STRUCTURE
ftFeatures<-data.frame(xml_list,stringsAsFactors=FALSE)
names(ftFeatures)<-gsub("^.*\\.","",names(ftFeatures))
ftFeatures<-sf::st_as_sf(ftFeatures,coords= c("longitude","latitude"))
}
}else{
ftFeatures <- sf::st_read(destfile, quiet = TRUE)
}
Expand Down

0 comments on commit 5d18338

Please sign in to comment.