Skip to content

Commit

Permalink
n_coordinates #79
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Apr 17, 2020
1 parent 4ce2bf8 commit 702fad7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: sfheaders
Type: Package
Title: Converts Between R Objects and Simple Feature Objects
Date: 2020-03-19
Date: 2020-05-16
Version: 0.2.1005
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre")),
Expand Down
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ rcpp_cast_sf <- function(sf, cast_to, close = TRUE) {
.Call(`_sfheaders_rcpp_cast_sf`, sf, cast_to, close)
}

rcpp_n_coordinates <- function(sfc) {
.Call(`_sfheaders_rcpp_n_coordinates`, sfc)
}

rcpp_fill_list <- function(v, line_ids) {
.Call(`_sfheaders_rcpp_fill_list`, v, line_ids)
}
Expand Down
2 changes: 0 additions & 2 deletions inst/include/sfheaders/df/sfc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ namespace df {
std::string cls;
cls = sfc_class[1];

// Rcpp::Rcout << "cls: " << cls << std::endl;

// switch on cls
if ( cls == "sfc_POINT" ) {
R_xlen_t n_geometries = sfc.size();
Expand Down
12 changes: 12 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// rcpp_n_coordinates
Rcpp::IntegerVector rcpp_n_coordinates(Rcpp::List sfc);
RcppExport SEXP _sfheaders_rcpp_n_coordinates(SEXP sfcSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type sfc(sfcSEXP);
rcpp_result_gen = Rcpp::wrap(rcpp_n_coordinates(sfc));
return rcpp_result_gen;
END_RCPP
}
// rcpp_fill_list
Rcpp::List rcpp_fill_list(Rcpp::NumericVector v, Rcpp::IntegerMatrix line_ids);
RcppExport SEXP _sfheaders_rcpp_fill_list(SEXP vSEXP, SEXP line_idsSEXP) {
Expand Down Expand Up @@ -834,6 +845,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_sfheaders_rcpp_count_new_sfc_objects", (DL_FUNC) &_sfheaders_rcpp_count_new_sfc_objects, 2},
{"_sfheaders_rcpp_cast_sfc", (DL_FUNC) &_sfheaders_rcpp_cast_sfc, 3},
{"_sfheaders_rcpp_cast_sf", (DL_FUNC) &_sfheaders_rcpp_cast_sf, 3},
{"_sfheaders_rcpp_n_coordinates", (DL_FUNC) &_sfheaders_rcpp_n_coordinates, 1},
{"_sfheaders_rcpp_fill_list", (DL_FUNC) &_sfheaders_rcpp_fill_list, 2},
{"_sfheaders_rcpp_list_sizes", (DL_FUNC) &_sfheaders_rcpp_list_sizes, 1},
{"_sfheaders_rcpp_list_type", (DL_FUNC) &_sfheaders_rcpp_list_type, 1},
Expand Down
17 changes: 17 additions & 0 deletions src/coordinates.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include <Rcpp.h>
#include "sfheaders/df/sfc.hpp"

// [[Rcpp::export]]
Rcpp::IntegerVector rcpp_n_coordinates( Rcpp::List sfc ) {
R_xlen_t n = sfc.length();
R_xlen_t i;
Rcpp::IntegerVector res( n );
for( i = 0; i < n; ++i ) {
R_xlen_t sfg_count = 0;
SEXP sfg = sfc[ i ] ;
sfheaders::df::sfg_n_coordinates( sfg, sfg_count );
res[ i ] = sfg_count;
}
return res;
}

0 comments on commit 702fad7

Please sign in to comment.