Skip to content

Commit

Permalink
fixes #2262
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Nov 10, 2023
1 parent 41a3c2c commit b595dac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# version 1.0-15

* `st_union.sfc()` with `x` and `y` given works consistent across geodetic and projected objects; #2262

* `st_union.sf()` with `x` and `y` given unions pairwise if `by_feature=TRUE`; #2259

* `st_read()` work around issue with GPKG driver if `wkt_filter` is set; #2248

* `st_read()` uses GDAL's stream reading when `use_stream = TRUE`; #2238 by @paleolimbot
Expand Down
28 changes: 22 additions & 6 deletions R/geom-transformers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1008,13 +1008,29 @@ st_union.sfc = function(x, y, ..., by_feature = FALSE, is_coverage = FALSE) {
st_sfc(CPL_geos_union(x, by_feature, is_coverage))
}
} else {
y = st_geometry(y)
stopifnot(st_crs(x) == st_crs(y))
if (ll && sf_use_s2())
st_as_sfc(s2::s2_union(x, y, ...), crs = st_crs(x))
else {
if (ll)
message_longlat("st_union")
geos_op2_geom("union", x, y, ...)
if (by_feature) {
stopifnot(length(x) == length(y))
if (ll && sf_use_s2())
st_as_sfc(s2::s2_union(x, y, ...), crs = st_crs(x))
else {
if (ll)
message_longlat("st_union")
st_as_sfc(mapply(st_union, x, y, MoreArgs = list(is_coverage = is_coverage), SIMPLIFY = FALSE),
crs = st_crs(x), precision = st_precision(x))
}
} else {
if (ll && sf_use_s2()) {
i = rep(seq_along(x), each = length(y))
j = rep(seq_along(y), length(x))
st_as_sfc(s2::s2_union(x[i], y[j], ...), crs = st_crs(x),
precision = st_precision(x))
} else {
if (ll)
message_longlat("st_union")
geos_op2_geom("union", x, y, ...)
}
}
}
}
Expand Down

0 comments on commit b595dac

Please sign in to comment.