1010# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111# See the License for the specific language governing permissions and limitations under the License.
1212
13-
1413# ' Query data from the B.C. Web Feature Service
1514# '
1615# ' Queries features from the B.C. Web Feature Service. See
6059# ' res <- bcdc_query_geodata("bc-airports") %>%
6160# ' filter(PHYSICAL_ADDRESS %LIKE% 'Vict%')
6261# ' )
63- # '
62+ # '
6463# ' # To query using %IN%
6564# ' try(
6665# ' res <- bcdc_query_geodata("bc-airports") %>%
@@ -111,13 +110,15 @@ bcdc_query_geodata <- function(record, crs = 3005) {
111110
112111# ' @export
113112bcdc_query_geodata.default <- function (record , crs = 3005 ) {
114- stop(" No bcdc_query_geodata method for an object of class " , class(record ),
115- call. = FALSE )
113+ stop(
114+ " No bcdc_query_geodata method for an object of class " ,
115+ class(record ),
116+ call. = FALSE
117+ )
116118}
117119
118120# ' @export
119121bcdc_query_geodata.character <- function (record , crs = 3005 ) {
120-
121122 if (length(record ) != 1 ) {
122123 stop(" Only one record my be queried at a time." , call. = FALSE )
123124 }
@@ -137,8 +138,12 @@ bcdc_query_geodata.character <- function(record, crs = 3005) {
137138 cols_df <- feature_helper(record )
138139
139140 return (
140- as.bcdc_promise(list (query_list = query_list , cli = cli , record = NULL ,
141- cols_df = cols_df ))
141+ as.bcdc_promise(list (
142+ query_list = query_list ,
143+ cli = cli ,
144+ record = NULL ,
145+ cols_df = cols_df
146+ ))
142147 )
143148 }
144149
@@ -156,8 +161,9 @@ bcdc_query_geodata.character <- function(record, crs = 3005) {
156161# ' @export
157162bcdc_query_geodata.bcdc_record <- function (record , crs = 3005 ) {
158163 if (! any(wfs_available(record $ resource_df ))) {
159- stop(" No Web Feature Service resource available for this data set." ,
160- call. = FALSE
164+ stop(
165+ " No Web Feature Service resource available for this data set." ,
166+ call. = FALSE
161167 )
162168 }
163169
@@ -170,7 +176,9 @@ bcdc_query_geodata.bcdc_record <- function(record, crs = 3005) {
170176 ))
171177
172178 if (grepl(" _SP?G$" , layer_name )) {
173- message(" You are accessing a simplified view of the data - see the catalogue record for details." )
179+ message(
180+ " You are accessing a simplified view of the data - see the catalogue record for details."
181+ )
174182 }
175183
176184 # # Parameters for the API call
@@ -184,8 +192,12 @@ bcdc_query_geodata.bcdc_record <- function(record, crs = 3005) {
184192
185193 cols_df <- feature_helper(query_list $ typeNames )
186194
187- as.bcdc_promise(list (query_list = query_list , cli = cli , record = record ,
188- cols_df = cols_df ))
195+ as.bcdc_promise(list (
196+ query_list = query_list ,
197+ cli = cli ,
198+ record = record ,
199+ cols_df = cols_df
200+ ))
189201}
190202
191203# ' Get preview map from the B.C. Web Map Service
@@ -213,20 +225,23 @@ bcdc_query_geodata.bcdc_record <- function(record, crs = 3005) {
213225# ' )
214226# ' }
215227# ' @export
216- bcdc_preview <- function (record ) { # nocov start
228+ bcdc_preview <- function (record ) {
229+ # nocov start
217230 if (! has_internet()) stop(" No access to internet" , call. = FALSE )
218231 UseMethod(" bcdc_preview" )
219232}
220233
221234# ' @export
222235bcdc_preview.default <- function (record ) {
223- stop(" No bcdc_preview method for an object of class " , class(record ),
224- call. = FALSE )
236+ stop(
237+ " No bcdc_preview method for an object of class " ,
238+ class(record ),
239+ call. = FALSE
240+ )
225241}
226242
227243# ' @export
228244bcdc_preview.character <- function (record ) {
229-
230245 if (is_whse_object_name(record )) {
231246 make_wms(record )
232247 } else {
@@ -236,30 +251,36 @@ bcdc_preview.character <- function(record) {
236251
237252# ' @export
238253bcdc_preview.bcdc_record <- function (record ) {
239-
240254 wfs_resource <- get_wfs_resource_from_record(record )
241255
242256 make_wms(basename(dirname(wfs_resource $ url )))
243-
244257}
245258
246- make_wms <- function (x ){
259+ make_wms <- function (x ) {
247260 wms_url <- wms_base_url()
248- wms_options <- leaflet :: WMSTileOptions(format = " image/png" ,
249- transparent = TRUE ,
250- attribution = " BC Data Catalogue (https://catalogue.data.gov.bc.ca/)" )
251- wms_legend <- glue :: glue(" {wms_url}?request=GetLegendGraphic&
261+ wms_options <- leaflet :: WMSTileOptions(
262+ format = " image/png" ,
263+ transparent = TRUE ,
264+ attribution = " BC Data Catalogue (https://catalogue.data.gov.bc.ca/)"
265+ )
266+ wms_legend <- glue :: glue(
267+ " {wms_url}?request=GetLegendGraphic&
252268 format=image%2Fpng&
253269 width=20&
254270 height=20&
255- layer=pub%3A{x}" )
271+ layer=pub%3A{x}"
272+ )
256273
257274 leaflet :: leaflet() %> %
258- leaflet :: addProviderTiles(leaflet :: providers $ CartoDB.Positron ,
259- options = leaflet :: providerTileOptions(noWrap = TRUE )) %> %
260- leaflet :: addWMSTiles(wms_url ,
261- layers = glue :: glue(" pub:{x}" ),
262- options = wms_options ) %> %
275+ leaflet :: addProviderTiles(
276+ leaflet :: providers $ CartoDB.Positron ,
277+ options = leaflet :: providerTileOptions(noWrap = TRUE )
278+ ) %> %
279+ leaflet :: addWMSTiles(
280+ wms_url ,
281+ layers = glue :: glue(" pub:{x}" ),
282+ options = wms_options
283+ ) %> %
263284 leaflet.extras :: addWMSLegend(uri = wms_legend ) %> %
264285 leaflet :: setView(lng = - 126.5 , lat = 54.5 , zoom = 5 )
265286} # nocov end
@@ -275,4 +296,3 @@ make_query_list <- function(layer_name, crs) {
275296 SRSNAME = paste0(" EPSG:" , crs )
276297 )
277298}
278-
0 commit comments