Skip to content

Commit

Permalink
fix #124
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Feb 22, 2024
1 parent 4ce469b commit 162dcea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 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.4
Date: 2024-02-13
Date: 2024-02-23
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")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

- [#122](https://github.com/eblondel/ows4R/issues/122) Service exceptions are not always handled in status code 400
- [#123](https://github.com/eblondel/ows4R/issues/123) Missing axis labels handling for WCS coverage envelope
- [#124](https://github.com/eblondel/ows4R/issues/124) Optimize WFS getFeatures depending on the outputFormat

## [ows4R 0.3-6](https://github.com/eblondel/ows4R) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://github.com/eblondel/ows4R)

Expand Down
20 changes: 18 additions & 2 deletions R/WFSFeatureType.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ WFSFeatureType <- R6Class("WFSFeatureType",
}
}

read_features = TRUE
validate_features = TRUE

#write the file to disk
tempf = tempfile()
if(is.null(outputFormat)){
Expand All @@ -384,19 +387,32 @@ WFSFeatureType <- R6Class("WFSFeatureType",
"application/json" = {
destfile = paste0(tempf,".json")
write(obj, destfile)
validate_features = FALSE
},
"json" = {
destfile = paste0(tempf,".json")
write(obj, destfile)
validate_features = FALSE
},
"csv" = {
destfile = paste0(tempf,".csv")
lcolnames = tolower(colnames(obj))
sf::st_write(obj[,!duplicated(lcolnames)], destfile)
if(self$getGeometryType() %in% colnames(obj)){
sf::st_write(obj[,!duplicated(lcolnames)], destfile)
validate_features = FALSE
}else{
readr::write_csv(obj[,!duplicated(lcolnames)], destfile)
read_features = FALSE
}
}
)
}

if(!read_features){
self$features = obj
return(self$features)
}

#read features
if(!is.null(outputFormat)){
ftFeatures <- switch(tolower(outputFormat),
Expand All @@ -418,7 +434,7 @@ WFSFeatureType <- R6Class("WFSFeatureType",
}

#validating attributes vs. schema
for(element in self$description){
if(validate_features) for(element in self$description){
attrType <- element$getType()
if(!is.null(attrType) && !element$isGeometry()){
attrName = element$getName()
Expand Down

0 comments on commit 162dcea

Please sign in to comment.