Skip to content

Commit

Permalink
couple of minor bugs in add-osm-groups for sf conversions #61
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 26, 2024
1 parent 20d39c6 commit aa83394
Show file tree
Hide file tree
Showing 3 changed files with 10 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: osmplotr
Title: Bespoke Images of 'OpenStreetMap' Data
Version: 0.3.5.008
Version: 0.3.5.009
Authors@R:
c(person(given = "Mark",
family = "Padgham",
Expand Down
13 changes: 8 additions & 5 deletions R/add-osm-groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,14 @@ group_centroids_bdrys <- function (groups, make_hull, cols,
bdry [, 1], bdry [, 2]
)
indx <- which (indx > 0) # see below for point.in.polygon values
grp_centroids [[i]] <- obj_trim$xy_mn [indx, ]
} else {

grp_centroids [[i]] <- bdry
# indx closest point to bdry
d <- sqrt ((obj_trim$xmn - bdry [1])^2 +
(obj_trim$ymn - bdry [2])^2)
indx <- which.min (d)
d <- sqrt ((obj_trim$xy_mn [, 1] - bdry [1])^2 +
(obj_trim$xy_mn [, 2] - bdry [2])^2)
indx <- unname (which.min (d))
}
grp_centroids [[i]] <- obj_trim$xy_mn [indx, ]

boundaries [[i]] <- bdry

Expand Down Expand Up @@ -826,6 +825,10 @@ map_plus_hulls <- function (map, border_width = 1, groups, xyflat, cols) {
}
}
bdry <- data.frame (do.call (rbind, bdry))
if (nrow (bdry) == 0) {
return (map)
}

names (bdry) <- c ("id", "x", "y")

aes <- ggplot2::aes (x = x, y = y, group = id)
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "/~https://github.com/ropensci/osmplotr",
"issueTracker": "/~https://github.com/ropensci/osmplotr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.3.5.008",
"version": "0.3.5.009",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit aa83394

Please sign in to comment.