Skip to content

Commit

Permalink
Merge pull request #268 from luukvdmeer/develop
Browse files Browse the repository at this point in the history
Version bump to v0.6.4
  • Loading branch information
luukvdmeer authored Apr 9, 2024
2 parents 23a4125 + 3a4b645 commit 3a4c82a
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ubuntu-latest
strategy:
matrix:
R: [ 'release' ]
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.R }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sfnetworks
Title: Tidy Geospatial Networks
Version: 0.6.3
Version: 0.6.4
Authors@R:
c(person(given = "Lucas",
family = "van der Meer",
Expand Down Expand Up @@ -63,4 +63,4 @@ VignetteBuilder:
ByteCompile: true
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# sfnetworks v0.6.4

### New features

* The `sfnetwork()` construction function now has an argument `message` which can be set to `FALSE` when the network validity checks should not print informational messages to the console. Refs [#261](https://github.com/luukvdmeer/sfnetworks/issues/261).

### Maintenance

* Code and documentation was updated where needed to align with changes in base R and/or package dependencies. No changes to program logic or behavior.

# sfnetworks v0.6.3

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion R/morphers.R
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ to_spatial_simple = function(x, remove_multiple = TRUE, remove_loops = TRUE,
#' @param protect Nodes to be protected from being removed, no matter if they
#' are a pseudo node or not. Can be given as a numeric vector containing node
#' indices or a character vector containing node names. Can also be a set of
#' geospatial features as object of class code{\link[sf]{sf}} or
#' geospatial features as object of class \code{\link[sf]{sf}} or
#' \code{\link[sf]{sfc}}. In that case, for each of these features its nearest
#' node in the network will be protected. Defaults to \code{NULL}, meaning that
#' none of the nodes is protected.
Expand Down
12 changes: 8 additions & 4 deletions R/sfnetwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#' your input data meet the requirements, the checks are unnecessary and can be
#' turned off to improve performance.
#'
#' @param message Should informational messages (those messages that are
#' neither warnings nor errors) be printed when constructing the network?
#' Defaults to \code{TRUE}.
#'
#' @param ... Arguments passed on to \code{\link[sf]{st_as_sf}}, if nodes need
#' to be converted into an \code{\link[sf]{sf}} object during construction.
#'
Expand Down Expand Up @@ -102,7 +106,7 @@
#' @export
sfnetwork = function(nodes, edges = NULL, directed = TRUE, node_key = "name",
edges_as_lines = NULL, length_as_weight = FALSE,
force = FALSE, ...) {
force = FALSE, message = TRUE, ...) {
# Prepare nodes.
# If nodes is not an sf object:
# --> Try to convert it to an sf object.
Expand Down Expand Up @@ -140,12 +144,12 @@ sfnetwork = function(nodes, edges = NULL, directed = TRUE, node_key = "name",
# --> Adding additional attributes if requested.
if (is.null(edges)) {
# Run validity check for nodes only and return the network.
if (! force) require_valid_network_structure(x_sfn, message = TRUE)
if (! force) require_valid_network_structure(x_sfn, message = message)
return (x_sfn)
}
if (edges_as_lines) {
# Run validity check before explicitizing edges.
if (! force) require_valid_network_structure(x_sfn, message = TRUE)
if (! force) require_valid_network_structure(x_sfn, message = message)
# Add edge geometries if needed.
if (edges_are_explicit) {
# Edges already have geometries, we don't need to add them.
Expand All @@ -163,7 +167,7 @@ sfnetwork = function(nodes, edges = NULL, directed = TRUE, node_key = "name",
x_sfn = implicitize_edges(x_sfn)
}
# Run validity check after implicitizing edges.
if (! force) require_valid_network_structure(x_sfn, message = TRUE)
if (! force) require_valid_network_structure(x_sfn, message = message)
}
if (length_as_weight) {
edges = edges_as_sf(x_sfn)
Expand Down
2 changes: 1 addition & 1 deletion R/spatstat.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ check_spatstat = function(pkg) {
)
} else {
spst_ver = try(packageVersion("spatstat"), silent = TRUE)
if (!inherits(spst_ver, "try-error") && spst_ver < 2.0-0) {
if (!inherits(spst_ver, "try-error") && spst_ver < "2.0-0") {
stop(
"You have an old version of spatstat which is incompatible with ",
pkg,
Expand Down
2 changes: 1 addition & 1 deletion man/as.linnet.Rd

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

5 changes: 5 additions & 0 deletions man/sfnetwork.Rd

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

2 changes: 1 addition & 1 deletion man/spatial_morphers.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test_morphers.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ test_that("morphers return same network when there is no morphing
suppressWarnings(ecount(convert(subd_u, to_spatial_subdivision)))
)
expect_equal(
is.directed(net_d),
is.directed(convert(net_d, to_spatial_directed))
is_directed(net_d),
is_directed(convert(net_d, to_spatial_directed))
)
expect_setequal(
st_geometry(activate(net_l, "edges")),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/sfn04_routing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ old_hooks = fansi::set_knit_hooks(

Calculating shortest paths between pairs of nodes is a core task in network analysis. The `sfnetworks` package offers wrappers around the path calculation functions of `igraph`, making it easier to use them when working with spatial data and tidyverse packages. This vignette demonstrates their functionality.

In this regard it is important to remember that `sfnetworks` is a general-purpose package for spatial network analysis, not specifically optimized for a single task. If your *only* purpose is many-to-many routing in large networks, there might be other approaches that are faster and fit better to your needs. For example, the [dodgr](https://github.com/ATFutures/dodgr) package was designed for many-to-many routing on large dual-weighted graphs, with its main focus on OpenStreetMap road network data. The [cppRouting](https://github.com/vlarmet/cppRouting) package contains functions to calculate shortest paths and isochrones/isodistances on weighted graphs. When working with OpenStreetMap data, it is also possible to use the interfaces to external routing engines such as [graphhopper](https://github.com/crazycapivara/graphhopper-r), [osrm](https://github.com/riatelab/osrm) and [opentripplanner](https://github.com/ropensci/opentripplanner). The [stplanr](https://github.com/ropensci/stplanr) package for sustainable transport planning lets you use many routing engines from a single interface, through `stplanr::route()`, including routing using local R objects. Of course, all these packages can be happily used *alongside* `sfnetworks`.
In this regard it is important to remember that `sfnetworks` is a general-purpose package for spatial network analysis, not specifically optimized for a single task. If your *only* purpose is many-to-many routing in large networks, there might be other approaches that are faster and fit better to your needs. For example, the [dodgr](https://github.com/UrbanAnalyst/dodgr) package was designed for many-to-many routing on large dual-weighted graphs, with its main focus on OpenStreetMap road network data. The [cppRouting](https://github.com/vlarmet/cppRouting) package contains functions to calculate shortest paths and isochrones/isodistances on weighted graphs. When working with OpenStreetMap data, it is also possible to use the interfaces to external routing engines such as [graphhopper](https://github.com/crazycapivara/graphhopper-r), [osrm](https://github.com/riatelab/osrm) and [opentripplanner](https://github.com/ropensci/opentripplanner). The [stplanr](https://github.com/ropensci/stplanr) package for sustainable transport planning lets you use many routing engines from a single interface, through `stplanr::route()`, including routing using local R objects. Of course, all these packages can be happily used *alongside* `sfnetworks`.

```{r, message=FALSE}
library(sfnetworks)
Expand Down

0 comments on commit 3a4c82a

Please sign in to comment.