diff --git a/DESCRIPTION b/DESCRIPTION
index 79c2345..a373d53 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: wdpar
Type: Package
-Version: 1.3.3.2
+Version: 1.3.3.3
Title: Interface to the World Database on Protected Areas
Description: Fetch and clean data from the World Database on Protected
Areas (WDPA) and the World Database on Other Effective Area-Based
diff --git a/NEWS.md b/NEWS.md
index d4e3c75..e8c4ad7 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,8 @@
+# wdpar 1.3.3.3
+
+- Improve error message for `wdpa_fetch()` when PhantomJS is not
+ installed (#63).
+
# wdpar 1.3.3.2
- Add URLs to README for citations (#58).
diff --git a/R/wdpa_url.R b/R/wdpa_url.R
index c98ec5c..2b8eb46 100644
--- a/R/wdpa_url.R
+++ b/R/wdpa_url.R
@@ -60,8 +60,15 @@ wdpa_url <- function(x, wait = FALSE, page_wait = 2) {
assertthat::is.flag(wait),
assertthat::is.count(page_wait),
assertthat::noNA(page_wait),
- is_online(),
- has_phantomjs(silent = FALSE))
+ is_online()
+ )
+ assertthat::assert_that(
+ has_phantomjs(),
+ msg = paste0(
+ "cannot find PhantomJS; please install it using: ",
+ "webdriver::install_phantomjs()"
+ )
+ )
# declare hidden function
try_and_find_url <- function(x) {
## initialize web driver
@@ -144,7 +151,7 @@ start_phantomjs <- function() {
pjs <- webdriver::run_phantomjs()
)
} else {
- pjs <- webdriver::run_phantomjs()
+ pjs <- suppressMessages(webdriver::run_phantomjs())
}
# return object
pjs
@@ -155,15 +162,8 @@ stop_phantomjs <- function(pjs) {
try(pjs$process$kill(), silent = TRUE)
}
-has_phantomjs <- function(silent = TRUE) {
- assertthat::assert_that(
- assertthat::is.flag(silent),
- assertthat::noNA(silent)
- )
- pjs <- try(start_phantomjs, silent = TRUE)
- on.exit(stop_phantomjs(pjs))
- if (inherits(pjs, "try-error") && !isTRUE(silent)) {
- stop(pjs)
- }
+has_phantomjs <- function() {
+ pjs <- suppressMessages(try(start_phantomjs(), silent = TRUE))
+ on.exit(suppressMessages(stop_phantomjs(pjs)))
!inherits(pjs, "try-error")
}
diff --git a/README.md b/README.md
index 675819b..c23d341 100644
--- a/README.md
+++ b/README.md
@@ -249,7 +249,7 @@ To cite the latest official version, please use:
To cite the latest development version, please use:
> Hanson JO (2022). wdpar: Interface to the World Database on Protected
-> Areas. R package version 1.3.3.2. Available at
+> Areas. R package version 1.3.3.3. Available at
> Hanson JO (2022) wdpar: Interface to the World Database on Protected Areas. R package version 1.3.3.2. https://github.com/prioritizr/wdpar Hanson JO (2022) wdpar: Interface to the World Database on Protected Areas. R package version 1.3.3.3. https://github.com/prioritizr/wdpar UNEP-WCMC and IUCN (2022) Protected Planet: The World Database on Protected Areas (WDPA), [insert month/year of the version downloaded], Cambridge, UK: UNEP-WCMC and IUCN. Available at: www.protectedplanet.net.wdpar: Interface to the World Database on Protected Areas
Jeffrey O. Hanson
- 2022-09-28
+ 2022-10-16
Source: vignettes/wdpar.Rmd
wdpar.Rmd
Citation
- @Manual{,
author = {Jeffrey O Hanson},
title = {wdpar: Interface to the World Database on Protected Areas},
year = {2022},
- note = {R package version 1.3.3.2},
+ note = {R package version 1.3.3.3},
url = {https://github.com/prioritizr/wdpar},
}
CitationTo cite the latest official version, please use:
Hanson JO (2022). wdpar: Interface to the World Database on Protected Areas. R package version 1.3.3. Available at https://CRAN.R-project.org/package=wdpar.
To cite the latest development version, please use:
-+Hanson JO (2022). wdpar: Interface to the World Database on Protected Areas. R package version 1.3.3.2. Available at https://github.com/prioritizr/wdpar.
Hanson JO (2022). wdpar: Interface to the World Database on Protected Areas. R package version 1.3.3.3. Available at https://github.com/prioritizr/wdpar.
To cite the World Database on Protected Areas (WDPA), please use:
UNEP-WCMC and IUCN ([insert year of the version downloaded]) Protected Planet: The World Database on Protected Areas (WDPA), [insert month/year of the version downloaded], Cambridge, UK: UNEP-WCMC and IUCN. Available at: www.protectedplanet.net.
To cite the World Database on Other Effective Area-Based Conservation Measures (WDOECM), please use:
diff --git a/docs/news/index.html b/docs/news/index.html index 8251921..f47da76 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ @@ -50,6 +50,9 @@NEWS.md
+ wdpa_fetch()
when PhantomJS is not installed (#63).