-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from paleolimbot/wkb-is-na
never vapply() along a wkb vector
- Loading branch information
Showing
4 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#define R_NO_REMAP | ||
#include <R.h> | ||
#include <Rinternals.h> | ||
|
||
SEXP wk_c_wkb_is_na(SEXP geom) { | ||
R_xlen_t size = Rf_xlength(geom); | ||
SEXP result = PROTECT(Rf_allocVector(LGLSXP, size)); | ||
int* pResult = LOGICAL(result); | ||
|
||
for (R_xlen_t i = 0; i < size; i++) { | ||
pResult[i] = VECTOR_ELT(geom, i) == R_NilValue; | ||
} | ||
|
||
UNPROTECT(1); | ||
return result; | ||
} | ||
|
||
SEXP wk_c_wkb_is_raw_or_null(SEXP geom) { | ||
R_xlen_t size = Rf_xlength(geom); | ||
SEXP result = PROTECT(Rf_allocVector(LGLSXP, size)); | ||
int* pResult = LOGICAL(result); | ||
int typeOf; | ||
for (R_xlen_t i = 0; i < size; i++) { | ||
typeOf = TYPEOF(VECTOR_ELT(geom, i)); | ||
pResult[i] = (typeOf == NILSXP) || (typeOf == RAWSXP); | ||
} | ||
|
||
UNPROTECT(1); | ||
return result; | ||
} |