diff --git a/R/vertex-filter.R b/R/vertex-filter.R index c668199f..f862590d 100644 --- a/R/vertex-filter.R +++ b/R/vertex-filter.R @@ -94,11 +94,13 @@ wk_vertex_filter <- function(handler, add_details = FALSE) { #' @export wk_coords.wk_xy <- function(handleable, ...) { feature_id <- seq_along(handleable) - not_empty <- !Reduce("&", lapply(unclass(handleable), is.nan)) + is_na <- Reduce("&", lapply(unclass(handleable), is.na)) + is_nan <- Reduce("&", lapply(unclass(handleable), is.nan)) + has_coord <- !is_na & !is_nan - if (!all(not_empty)) { - handleable <- handleable[not_empty] - feature_id <- feature_id[not_empty] + if (!all(has_coord)) { + handleable <- handleable[has_coord] + feature_id <- feature_id[has_coord] } new_data_frame( diff --git a/src/vertex-filter.c b/src/vertex-filter.c index 08ca2314..54876c17 100644 --- a/src/vertex-filter.c +++ b/src/vertex-filter.c @@ -128,11 +128,6 @@ int wk_vertex_filter_feature_start(const wk_vector_meta_t* meta, R_xlen_t feat_i return WK_CONTINUE; } -int wk_vertex_filter_feature_null(void* handler_data) { - vertex_filter_t* vertex_filter = (vertex_filter_t*)handler_data; - return vertex_filter->next->null_feature(vertex_filter->next->handler_data); -} - int wk_vertex_filter_feature_end(const wk_vector_meta_t* meta, R_xlen_t feat_id, void* handler_data) { return WK_CONTINUE; @@ -234,7 +229,6 @@ SEXP wk_c_vertex_filter_new(SEXP handler_xptr, SEXP add_details) { handler->vector_end = &wk_vertex_filter_vector_end; handler->feature_start = &wk_vertex_filter_feature_start; - handler->null_feature = &wk_vertex_filter_feature_null; handler->feature_end = &wk_vertex_filter_feature_end; handler->geometry_start = &wk_vertex_filter_geometry_start; diff --git a/tests/testthat/test-vertex-filter.R b/tests/testthat/test-vertex-filter.R index 6cad4bb0..1143139b 100644 --- a/tests/testthat/test-vertex-filter.R +++ b/tests/testthat/test-vertex-filter.R @@ -2,11 +2,11 @@ test_that("wk_vertices() works", { expect_identical( wk_vertices(wkt(c("POINT (0 0)", "POINT (1 1)", NA))), - wkt(c("POINT (0 0)", "POINT (1 1)", NA)) + wkt(c("POINT (0 0)", "POINT (1 1)")) ) expect_identical( wk_vertices(wkt(c("LINESTRING (0 0, 1 1)", NA))), - wkt(c("POINT (0 0)", "POINT (1 1)", NA)) + wkt(c("POINT (0 0)", "POINT (1 1)")) ) expect_error(wk_vertices(new_wk_wkt("POINT ENTPY")), "ENTPY")