Skip to content

Commit

Permalink
Move sp to suggests and warn user to install for coordinate searches
Browse files Browse the repository at this point in the history
  • Loading branch information
steffilazerte committed Jan 2, 2018
1 parent 839cccc commit 40cb49b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Imports:
lubridate (>= 1.7.1),
magrittr (>= 1.5),
methods (>= 3.2.2),
sp (>= 1.2-3),
stringi (>= 1.1.2),
tibble (>= 1.2),
tidyr (>= 0.4.1),
Expand All @@ -35,6 +34,7 @@ Suggests:
ggplot2,
knitr,
rmarkdown,
sp,
stringr,
testthat
VignetteBuilder: knitr
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ author: "Steffi LaZerte"
output: html_document
---

# weathercan 0.2.3.9000

## Changes
- `sp` moved to suggests, users are now prompted to install sp if they want to search stations by coordinates


# weathercan 0.2.3 (2017-11-22)

## Changes
Expand Down
8 changes: 8 additions & 0 deletions R/stations.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ stations_all <- function(url = NULL,
#' @param quiet Logical. Suppress all messages (including messages regarding
#' missing data, etc.)
#'
#' @details To search by coordinates, users must make sure they have the
#' \code{\link[sp]{sp}} package installed.
#'
#' @return Returns a subset of the stations data frame which match the search
#' parameters. If the search was by location, an extra column 'distance' shows
#' the distance in kilometres from the location to the station. If no stations
Expand Down Expand Up @@ -166,6 +169,11 @@ stations_search <- function(name = NULL,
if(length(coords) != 2 | all(is.na(coords)) | class(coords) == "try-error") {
stop("'coord' takes one pair of lat and lon in a numeric vector")
}

if(!requireNamespace("sp", quietly = TRUE)) {
stop("Package 'sp' required to search for stations using coordinates. Use the code \"install.packages('sp')\" to install.", call. = FALSE)
}

}

check_int(interval)
Expand Down
4 changes: 4 additions & 0 deletions man/stations_search.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40cb49b

Please sign in to comment.