EMODnet / emodnet.wfs

Access EMODnet Web Feature Service data through R
https://emodnet.github.io/emodnet.wfs/
Other
8 stars 4 forks source link

Client creation fails but http status is 200 #92

Closed salvafern closed 1 year ago

salvafern commented 2 years ago
library("EMODnetWFS")
wfs <- emodnet_init_wfs_client(service = "biology_occurrence_data")
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> x WFS client creation failed.
#> i Service: 'https://geo.vliz.be/geoserver/Dataportal/wfs'
#> i HTTP Status: Success: (200) OK
#> Error: An exception has occurred. Please raise an issue in https://github.com/EMODnet/EMODnetWFS/issues

However this is solved if the user agent and config are removed in: https://github.com/EMODnet/EMODnetWFS/blob/5ada1209b91514e135e78c82e02ca5d7021b5199/R/client.R#L35

The issue is in ows4R when creating a new client.

Happening in master branch in Windows.

sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] EMODnetWFS_2.0.1.9001
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.4.1       tidyselect_1.1.0   xfun_0.21          purrr_0.3.4       
#>  [5] sf_0.9-7           lattice_0.20-41    generics_0.1.0     vctrs_0.3.6       
#>  [9] usethis_2.1.5      htmltools_0.5.2    yaml_2.2.1         utf8_1.1.4        
#> [13] XML_3.99-0.5       rlang_0.4.10       e1071_1.7-5        pillar_1.6.0      
#> [17] glue_1.6.1         withr_2.4.1        DBI_1.1.1          sp_1.4-5          
#> [21] lifecycle_1.0.0    stringr_1.4.0      memoise_2.0.0      evaluate_0.14     
#> [25] knitr_1.31         fastmap_1.1.0      curl_4.3.2         parallel_4.0.2    
#> [29] class_7.3-17       fansi_0.4.2        highr_0.8          Rcpp_1.0.7        
#> [33] KernSmooth_2.23-17 readr_1.4.0        openssl_1.4.3      backports_1.2.1   
#> [37] classInt_0.4-3     checkmate_2.0.0    ows4R_0.2-1        cachem_1.0.4      
#> [41] jsonlite_1.7.2     fs_1.5.0           hms_1.0.0          askpass_1.1       
#> [45] digest_0.6.27      stringi_1.5.3      dplyr_1.0.5        keyring_1.3.0     
#> [49] grid_4.0.2         cli_3.2.0          rgdal_1.5-23       tools_4.0.2       
#> [53] magrittr_2.0.1     proxy_0.4-25       geometa_0.6-3      tibble_3.1.0      
#> [57] crayon_1.4.1       pkgconfig_2.0.3    ellipsis_0.3.1     reprex_2.0.0      
#> [61] rstudioapi_0.13    assertthat_0.2.1   rmarkdown_2.11     httr_1.4.2        
#> [65] R6_2.5.0           units_0.7-0        compiler_4.0.2

Created on 2022-04-12 by the reprex package (v2.0.0)

annakrystalli commented 2 years ago

EMODnetWFS now depends on ows4R version 0.3or higher (i.e. the development version). https://github.com/EMODnet/EMODnetWFS/blob/5c5ff422959c8fbde19cbf5ae2b2685e71aead00/DESCRIPTION#L30

You are using ows4R_0.2-1.You should have gotten a warning I believe. If not we should look into it.

In any case, try upgrading the package and see if that fixes it.

salvafern commented 2 years ago

Aah I see, I was installing the EMODnetWFS package locally so nothing changed for my version of ows4R. Thanks Anna!

How about adding this assertion

stopifnot(packageVersion("ows4R") >= '0.3')

in https://github.com/EMODnet/EMODnetWFS/blob/5ada1209b91514e135e78c82e02ca5d7021b5199/R/client.R#L31 ?

There were no warnings. Only an error in ows4R::WFSClient$new most likely cause the old version of the package doesn't have the config argument

# Loading ISO 19139 XML schemas...
# Loading ISO 19115 codelists...
# Error in initialize(...) : 
#     unused argument (config = list(NULL, NULL, NULL, NULL, list(), NULL, NULL))
maelle commented 2 years ago

Or maybe a note in a contributing guide for now?

I think an error in the code would be no longer necessary once ows4R new version is on CRAN / when EMODnetWFS is installed from GitHub.