Skip to content

Commit

Permalink
fixes #174
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Mar 23, 2022
1 parent 03b058d commit 8319070
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 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.2.12.042
Version: 0.2.12.043
Authors@R: c(
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
6 changes: 6 additions & 0 deletions R/dodgr-streetnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ process_bbox <- function (bbox,
bbox <- apply (bbox, 2, range)
}

# if x/y are rows, then transpose to columns:
ptn <- "^x|x$|^y|y$|^lon|lon$|long$|longitude|^lat|lat$|latitude"
if (all (grepl (ptn, rownames (bbox)))) {
bbox <- t (bbox)
}

rownames (bbox) <- c ("min", "max")
colnames (bbox) <- c ("x", "y")
}
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/ATFutures/dodgr",
"issueTracker": "https://github.com/ATFutures/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.12.042",
"version": "0.2.12.043",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-streetnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ test_that("streetnet bbox", {
rownames (bbox2) <- c ("min", "max")
colnames (bbox2) <- c ("x", "y")
expect_silent (bb3 <- process_bbox (bbox2, NULL, 0))
colnames (bb2$bbox) <- c ("x", "y")
rownames (bb2$bbox) <- c ("min", "max")
expect_identical (bb2, bb3)
expect_true (!identical (bb2, bb3))

colnames (bbox) <- c ("x", "y")
bb4 <- process_bbox (bbox, expand = 0)
Expand All @@ -39,7 +37,7 @@ test_that("streetnet bbox", {
expect_identical (bb$bbox, bb5$bbox)

expect_silent (bb2 <- process_bbox (list (bbox), NULL, 0))
expect_identical (bb, bb2)
expect_true (!identical (bb, bb2))

bbox <- list (matrix (letters [ceiling (runif (n) * 26)],
ncol = 2))
Expand Down Expand Up @@ -67,8 +65,9 @@ test_that ("streetnet pts", {

colnames (pts) <- c ("x", "y")
expect_silent (bb <- process_bbox (pts = pts, expand = 0))
# This gives wrong result:
expect_silent (bb2 <- process_bbox (bbox = pts, expand = 0))
expect_identical (bb$bbox, bb2$bbox)
expect_true (!identical (bb$bbox, bb2$bbox))
})


Expand Down

0 comments on commit 8319070

Please sign in to comment.