|
9 | 9 | #' distances and for each edge category; if `TRUE`, return single vector of |
10 | 10 | #' proportional distances, like the `summary` function applied to full |
11 | 11 | #' results. See Note. |
12 | | -#' @param dlimit If `TRUE`, and no value to `to` is given, distances are |
13 | | -#' aggregated from each `from` point out to the specified distance limit (in |
14 | | -#' the same units as the edge distances of the input graph). The |
15 | | -#' `proportions_only` argument has no effect when `dlimit = TRUE`. |
16 | | -#' @return If `dlimit = FALSE`, a list of distance matrices of equal dimensions |
| 12 | +#' @param dlimit If no value to `to` is given, distances are aggregated from |
| 13 | +#' each `from` point out to the specified distance limit (in the same units as |
| 14 | +#' the edge distances of the input graph). `dlimit` only has any effect if `to` |
| 15 | +#' is not specified, in which case the `proportions_only` argument has no |
| 16 | +#' effect. |
| 17 | +#' @return If `to` is specified, a list of distance matrices of equal dimensions |
17 | 18 | #' (length(from), length(to)), the first of which ("distance") holds the final |
18 | 19 | #' distances, while the rest are one matrix for each unique value of |
19 | 20 | #' "edge_type", holding the distances traversed along those types of edges only. |
20 | | -#' If `dlimit = TRUE`, a single matrix of total distances along all ways from |
21 | | -#' each point, along with distances along each of the different kinds of ways |
22 | | -#' specified in the "edge_type" column of the input graph. |
| 21 | +#' Otherwise, a single matrix of total distances along all ways from each point |
| 22 | +#' out to the specified value of `dlimit`, along with distances along each of |
| 23 | +#' the different kinds of ways specified in the "edge_type" column of the input |
| 24 | +#' graph. |
23 | 25 | #' |
24 | 26 | #' @note The "edge_type" column in the graph can contain any kind of discrete or |
25 | 27 | #' categorical values, although integer values of 0 are not permissible. `NA` |
@@ -79,6 +81,14 @@ dodgr_dists_categorical <- function (graph, |
79 | 81 | if (is.integer (graph$edge_type) && any (graph$edge_type == 0L)) { |
80 | 82 | stop ("graphs with integer edge_type columns may not contain 0s") |
81 | 83 | } |
| 84 | + if (is.null (to)) { |
| 85 | + if (is.null (dlimit)) { |
| 86 | + stop ("'dlimit' must be specified if no 'to' points are given.") |
| 87 | + } |
| 88 | + if (!(is.numeric (dlimit) && length (dlimit) == 1L)) { |
| 89 | + stop ("'dlimit' must be a single number.") |
| 90 | + } |
| 91 | + } |
82 | 92 |
|
83 | 93 | graph <- tbl_to_df (graph) |
84 | 94 |
|
@@ -121,7 +131,7 @@ dodgr_dists_categorical <- function (graph, |
121 | 131 | message ("Calculating shortest paths ... ", appendLF = FALSE) |
122 | 132 | } |
123 | 133 |
|
124 | | - if (is.null (dlimit) && !is.null (to)) { |
| 134 | + if (!is.null (to)) { |
125 | 135 |
|
126 | 136 | d <- rcpp_get_sp_dists_categorical ( |
127 | 137 | graph, |
|
0 commit comments