From 49b5fbd18f23d3045278b385879c420ab56bb4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20A=2E=20G=C3=B6rgen?= Date: Tue, 24 Sep 2024 04:42:30 +0000 Subject: [PATCH 1/3] address #2442 --- NEWS.md | 2 ++ R/geom-transformers.R | 7 ++++++- tests/gdal_geom.R | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 12add0430..610ad4491 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/geom-transformers.R b/R/geom-transformers.R index af13a68e3..1998997ed 100644 --- a/R/geom-transformers.R +++ b/R/geom-transformers.R @@ -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 diff --git a/tests/gdal_geom.R b/tests/gdal_geom.R index 7785de0be..b18de15ef 100644 --- a/tests/gdal_geom.R +++ b/tests/gdal_geom.R @@ -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") From ae4231d1850e4f908544d5ba6ba6abd27c331fb4 Mon Sep 17 00:00:00 2001 From: Krzysztof Dyba <35004826+kadyb@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:57:32 +0200 Subject: [PATCH 2/3] fix badges in README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 06a14d691..0f46557c3 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ [![tic-db](https://github.com/r-spatial/sf/actions/workflows/tic-db.yml/badge.svg)](https://github.com/r-spatial/sf/actions/workflows/tic-db.yml) [![Coverage Status](https://img.shields.io/codecov/c/github/r-spatial/sf/main.svg)](https://app.codecov.io/gh/r-spatial/sf) [![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) -[![CRAN](http://www.r-pkg.org/badges/version/sf)](https://cran.r-project.org/package=sf) +[![CRAN](https://www.r-pkg.org/badges/version/sf)](https://cran.r-project.org/package=sf) [![cran checks](https://badges.cranchecks.info/worst/sf.svg)](https://cran.r-project.org/web/checks/check_results_sf.html) -[![Downloads](http://cranlogs.r-pkg.org/badges/sf?color=brightgreen)](https://www.r-pkg.org:443/pkg/sf) +[![Downloads](https://cranlogs.r-pkg.org/badges/sf?color=brightgreen)](https://www.r-pkg.org/pkg/sf) [![status](https://tinyverse.netlify.com/badge/sf)](https://CRAN.R-project.org/package=sf) @@ -159,13 +159,13 @@ If you use dynamic linking (installation from source) and have multiple versions ### lwgeom -Functions and methods that require `liblwgeom`, including ellipsoidal (not spherical or Eucledian) metrics (area, distances), are provide by and used from [lwgeom](https://github.com/r-spatial/lwgeom), which is also on [CRAN](https://cran.r-project.org/package=lwgeom). +Functions and methods that require `liblwgeom`, including ellipsoidal (not spherical or Euclidean) metrics (area, distances), are provide by and used from [lwgeom](https://github.com/r-spatial/lwgeom), which is also on [CRAN](https://cran.r-project.org/package=lwgeom). ## Contributing * Contributions of all sorts are most welcome, issues and pull requests are the preferred ways of sharing them. -* When contributing pull requests, please adhere to the package style (in package code use `=` rather than `<-`; don't change indentation; tab stops of 4 spaces are preferred) -* This project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. +* When contributing pull requests, please adhere to the package style (in package code use `=` rather than `<-`; don't change indentation; tab stops of 4 spaces are preferred). +* This project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project, you agree to abide by its terms. ## How to cite From 713d0661a82695c49ba43947075ec3e1d6e25140 Mon Sep 17 00:00:00 2001 From: Krzysztof Dyba <35004826+kadyb@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:01:24 +0200 Subject: [PATCH 3/3] one more badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f46557c3..d2ff4842b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![CRAN](https://www.r-pkg.org/badges/version/sf)](https://cran.r-project.org/package=sf) [![cran checks](https://badges.cranchecks.info/worst/sf.svg)](https://cran.r-project.org/web/checks/check_results_sf.html) [![Downloads](https://cranlogs.r-pkg.org/badges/sf?color=brightgreen)](https://www.r-pkg.org/pkg/sf) -[![status](https://tinyverse.netlify.com/badge/sf)](https://CRAN.R-project.org/package=sf) +[![status](https://tinyverse.netlify.app/badge/sf)](https://CRAN.R-project.org/package=sf) # Simple Features for R