Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address #2442 #2445

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* fix build failure with GDAL < 3.4.0 #2436

* `st_simplify()` now accepts feature-wise tolerance values when `s2` is switched on #2442

# version 1.0-17

* add `st_transform()` method for `bbox` objects; this uses OGRCoordinateTransformation::TransformBounds(), densifying first and antemeridian proof; #2415
Expand Down
7 changes: 6 additions & 1 deletion R/geom-transformers.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ st_simplify.sfc = function(x, preserveTopology, dTolerance = 0.0) {
if (ll && sf_use_s2()) {
if (!missing(preserveTopology) && isFALSE(preserveTopology))
warning("argument preserveTopology cannot be set to FALSE when working with ellipsoidal coordinates since the algorithm behind st_simplify always preserves topological relationships")
st_as_sfc(s2::s2_simplify(x, dTolerance), crs = st_crs(x))
if (length(dTolerance) == 1) {
st_as_sfc(s2::s2_simplify(x, dTolerance), crs = st_crs(x))
} else {
simplify <- function(x, dTolerance) st_as_sfc(s2::s2_simplify(x, dTolerance))
st_as_sfc(mapply(simplify, x, dTolerance), crs = st_crs(x))
}
} else {
if (missing(preserveTopology)) {
preserveTopology = FALSE
Expand Down
2 changes: 2 additions & 0 deletions tests/gdal_geom.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ x = st_convex_hull(nc)

x = st_simplify(nc_tr, dTolerance = 1e4)

x = st_simplify(nc_tr, dTolerance = rep(1e4, nrow(nc_tr)))

x = st_simplify(nc_tr, preserveTopology = TRUE)

if (sf:::CPL_geos_version() >= "3.4.0")
Expand Down
Loading