Skip to content

Commit

Permalink
Demote nngeo to Suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Aug 20, 2024
1 parent 9148695 commit 3d3a211
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Depends: R (>= 3.4.0)
Imports:
sfheaders,
methods,
nngeo,
vctrs
Suggests:
sf,
knitr,
rmarkdown,
tinytest,
covr,
lwgeom
lwgeom,
nngeo
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
10 changes: 8 additions & 2 deletions R/points_to_od.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
#' (l2_oneway = od_oneway(l2))
#' sf::st_length(l2)
#' # With max_dist:
#' (l3 = points_to_odl(p, max_dist = 10000))
#' sf::st_length(l3)
#' if (require(nngeo)) {
#' (l3 = points_to_odl(p, max_dist = 10000))
#' sf::st_length(l3)
#' }
points_to_od = function(p, pd = NULL, interzone_only = FALSE, ids_only = FALSE,
max_dist = Inf, max_dest = Inf) {
# to work with other classes at some point, possibly, it's a generic:
Expand Down Expand Up @@ -81,6 +83,10 @@ points_to_od.sf = function(p, pd = NULL, interzone_only = FALSE, ids_only = FALS

# Use nngeo implementation if max_dist or max_dest is provided
if(max_dist < Inf || max_dest < Inf) {
# Fail gracefully if nngeo is not available:
if(!requireNamespace("nngeo", quietly = TRUE)) {
stop("nngeo must be installed for max_dist and max_dest arguments")
}
if(max_dest > nrow(pd)){
max_dest = nrow(pd)
}
Expand Down
6 changes: 4 additions & 2 deletions man/points_to_od.Rd

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

0 comments on commit 3d3a211

Please sign in to comment.