Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable passing Vendor parameters to ows4R::GetFeature() #88

Merged
merged 9 commits into from
Apr 7, 2022

Conversation

annakrystalli
Copy link
Collaborator

@annakrystalli annakrystalli commented Apr 4, 2022

This PR (I believe) addresses the issues raised in #86 by introducing dots into emodnet_get_layers() which allows passing additional vendor parameters etc. to underlying ows4R::GetFeature() function.

I've started fresh because of merge issues with previous PR #87

This allows, for example, passing a count=1 argument to return just the first feature.

I've now tested this and it works at least with the simple count = 1 request.

@salvafern I tried your example and I'm now getting a different error which has to do with the result being a data.frame:

R.utils::withTimeout({
    
    test_emodnetwfs <- emodnet_get_layers(
        wfs_client,
        layers = "eurobis-obisenv_basic",
        viewParams = viewparams,
        resultType = "results"
        
    )},
    timeout = 10
)
Warning: Download of layer 'eurobis-obisenv_basic' failed: Error in UseMethod("st_crs<-"): no applicable method for 'st_crs<-' applied to an object of class "data.frame"

This is an issue identified in #62 but your input on what @maelle has been thinking as a solution would be useful. Ultimately, WFS is not really the place to serve non spatial data but it seems there are some such datasets so we'll need a strategy to handle them.

Moved vignettes to articles.

I've also gone ahead and moved our docs from vignettes to articles so they don't get rebuilt every time R CMD CHECK is run

@annakrystalli annakrystalli mentioned this pull request Apr 4, 2022
Copy link
Collaborator

@maelle maelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent idea! Added a few comments.

R/layers.R Outdated Show resolved Hide resolved
ews_get_layer(x, wfs = wfs, cql_filter = y,
suppress_warnings = suppress_warnings, ...)
},
wfs, suppress_warnings, ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the dots passed here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purrr::map does funny stuff with dots so this was the only way to get it to work: https://stackoverflow.com/questions/48215325/passing-ellipsis-arguments-to-map-function-purrr-package-r

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this as code comment so we don't forget? That sounds good to know 😅

@@ -0,0 +1,11 @@
test_that("vendor param count works", {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there new fixtures, and what is their size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm testing a new request. Small because it only returns the first feature

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is no httptest::with_mock_dir in this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yesh. Actually it doesn't seem like there is fixture for it but there probably should be

@salvafern
Copy link
Collaborator

Hi @annakrystalli

By requesting eurobis-obisenv_full (which has geometry) I can see that the vendor params work fine. Thanks!!

test_emodnetwfs <- emodnet_get_layers(
        wfs_client,
        layers = "eurobis-obisenv_full",
        viewParams = viewparams,
        resultType = "results"
   )
 class(test_emodnetwfs$`eurobis-obisenv_full`)
#> [1] "sf"         "data.frame"

I agree that WFS is meant to share vector data, so the layers should have a geometry. But there will be cases in which there is no geometry and it would be good to check it as in eblondel/ows4R#65 (comment) (and maybe raise a warning?).

I will check why the basic data don't have geometry. If there is not a serious reason I will add the geom via geoserver (the layer has anyways lon and lat as attributes)

Feel free to merge 🎉

@annakrystalli annakrystalli merged commit 5c5ff42 into master Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants