Skip to content

Commit

Permalink
tidy before CRAN release
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Dec 14, 2023
1 parent 324ae10 commit 0d8b3eb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-15

* add `st_perimeter()` to cover both geographic and projected coordinates; #268, #2279, by @JosiahParry

* add `st_sample()` method for `bbox`, with special provisions for ellipsoidal coordinates; #2283

* documentation clean-up by @olivroy; #2266, #2285
Expand Down
2 changes: 1 addition & 1 deletion R/aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ aggregate.sf = function(x, by, FUN, ..., do_union = TRUE, simplify = TRUE,
#' sum(a2$BIR74) / sum(nc$BIR74)
#' a1$intensive = a1$BIR74
#' a1$extensive = a2$BIR74
#' plot(a1[c("intensive", "extensive")], key.pos = 4)
#' \donttest{plot(a1[c("intensive", "extensive")], key.pos = 4)}
#' @export
st_interpolate_aw = function(x, to, extensive, ...) UseMethod("st_interpolate_aw")

Expand Down
17 changes: 4 additions & 13 deletions R/geom-measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,18 @@ message_longlat = function(caller) {
#' st_perimeter(mpoly)
st_perimeter = function(x, ...) {
x = st_geometry(x)

# for spherical geometries we use s2
if (isTRUE(st_is_longlat(x))) {

if (!requireNamespace("s2", quietly = TRUE)) {
if (isTRUE(st_is_longlat(x))) { # for spherical geometries we use s2
if (!requireNamespace("s2", quietly = TRUE))
stop("package s2 required to calculate the perimeter of spherical geometries")
}

# ensure units are set to meters
units::set_units(
s2::s2_perimeter(x, ...),
"m",
mode = "standard"
)

# non-spherical geometries use lwgeom
} else {
if (!requireNamespace("lwgeom", quietly = TRUE)) {
} else { # non-spherical geometries use lwgeom:
if (!requireNamespace("lwgeom", quietly = TRUE))
stop("package lwgeom required, please install it first")
}

# note that units are handled appropriately by lwgeom
lwgeom::st_perimeter(x)
}
Expand Down
2 changes: 1 addition & 1 deletion man/interpolate_aw.Rd

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

0 comments on commit 0d8b3eb

Please sign in to comment.