From dc990d266f69da28ef1385d2d82d342189ee70f6 Mon Sep 17 00:00:00 2001 From: edzer Date: Sun, 3 Nov 2024 20:45:58 +0100 Subject: [PATCH] clean up st_is_full(); closes #2467 --- R/bbox.R | 2 +- R/init.R | 1 + R/sfc.R | 9 ++------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/R/bbox.R b/R/bbox.R index 69e265ea6..5679f9252 100644 --- a/R/bbox.R +++ b/R/bbox.R @@ -71,7 +71,7 @@ st_bbox.MULTIPOINT = bbox.Mtrx st_bbox.LINESTRING = bbox.Mtrx #' @export #' @name st_bbox -st_bbox.POLYGON = function(obj, ...) if (sf_use_s2() && length(obj) == 1 && nrow(obj[[1]]) == 2) FULL_bbox_ else bbox.MtrxSet(obj) +st_bbox.POLYGON = function(obj, ...) if (st_is_full(obj)) FULL_bbox_ else bbox.MtrxSet(obj) #' @export #' @name st_bbox st_bbox.MULTILINESTRING = bbox.MtrxSet diff --git a/R/init.R b/R/init.R index 4488157ec..48d500a6e 100644 --- a/R/init.R +++ b/R/init.R @@ -40,6 +40,7 @@ pathGrob <- NULL load_gdal() if ((s2 <- Sys.getenv("_SF_USE_S2")) != "") options(sf_use_s2 = s2 != "false") + FULL_bbox_ <<- st_set_crs(FULL_bbox_, "OGC:CRS84") } .onUnload = function(libname, pkgname) { diff --git a/R/sfc.R b/R/sfc.R index c3230fb2a..6a422abef 100644 --- a/R/sfc.R +++ b/R/sfc.R @@ -641,14 +641,9 @@ st_is_full.sfg = function(x, ..., is_longlat = NULL) { #' @export #' @name st_is_full st_is_full.sfc = function(x, ...) { - if (sf_use_s2() && inherits(x, c("sfc_POLYGON", "sfc_GEOMETRY"))) { - is_longlat = if (!is.null(attr(x, "crs"))) - st_is_longlat(x) - else - NA - #sapply(x, st_is_full.sfg, ..., is_longlat = is_longlat) + if (sf_use_s2() && inherits(x, c("sfc_POLYGON", "sfc_GEOMETRY"))) sfc_is_full(x) - } else + else rep_len(FALSE, length(x)) }