bcgov / bcdata

An R package for searching & retrieving data from the B.C. Data Catalogue
https://bcgov.github.io/bcdata
Apache License 2.0
81 stars 12 forks source link

Add ability to get bcdc call from sf object downloaded from wfs #70

Closed ateucher closed 5 years ago

ateucher commented 5 years ago

Mostly done, but the ability to get the call that you used to get the final sf object could be useful. Moving to 0.2.0

Originally posted by @ateucher in https://github.com/bcgov/bcdata/issues/39#issuecomment-488798380

boshek commented 5 years ago

Could this be stored as an attribute in the sf object and then we could write an accessor function? That could actually happen pretty easily in collect I think.

ateucher commented 5 years ago

Yeah, that's exactly what I was thinking (add a custom class "sf_bcdc_query" or something like that?)

boshek commented 5 years ago

Do we need an additional class?

ateucher commented 5 years ago

I think so... most sf objects won't have this attribute, so if someone tries the accessor function on them it would fail in a strange way... thinking something like:

foo <- collect(a_bcdc_promise_object)
class(foo)
#> "sf_bcdc_query" "sf" "tibble" etc
show_query(foo)
#> prints the call to `bcdc_get_query` etc

show_query(another_random_sf_object)
#> "Error: This does not appear to be an object from bcdc_query_geodata, no query available"
boshek commented 5 years ago

Oh i see. The accessor function is show_query. That is a good path.