ropensci / mregions

MarineRegions R client

Home Page:https://docs.ropensci.org/mregions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mr_geo_code does not encode string for GET request

LennertSchepers opened this issue · comments

I think that the mr_geo_code() function does not parse the url correctly when using special characters (e.g. spaces,..).

mr_geo_code('Belgian') # works
mr_geo_code('Belgian Exclusive') # Error in mr_geo_code("Belgian Exclusive") : Bad Request (HTTP 400).
mr_geo_code(URLencode('Belgian Exclusive')) # works

I didn't check (yet) if this is also the case for other functions

thanks @LennertSchepers - can you share your sessionInfo()

sessionInfo() output see below:

R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 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] mregions_0.1.7.9210 raster_2.6-7 sp_1.2-6

loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 lattice_0.20-35 class_7.3-14 sf_0.6-3 digest_0.6.15 withr_2.1.1.9000
[7] grid_3.4.3 R6_2.2.2 jsonlite_1.5 DBI_1.0.0 magrittr_1.5 git2r_0.21.0
[13] units_0.5-1 e1071_1.6-8 httr_1.3.1 curl_3.1 devtools_1.13.4 tools_3.4.3
[19] udunits2_0.13 yaml_2.1.19 compiler_3.4.3 classInt_0.1-24 memoise_1.1.0

thanks @LennertSchepers

since the place name goes into the URL path, httr doesn't url encode it, so we have to manually. just pushed a change, see if it works for you now.

Yes, it works now. Thanks!