Skip to content

Commit

Permalink
update all parameter inheritance structures for #254
Browse files Browse the repository at this point in the history
So that almost all fns just inherit param descriptions directly from dodgr_dists
  • Loading branch information
mpadge committed Sep 30, 2024
1 parent 192d769 commit b40317b
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 232 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.4.1.035
Version: 0.4.1.036
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
14 changes: 1 addition & 13 deletions R/dists-nearest.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
#' Calculate vector of shortest distances from a series of 'from' points to
#' nearest one of series of 'to' points.
#'
#' @param graph `data.frame` or equivalent object representing the network
#' graph (see Notes)
#' @param from Vector or matrix of points **from** which route distances are to
#' be calculated (see Notes)
#' @param to Vector or matrix of points **to** which shortest route distances
#' are to be calculated to nearest 'to' point only.
#' @param shortest If `FALSE`, calculate distances along the \emph{fastest}
#' rather than shortest routes (see Notes).
#' @param heap Type of heap to use in priority queue. Options include
#' Fibonacci Heap (default; `FHeap`), Binary Heap (`BHeap`),
#' `Trinomial Heap (`TriHeap`), Extended Trinomial Heap
#' (`TriHeapExt`, and 2-3 Heap (`Heap23`).
#' @param quiet If `FALSE`, display progress messages on screen.
#' @inheritParams dodgr_dists
#' @return Vector of distances, one element for each 'from' point giving the
#' distance to the nearest 'to' point.
#'
Expand Down
103 changes: 55 additions & 48 deletions R/dists.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,73 @@
#' graph (see Notes). For `dodgr` street networks, this may be a network derived
#' from either \pkg{sf} or \pkg{silicate} ("sc") data, generated with
#' \link{weight_streetnet}.
#'
#' The `from` and `to` columns of `graph` may be either single
#' columns of numeric or character values specifying the numbers or names of
#' graph vertices, or combinations to two columns specifying geographical
#' (longitude and latitude,) coordinates. In the latter case, almost any sensible
#' combination of names will be accepted (for example, `fromx, fromy`,
#' `from_x, from_y`, or `fr_lat, fr_lon`.)
#'
#' Note that longitude and latitude values are always interpreted in 'dodgr' to
#' be in EPSG:4326 / WSG84 coordinates. Any other kinds of coordinates should
#' first be reprojected to EPSG:4326 before submitting to any 'dodgr' routines.
#'
#' See further information in Details.
#'
#' @param from Vector or matrix of points **from** which route distances are to
#' be calculated (see Notes)
#' be calculated, specified as one of the following:
#' \itemize{
#' \item Single character vector precisely matching node numbers or names
#' given in `graph$from` or `graph$to`.
#' \item Single vector of integer-ish values, in which case these will be
#' presumed to specify indices into \link{dodgr_vertices}, and NOT to
#' correspond to values in the 'from' or 'to' columns of the graph. See the
#' example below for a demonstration.
#' \item Matrix or equivalent of longitude and latitude coordinates, in which
#' case these will be matched on to the nearest coordinates of 'from' and 'to'
#' points in the graph.
#' }
#'
#' @param to Vector or matrix of points **to** which route distances are to be
#' calculated (see Notes)
#' calculated. If `to` is `NULL`, pairwise distances will be calculated from
#' all `from` points to all other nodes in `graph`. If both `from` and `to` are
#' `NULL`, pairwise distances are calculated between all nodes in `graph`.
#'
#' @param shortest If `FALSE`, calculate distances along the \emph{fastest}
#' rather than shortest routes (see Notes).
#' rather than shortest routes. For street networks produced with
#' \link{weight_streetnet}, distances may also be calculated along the
#' \emph{fastest} routes with the `shortest = FALSE` option. Graphs must in
#' this case have columns of `time` and `time_weighted`. Note that the fastest
#' routes will only be approximate when derived from \pkg{sf}-format data
#' generated with the \pkg{osmdata} function `osmdata_sf()`, and will be much
#' more accurate when derived from `sc`-format data generated with
#' `osmdata_sc()`. See \link{weight_streetnet} for details.
#'
#' @param pairwise If `TRUE`, calculate distances only between the ordered
#' pairs of `from` and `to`.
#'
#' @param heap Type of heap to use in priority queue. Options include
#' Fibonacci Heap (default; `FHeap`), Binary Heap (`BHeap`),
#' `Trinomial Heap (`TriHeap`), Extended Trinomial Heap
#' (`TriHeapExt`, and 2-3 Heap (`Heap23`).
#' @param parallel If `TRUE`, perform routing calculation in parallel (see
#' details)
#'
#' @param parallel If `TRUE`, perform routing calculation in parallel.
#' Calculations in parallel ought very generally be advantageous. For small
#' graphs, calculating distances in parallel is likely to offer relatively
#' little gain in speed, but increases from parallel computation will generally
#' markedly increase with increasing graph sizes. By default, parallel
#' computation uses the maximal number of available cores or threads. This
#' number can be reduced by specifying a value via
#' `RcppParallel::setThreadOptions (numThreads = <desired_number>)`. Parallel
#' calculations are, however, not able to be interrupted (for example, by
#' `Ctrl-C`), and can only be stopped by killing the R process.
#'
#' @param quiet If `FALSE`, display progress messages on screen.
#'
#' @return square matrix of distances between nodes
#'
#' @note `graph` must minimally contain three columns of `from`,
#' @details `graph` must minimally contain three columns of `from`,
#' `to`, `dist`. If an additional column named `weight` or
#' `wt` is present, shortest paths are calculated according to values
#' specified in that column; otherwise according to `dist` values. Either
Expand All @@ -31,48 +80,6 @@
#' values (if present), while reported distances will be total sums of `dist`
#' values.
#'
#' For street networks produced with \link{weight_streetnet}, distances may also
#' be calculated along the \emph{fastest} routes with the `shortest = FALSE`
#' option. Graphs must in this case have columns of `time` and `time_weighted`.
#' Note that the fastest routes will only be approximate when derived from
#' \pkg{sf}-format data generated with the \pkg{osmdata} function
#' `osmdata_sf()`, and will be much more accurate when derived from `sc`-format
#' data generated with `osmdata_sc()`. See \link{weight_streetnet} for details.
#'
#' The `from` and `to` columns of `graph` may be either single
#' columns of numeric or character values specifying the numbers or names of
#' graph vertices, or combinations to two columns specifying geographical
#' (longitude and latitude) coordinates. In the latter case, almost any sensible
#' combination of names will be accepted (for example, `fromx, fromy`,
#' `from_x, from_y`, or `fr_lat, fr_lon`.)
#'
#' The `from` and `to` parameters passed to this function can be either:
#' \itemize{
#' \item Single character vectors precisely matching node numbers or names
#' given in `graph$from` or `graph$to`.
#' \item Single vectors of integer-ish values, in which case these will be
#' presumed to specify indices into \link{dodgr_vertices}, and NOT to
#' correspond to values in the "from" or "to" columns of the graph. See the
#' example below for a demonstration.
#' \item matrices or equivalent of longitude and latitude coordinates, in which
#' case these will be matched on to the nearest coordinates of "from" and "to"
#' points in the graph.
#' }
#'
#' If `to` is `NULL`, pairwise distances will be calculated from all `from`
#' points to all other nodes in `graph`. If both `from` and `to` are `NULL`,
#' pairwise distances are calculated between all nodes in `graph`.
#'
#' Calculations in parallel (`parallel = TRUE`) ought very generally be
#' advantageous. For small graphs, calculating distances in parallel is likely
#' to offer relatively little gain in speed, but increases from parallel
#' computation will generally markedly increase with increasing graph sizes.
#' By default, parallel computation uses the maximal number of available cores
#' or threads. This number can be reduced by specifying a value via
#' `RcppParallel::setThreadOptions (numThreads = <desired_number>)`. Parallel
#' calculations are, however, not able to be interrupted (for example, by
#' `Ctrl-C`), and can only be stopped by killing the R process.
#'
#' @family distances
#' @export
#' @examples
Expand Down
10 changes: 1 addition & 9 deletions R/times.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#' Calculate matrix of pair-wise travel times between points.
#'
#' @inherit dodgr_dists
#' @param graph `data.frame` or equivalent object representing the network
#' graph (see Notes). For `dodgr` street networks, this may be a network derived
#' from either \pkg{sf} or \pkg{silicate} ("sc") data, generated with
#' \link{weight_streetnet}. Note, however, that networks derived from \pkg{sf}
#' data will generally not produce reliable estimates of times. Accurate
#' estimates can only be guaranteed by using networks derived from
#' \pkg{silicate} ("sc") data.
#' @param shortest If `TRUE`, calculate times along the \emph{shortest} rather
#' than fastest paths.
#' @inheritParams dodgr_dists
#'
#' @family distances
#' @export
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/UrbanAnalyst/dodgr",
"issueTracker": "https://github.com/UrbanAnalyst/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.4.1.035",
"version": "0.4.1.036",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
97 changes: 48 additions & 49 deletions man/dodgr_distances.Rd

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

Loading

0 comments on commit b40317b

Please sign in to comment.