Skip to content

Commit 5b096aa

Browse files
committed
provide more helpful warning messages; #2315
1 parent 7472a21 commit 5b096aa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

R/valid.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ st_make_valid.sfc = function(x, ..., oriented = FALSE, s2_options = s2::s2_optio
7878
geos_method = "valid_structure", geos_keep_collapsed = TRUE) {
7979
crs = st_crs(x)
8080
if (sf_use_s2() && isTRUE(st_is_longlat(x))) {
81-
stopifnot(missing(geos_method), missing(geos_keep_collapsed))
81+
if (!missing(geos_method) || !missing(geos_keep_collapsed))
82+
warning("arguments geos_method and geos_keep_collapsed are ignored for geodetic coordinates as sf_use_s2() is TRUE")
8283
s2 = s2::as_s2_geography(st_as_binary(st_set_precision(x, 0.0)), oriented = oriented, check = FALSE)
8384
if (st_precision(x) != 0 && missing(s2_options))
8485
s2_options = s2::s2_options(snap = s2::s2_snap_precision(st_precision(x)), ...)
8586
s2 = s2::s2_rebuild(s2, s2_options)
8687
st_as_sfc(s2, crs = crs)
8788
} else if (compareVersion(CPL_geos_version(), "3.8.0") == -1) {
88-
stopifnot(missing(geos_method), missing(geos_keep_collapsed))
89+
if (!missing(geos_method) || !missing(geos_keep_collapsed))
90+
warning("ignoring arguments geos_method and geos_keep_collapsed, as these require GEOS >= 3.8.0")
8991
if (!requireNamespace("lwgeom", quietly = TRUE))
9092
stop("package lwgeom required, please install it first") # nocov
9193
st_sfc(lwgeom::lwgeom_make_valid(x), crs = crs)

0 commit comments

Comments
 (0)