Skip to content

Commit db14bfb

Browse files
committed
fix bug in connect-highways
1 parent 4ef6a73 commit db14bfb

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: osmplotr
22
Title: Bespoke Images of 'OpenStreetMap' Data
3-
Version: 0.3.5.027
3+
Version: 0.3.5.028
44
Authors@R:
55
c(person(given = "Mark",
66
family = "Padgham",
@@ -40,6 +40,7 @@ Imports:
4040
spatstat.geom
4141
Suggests:
4242
curl,
43+
geodist,
4344
knitr,
4445
magrittr,
4546
markdown,

R/connect-highways.R

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
#' @export
6464
connect_highways <- function (highways, bbox, plot = FALSE) {
6565

66+
requireNamespace ("geodist", quietly = TRUE)
67+
6668
if (missing (highways)) {
6769
stop ("A vector of highway names must be given")
6870
}
@@ -430,19 +432,23 @@ sps_through_cycle <- function (ways, cyc) {
430432
logical (1L)
431433
))
432434
combs <- expand.grid (index_f, index_t)
433-
cm <- osmplotr:::get_conmat (ways [[c0]])
434-
asp <- e1071::allShortestPaths (cm)
435-
paths <- apply (combs, 1, function (i) {
436-
unique (e1071::extractPath (asp, i [1], i [2]))
437-
}, simplify = FALSE)
438-
path_lens <- vapply (paths, length, integer (1L))
439-
paths <- paths [which (path_lens == min (path_lens))]
435+
if (length (w0) > 1L) {
436+
cm <- get_conmat (w0)
437+
asp <- e1071::allShortestPaths (cm)
438+
paths <- apply (combs, 1, function (i) {
439+
unique (e1071::extractPath (asp, i [1], i [2]))
440+
}, simplify = FALSE)
441+
path_lens <- vapply (paths, length, integer (1L))
442+
paths <- paths [which (path_lens == min (path_lens))]
443+
} else {
444+
paths <- list (1L)
445+
}
440446
if (length (paths) > 1L) {
441447
# Choose paths with outermost elements:
442-
dmax <- vapply (paths, function (p) {
448+
dmax <- lapply (paths, function (p) {
443449
these_ways <- do.call (rbind, w0 [p])
444450
max (geodist::geodist (xy0, these_ways))
445-
}, numeric (1L))
451+
})
446452
paths <- paths [[which.max (dmax)]]
447453
}
448454
ways [[c0]] <- ways [[c0]] [unlist (paths)]

codemeta.json

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"codeRepository": "https://github.com/ropensci/osmplotr",
99
"issueTracker": "https://github.com/ropensci/osmplotr/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.3.5.027",
11+
"version": "0.3.5.28",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",
1515
"url": "https://r-project.org"
1616
},
17-
"runtimePlatform": "R version 4.4.2 (2024-10-31)",
17+
"runtimePlatform": "R version 4.5.1 (2025-06-13)",
1818
"author": [
1919
{
2020
"@type": "Person",
@@ -73,6 +73,18 @@
7373
},
7474
"sameAs": "https://CRAN.R-project.org/package=curl"
7575
},
76+
{
77+
"@type": "SoftwareApplication",
78+
"identifier": "geodist",
79+
"name": "geodist",
80+
"provider": {
81+
"@id": "https://cran.r-project.org",
82+
"@type": "Organization",
83+
"name": "Comprehensive R Archive Network (CRAN)",
84+
"url": "https://cran.r-project.org"
85+
},
86+
"sameAs": "https://CRAN.R-project.org/package=geodist"
87+
},
7688
{
7789
"@type": "SoftwareApplication",
7890
"identifier": "knitr",
@@ -279,31 +291,17 @@
279291
},
280292
"sameAs": "https://CRAN.R-project.org/package=spatstat.geom"
281293
},
282-
"SystemRequirements": {}
294+
"SystemRequirements": null
283295
},
284-
"fileSize": "1371.45KB",
285-
"releaseNotes": "https://github.com/ropensci/osmplotr/blob/master/NEWS.md",
296+
"fileSize": "3214.001KB",
297+
"releaseNotes": "https://github.com/ropensci/osmplotr/blob/main/NEWS.md",
286298
"readme": "https://github.com/ropensci/osmplotr/blob/main/README.md",
287-
"contIntegration": [
288-
"https://github.com/ropensci/osmplotr/actions?query=workflow%3AR-CMD-check",
289-
"https://app.codecov.io/gh/ropensci/osmplotr"
290-
],
299+
"contIntegration": ["https://github.com/ropensci/osmplotr/actions?query=workflow%3AR-CMD-check", "https://app.codecov.io/gh/ropensci/osmplotr"],
291300
"developmentStatus": "https://www.repostatus.org/",
292301
"review": {
293302
"@type": "Review",
294303
"url": "https://github.com/ropensci/software-review/issues/27",
295304
"provider": "https://ropensci.org"
296305
},
297-
"keywords": [
298-
"osm",
299-
"openstreetmap",
300-
"overpass-api",
301-
"overpass",
302-
"data-visualisation",
303-
"highlighting-clusters",
304-
"r",
305-
"rstats",
306-
"r-package",
307-
"peer-reviewed"
308-
]
306+
"keywords": ["osm", "openstreetmap", "overpass-api", "overpass", "data-visualisation", "highlighting-clusters", "r", "rstats", "r-package", "peer-reviewed"]
309307
}

0 commit comments

Comments
 (0)