From fd861f326254b134b067011787bccd81dc32b83f Mon Sep 17 00:00:00 2001 From: eblondel Date: Wed, 26 Jun 2024 10:50:47 +0200 Subject: [PATCH] fix #128 --- DESCRIPTION | 2 +- NEWS.md | 1 + R/WFSFeatureType.R | 8 +++----- man/WFSFeatureType.Rd | 3 +++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c109c33..1216f9c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ows4R Version: 0.4 -Date: 2024-06-25 +Date: 2024-06-26 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/NEWS.md b/NEWS.md index fc379ba..1cb04cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,7 @@ - [#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 - [#126](https://github.com/eblondel/ows4R/issues/126) Add skipXmlComments as internal arg for OWS http XML requests +- [#128](https://github.com/eblondel/ows4R/issues/128) Make feature validation as arg, and default to TRUE for backward compatibility ## [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) diff --git a/R/WFSFeatureType.R b/R/WFSFeatureType.R index 156cb8c..aafdcc8 100644 --- a/R/WFSFeatureType.R +++ b/R/WFSFeatureType.R @@ -277,6 +277,7 @@ WFSFeatureType <- R6Class("WFSFeatureType", #'@description Get features #'@param typeName the name of the feature type #'@param ... any other parameter to pass to the \link{WFSGetFeature} request + #'@param validate Whether features have to be validated vs. the feature type description. Default is \code{TRUE} #'@param outputFormat output format #'@param paging paging. Default is \code{FALSE} #'@param paging_length number of features to request per page. Default is 1000 @@ -285,6 +286,7 @@ WFSFeatureType <- R6Class("WFSFeatureType", #'@param cl optional cluster object for parallel cluster approaches using eg. \code{parallel::makeCluster} #'@return features as object of class \code{sf} getFeatures = function(..., + validate = TRUE, outputFormat = NULL, paging = FALSE, paging_length = 1000, parallel = FALSE, parallel_handler = NULL, cl = NULL){ @@ -367,7 +369,6 @@ WFSFeatureType <- R6Class("WFSFeatureType", } read_features = TRUE - validate_features = TRUE #write the file to disk tempf = tempfile() @@ -387,19 +388,16 @@ 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)) 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 @@ -434,7 +432,7 @@ WFSFeatureType <- R6Class("WFSFeatureType", } #validating attributes vs. schema - if(validate_features) for(element in self$description){ + if(validate) for(element in self$description){ attrType <- element$getType() if(!is.null(attrType) && !element$isGeometry()){ attrName = element$getName() diff --git a/man/WFSFeatureType.Rd b/man/WFSFeatureType.Rd index 25cb13c..a6325b5 100644 --- a/man/WFSFeatureType.Rd +++ b/man/WFSFeatureType.Rd @@ -269,6 +269,7 @@ Get features \subsection{Usage}{ \if{html}{\out{
}}\preformatted{WFSFeatureType$getFeatures( ..., + validate = TRUE, outputFormat = NULL, paging = FALSE, paging_length = 1000, @@ -283,6 +284,8 @@ Get features \describe{ \item{\code{...}}{any other parameter to pass to the \link{WFSGetFeature} request} +\item{\code{validate}}{Whether features have to be validated vs. the feature type description. Default is \code{TRUE}} + \item{\code{outputFormat}}{output format} \item{\code{paging}}{paging. Default is \code{FALSE}}