Skip to content

Instantly share code, notes, and snippets.

@paleolimbot
Last active April 10, 2020 01:40
Show Gist options
  • Save paleolimbot/8bfe4c3157e2306479220070b344da21 to your computer and use it in GitHub Desktop.
Save paleolimbot/8bfe4c3157e2306479220070b344da21 to your computer and use it in GitHub Desktop.
Rcpp::sourceCpp(
code = '
#include "geovctrs/geos-operator.hpp"
// [[Rcpp::depends(geovctrs)]]
class BufferOp: public UnaryGeometryOperator {
GEOSGeometry* operateNext(GEOSContextHandle_t context, GEOSGeometry* geometry, size_t i) {
// width, segments per quandrant
return GEOSBuffer_r(context, geometry, 2, 30);
}
};
// [[Rcpp::export]]
SEXP buffer2(SEXP data, SEXP ptype) {
BufferOp op;
op.initProvider(data);
op.initExporter(ptype);
return op.operate();
}
'
)
buffer2(geovctrs::geo_wkt("POINT (30 10)"), geovctrs::geo_wkt())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment