Skip to content

Commit

Permalink
closes #2463
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Oct 29, 2024
1 parent 4b5fab5 commit 90980f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-19

* improve test on empty geometries, which changed in 1.0-18; #2463

* `gdal_utils()` `ogrinfo` has an argument `read_only` which, when `TRUE` (or `options` includes `"-ro"`), opens a datasource in read-only mode (#2460; `sf` did this before 1.0-17); by default a datasource is opened in update (read-write) mode (since sf 1.0-17; #2420)

# version 1.0-18
Expand Down
11 changes: 4 additions & 7 deletions src/sfc-sfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ LogicalVector sfc_is_empty(List sfc) {
for (R_xlen_t i = 0; i < sfc.size(); i++) {
item = sfc[i];
int item_len = Rf_length(item);
bool is_empty = true;

if (Rf_inherits(item, "POINT")) {
bool is_empty = true;

if (TYPEOF(item) == REALSXP) {
for (int j = 0; j < item_len; j++) {
double val = REAL(item)[j];
Expand All @@ -120,11 +119,9 @@ LogicalVector sfc_is_empty(List sfc) {
}
}
}

out[i] = is_empty;
} else {
out[i] = item_len == 0;
}
} else
is_empty = (item_len == 0) || (TYPEOF(item) == VECSXP && Rf_length(VECTOR_ELT(item, 0)) == 0); // #2463
out[i] = is_empty;
}

return out;
Expand Down

0 comments on commit 90980f7

Please sign in to comment.