inst/include/sfheaders/df/sfg.hpp
changed.
src/to_df.cpp
changed.
inst/include/sfheaders/df/sfc.hpp
changed.
Other files ignored by Codecov
tests/testthat/test-df.R
has changed.
26 | 26 | namespace sfheaders { |
|
27 | 27 | namespace df { |
|
28 | 28 | ||
29 | + | inline void dim_error() { // #nocov |
|
30 | + | Rcpp::stop("sfheaders - unknown geometry dimension"); // #nocov |
|
31 | + | } |
|
32 | + | ||
33 | + | inline Rcpp::IntegerVector get_sfg_cols( R_xlen_t& n_col, int geometry, std::string& dim ) { |
|
34 | + | ||
35 | + | switch( geometry ) { |
|
36 | + | case sfheaders::sfg::SFG_POINT: {} |
|
37 | + | case sfheaders::sfg::SFG_MULTIPOINT: {} |
|
38 | + | case sfheaders::sfg::SFG_LINESTRING: { |
|
39 | + | if( dim == "XY" ) { |
|
40 | + | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN }); |
|
41 | + | } else if( dim == "XYZM" ) { |
|
42 | + | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
43 | + | } else if ( dim == "XYZ" ) { |
|
44 | + | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
45 | + | } else if ( dim == "XYM" ) { |
|
46 | + | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
47 | + | } else { |
|
48 | + | dim_error(); // #nocov |
|
49 | + | } |
|
50 | + | } |
|
51 | + | case sfheaders::sfg::SFG_MULTILINESTRING: {} |
|
52 | + | case sfheaders::sfg::SFG_POLYGON: { |
|
53 | + | if( dim == "XY" ) { |
|
54 | + | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
55 | + | } else if( dim == "XYZM" ) { |
|
56 | + | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
57 | + | } else if ( dim == "XYZ" ) { |
|
58 | + | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
59 | + | } else if ( dim == "XYM" ) { |
|
60 | + | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
61 | + | } else { |
|
62 | + | dim_error(); // #nocov |
|
63 | + | } |
|
64 | + | } |
|
65 | + | case sfheaders::sfg::SFG_MULTIPOLYGON: { |
|
66 | + | if( dim == "XY" ) { |
|
67 | + | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
68 | + | } else if( dim == "XYZM" ) { |
|
69 | + | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
70 | + | } else if ( dim == "XYZ" ) { |
|
71 | + | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
72 | + | } else if ( dim == "XYM" ) { |
|
73 | + | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
74 | + | } else { |
|
75 | + | dim_error(); // #nocov |
|
76 | + | } |
|
77 | + | } |
|
78 | + | case sfheaders::sfg::SFG_GEOMETRYCOLLECTION: { |
|
79 | + | if( dim == "XY" ) { |
|
80 | + | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
81 | + | } else if( dim == "XYZM" ) { |
|
82 | + | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
83 | + | } else if ( dim == "XYZ" ) { |
|
84 | + | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
85 | + | } else if ( dim == "XYM" ) { // #nocov |
|
86 | + | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); // #nocov |
|
87 | + | } else { |
|
88 | + | dim_error(); // #nocov |
|
89 | + | } |
|
90 | + | ||
91 | + | } |
|
92 | + | default: { |
|
93 | + | Rcpp::stop("sfheaders - unknown geometry type"); // #nocov |
|
94 | + | } |
|
95 | + | } |
|
96 | + | ||
97 | + | return Rcpp::IntegerVector(); // #nocov never reached |
|
98 | + | } |
|
99 | + | ||
29 | 100 | const Rcpp::CharacterVector column_names = { |
|
30 | 101 | "sfc_id", "sfg_id", "geometrycollection_id", "multipolygon_id", "polygon_id", "multilinestring_id", |
|
31 | 102 | "linestring_id", "multipoint_id", "point_id", "x","y","z","m" |
67 | 138 | } else if ( geometry == "MULTIPOLYGON" ) { |
|
68 | 139 | columns[ LINESTRING_COLUMN ] = true; |
|
69 | 140 | columns[ POLYGON_COLUMN ] = true; |
|
141 | + | // } else if ( geometry == "GEOMETRYCOLLECTION" ) { |
|
142 | + | // columns[ GEOMETRYCOLLECTION_COLUMN ] = true; |
|
70 | 143 | } |
|
71 | 144 | return column_names[ columns ]; |
|
72 | 145 | } |
379 | 452 | R_xlen_t i; |
|
380 | 453 | Rcpp::List res( n_sfgs ); |
|
381 | 454 | ||
455 | + | R_xlen_t total_rows = 0; |
|
456 | + | ||
382 | 457 | // need to fill res(), |
|
383 | 458 | // then collapse it... |
|
384 | 459 | // but it will be filled like an 'sfc' - a collection of geometries. |
432 | 507 | case sfheaders::sfg::SFG_GEOMETRYCOLLECTION: { |
|
433 | 508 | Rcpp::List lst = Rcpp::as< Rcpp::List >( s ); |
|
434 | 509 | res[i] = sfheaders::df::sfg_geometrycollection_coordinates( lst, sfg_rows ); |
|
510 | + | Rcpp::Rcout << "getting gc coords - sfg_rows: " << sfg_rows << std::endl; |
|
511 | + | //res = collapse_list( res, sfg_rows ); |
|
435 | 512 | break; |
|
436 | 513 | } |
|
437 | 514 | default: { |
440 | 517 | } |
|
441 | 518 | } |
|
442 | 519 | ||
520 | + | Rcpp::Rcout << "sfg_rows: " << sfg_rows << std::endl; |
|
521 | + | ||
522 | + | // res = collapse_list( res, sfg_rows ); |
|
523 | + | ||
443 | 524 | return res; |
|
444 | 525 | ||
445 | 526 | Rcpp::stop("sfheaders - geometrycollection not implemented"); |
|
446 | 527 | return Rcpp::List(); |
|
447 | 528 | } |
|
448 | 529 | ||
449 | - | inline Rcpp::List sfg_to_df( SEXP& sfg ) { |
|
530 | + | inline Rcpp::List get_sfg_coordinates( SEXP& sfg, R_xlen_t& sfc_rows, int SFG_TYPE ) { |
|
531 | + | ||
532 | + | switch( SFG_TYPE ) { |
|
533 | + | case sfheaders::sfg::SFG_POINT: { |
|
534 | + | Rcpp::NumericVector vec = Rcpp::as< Rcpp::NumericVector >( sfg ); |
|
535 | + | return sfheaders::df::sfg_point_coordinates( vec, sfc_rows ); |
|
536 | + | } |
|
537 | + | case sfheaders::sfg::SFG_MULTIPOINT: { |
|
538 | + | Rcpp::NumericMatrix mat = Rcpp::as< Rcpp::NumericMatrix >( sfg ); |
|
539 | + | return sfheaders::df::sfg_multipoint_coordinates( mat, sfc_rows ); |
|
540 | + | } |
|
541 | + | case sfheaders::sfg::SFG_LINESTRING: { |
|
542 | + | Rcpp::NumericMatrix mat = Rcpp::as< Rcpp::NumericMatrix >( sfg ); |
|
543 | + | return sfheaders::df::sfg_linestring_coordinates( mat, sfc_rows ); |
|
544 | + | } |
|
545 | + | case sfheaders::sfg::SFG_MULTILINESTRING: { |
|
546 | + | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
547 | + | return sfheaders::df::sfg_multilinestring_coordinates( lst, sfc_rows ); |
|
548 | + | } |
|
549 | + | case sfheaders::sfg::SFG_POLYGON: { |
|
550 | + | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
551 | + | return sfheaders::df::sfg_polygon_coordinates( lst, sfc_rows ); |
|
552 | + | } |
|
553 | + | case sfheaders::sfg::SFG_MULTIPOLYGON: { |
|
554 | + | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
555 | + | return sfheaders::df::sfg_multipolygon_coordinates( lst, sfc_rows ); |
|
556 | + | } |
|
557 | + | case sfheaders::sfg::SFG_GEOMETRYCOLLECTION: { |
|
558 | + | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
559 | + | return sfheaders::df::sfg_geometrycollection_coordinates( lst, sfc_rows ); |
|
560 | + | } |
|
561 | + | default: { |
|
562 | + | Rcpp::stop("sfheaders - unknown sfg type"); // #nocov |
|
563 | + | } |
|
564 | + | } |
|
565 | + | return Rcpp::List::create(); // #nocov never reaches |
|
566 | + | } |
|
567 | + | ||
568 | + | inline Rcpp::List sfg_to_df( SEXP& sfg, R_xlen_t& sfg_rows ) { |
|
450 | 569 | ||
451 | 570 | Rcpp::List res; |
|
452 | 571 |
460 | 579 | //dim = cls[0]; |
|
461 | 580 | geometry = cls[1]; |
|
462 | 581 | ||
463 | - | R_xlen_t sfg_rows = 0; |
|
582 | + | //R_xlen_t sfg_rows = 0; |
|
464 | 583 | ||
465 | 584 | if( geometry == "POINT" ) { |
|
466 | 585 | Rcpp::NumericVector nv = Rcpp::as< Rcpp::NumericVector >( sfg ); |
486 | 605 | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
487 | 606 | res = sfg_multipolygon_coordinates( lst, sfg_rows ); |
|
488 | 607 | ||
608 | + | } else if (geometry == "GEOMETRYCOLLECTION" ) { |
|
609 | + | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
610 | + | R_xlen_t n = lst.size(); |
|
611 | + | R_xlen_t i; |
|
612 | + | //R_xlen_t total_rows; |
|
613 | + | R_xlen_t inner_rows = 0; |
|
614 | + | Rcpp::List inner_res( n ); |
|
615 | + | for( i = 0; i < n; ++i ) { |
|
616 | + | Rcpp::Rcout << "loopy" << std::endl; |
|
617 | + | SEXP sfgi = lst[ i ]; |
|
618 | + | inner_res[ i ] = sfg_to_df( sfgi, inner_rows ); |
|
619 | + | Rcpp::Rcout << "inner_rows: " << inner_rows << std::endl; |
|
620 | + | //total_rows = total_rows + inner_rows; |
|
621 | + | //Rcpp::Rcout << "total_rows: " << total_rows << std::endl; |
|
622 | + | sfg_rows = sfg_rows + inner_rows; |
|
623 | + | } |
|
624 | + | Rcpp::Rcout << "total_sfg_rows: " << sfg_rows << std::endl; |
|
625 | + | //res = collapse_list( inner_res, sfg_rows ); |
|
626 | + | //res = sfg_geometrycollection_coordinates( lst, sfg_rows ); |
|
627 | + | return inner_res; |
|
628 | + | ||
489 | 629 | } else { |
|
490 | 630 | Rcpp::stop("sfheaders - unknown geometry type"); // #nocov |
|
491 | 631 | } |
|
492 | 632 | ||
493 | 633 | Rcpp::CharacterVector df_names = make_names( cls ); |
|
634 | + | Rcpp::Rcout << "cls: " << cls << ", df_names: " << df_names << std::endl; |
|
494 | 635 | return sfheaders::utils::make_dataframe(res, sfg_rows, df_names ); |
|
495 | - | ||
496 | - | // res.attr("class") = Rcpp::CharacterVector("data.frame"); |
|
497 | - | // |
|
498 | - | // if( sfg_rows > 0 ) { |
|
499 | - | // Rcpp::IntegerVector rownames = Rcpp::seq( 1, sfg_rows ); |
|
500 | - | // res.attr("row.names") = rownames; |
|
501 | - | // } else { |
|
502 | - | // res.attr("row.names") = Rcpp::IntegerVector(0); // #nocov |
|
503 | - | // } |
|
504 | - | // |
|
505 | - | // res.attr("names") = df_names; |
|
506 | - | // return res; |
|
507 | 636 | } |
|
508 | 637 | ||
509 | 638 | } // df |
48 | 48 | return res; |
|
49 | 49 | } |
|
50 | 50 | ||
51 | - | inline void dim_error() { // #nocov |
|
52 | - | Rcpp::stop("sfheaders - unknown geometry dimension"); // #nocov |
|
53 | - | } |
|
54 | - | ||
55 | - | inline Rcpp::IntegerVector get_sfg_cols( R_xlen_t& n_col, int geometry, std::string& dim ) { |
|
56 | - | ||
57 | - | switch( geometry ) { |
|
58 | - | case sfheaders::sfg::SFG_POINT: {} |
|
59 | - | case sfheaders::sfg::SFG_MULTIPOINT: {} |
|
60 | - | case sfheaders::sfg::SFG_LINESTRING: { |
|
61 | - | if( dim == "XY" ) { |
|
62 | - | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN }); |
|
63 | - | } else if( dim == "XYZM" ) { |
|
64 | - | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
65 | - | } else if ( dim == "XYZ" ) { |
|
66 | - | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
67 | - | } else if ( dim == "XYM" ) { |
|
68 | - | return Rcpp::IntegerVector({ X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
69 | - | } else { |
|
70 | - | dim_error(); // #nocov |
|
71 | - | } |
|
72 | - | } |
|
73 | - | case sfheaders::sfg::SFG_MULTILINESTRING: {} |
|
74 | - | case sfheaders::sfg::SFG_POLYGON: { |
|
75 | - | if( dim == "XY" ) { |
|
76 | - | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
77 | - | } else if( dim == "XYZM" ) { |
|
78 | - | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
79 | - | } else if ( dim == "XYZ" ) { |
|
80 | - | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
81 | - | } else if ( dim == "XYM" ) { |
|
82 | - | return Rcpp::IntegerVector({ LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
83 | - | } else { |
|
84 | - | dim_error(); // #nocov |
|
85 | - | } |
|
86 | - | } |
|
87 | - | case sfheaders::sfg::SFG_MULTIPOLYGON: { |
|
88 | - | if( dim == "XY" ) { |
|
89 | - | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
90 | - | } else if( dim == "XYZM" ) { |
|
91 | - | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
92 | - | } else if ( dim == "XYZ" ) { |
|
93 | - | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
94 | - | } else if ( dim == "XYM" ) { |
|
95 | - | return Rcpp::IntegerVector({ POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); |
|
96 | - | } else { |
|
97 | - | dim_error(); // #nocov |
|
98 | - | } |
|
99 | - | } |
|
100 | - | case sfheaders::sfg::SFG_GEOMETRYCOLLECTION: { |
|
101 | - | if( dim == "XY" ) { |
|
102 | - | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN }); |
|
103 | - | } else if( dim == "XYZM" ) { |
|
104 | - | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN, M_COLUMN }); |
|
105 | - | } else if ( dim == "XYZ" ) { |
|
106 | - | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, Z_COLUMN }); |
|
107 | - | } else if ( dim == "XYM" ) { // #nocov |
|
108 | - | return Rcpp::IntegerVector({ MULTIPOLYGON_COLUMN, POLYGON_COLUMN, LINESTRING_COLUMN, X_COLUMN, Y_COLUMN, M_COLUMN }); // #nocov |
|
109 | - | } else { |
|
110 | - | dim_error(); // #nocov |
|
111 | - | } |
|
112 | - | ||
113 | - | } |
|
114 | - | default: { |
|
115 | - | Rcpp::stop("sfheaders - unknown geometry type"); // #nocov |
|
116 | - | } |
|
117 | - | } |
|
118 | - | ||
119 | - | return Rcpp::IntegerVector(); // #nocov never reached |
|
120 | - | } |
|
121 | - | ||
122 | 51 | inline void sfg_n_coordinates( |
|
123 | 52 | SEXP& sfg, |
|
124 | 53 | R_xlen_t& sfg_count |
205 | 134 | } |
|
206 | 135 | } |
|
207 | 136 | ||
208 | - | // sfcs are a list of sfgs. |
|
209 | - | // they can be mixed, or individual. |
|
210 | - | // if indiidual, loop over each one and extract the sfgs, list by list, then collapse the lists?? |
|
211 | - | ||
212 | - | inline Rcpp::List get_sfg_coordinates( SEXP& sfg, R_xlen_t& sfc_rows, int SFG_TYPE ) { |
|
213 | - | ||
214 | - | switch( SFG_TYPE ) { |
|
215 | - | case sfheaders::sfg::SFG_POINT: { |
|
216 | - | Rcpp::NumericVector vec = Rcpp::as< Rcpp::NumericVector >( sfg ); |
|
217 | - | return sfheaders::df::sfg_point_coordinates( vec, sfc_rows ); |
|
218 | - | } |
|
219 | - | case sfheaders::sfg::SFG_MULTIPOINT: { |
|
220 | - | Rcpp::NumericMatrix mat = Rcpp::as< Rcpp::NumericMatrix >( sfg ); |
|
221 | - | return sfheaders::df::sfg_multipoint_coordinates( mat, sfc_rows ); |
|
222 | - | } |
|
223 | - | case sfheaders::sfg::SFG_LINESTRING: { |
|
224 | - | Rcpp::NumericMatrix mat = Rcpp::as< Rcpp::NumericMatrix >( sfg ); |
|
225 | - | return sfheaders::df::sfg_linestring_coordinates( mat, sfc_rows ); |
|
226 | - | } |
|
227 | - | case sfheaders::sfg::SFG_MULTILINESTRING: { |
|
228 | - | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
229 | - | return sfheaders::df::sfg_multilinestring_coordinates( lst, sfc_rows ); |
|
230 | - | } |
|
231 | - | case sfheaders::sfg::SFG_POLYGON: { |
|
232 | - | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
233 | - | return sfheaders::df::sfg_polygon_coordinates( lst, sfc_rows ); |
|
234 | - | } |
|
235 | - | case sfheaders::sfg::SFG_MULTIPOLYGON: { |
|
236 | - | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
237 | - | return sfheaders::df::sfg_multipolygon_coordinates( lst, sfc_rows ); |
|
238 | - | } |
|
239 | - | case sfheaders::sfg::SFG_GEOMETRYCOLLECTION: { |
|
240 | - | Rcpp::List lst = Rcpp::as< Rcpp::List >( sfg ); |
|
241 | - | return sfheaders::df::sfg_geometrycollection_coordinates( lst, sfc_rows ); |
|
242 | - | } |
|
243 | - | default: { |
|
244 | - | Rcpp::stop("sfheaders - unknown sfg type"); // #nocov |
|
245 | - | } |
|
246 | - | } |
|
247 | - | return Rcpp::List::create(); // #nocov never reaches |
|
248 | - | } |
|
249 | - | ||
250 | 137 | /* |
|
251 | 138 | * get sfc geometry coordinates |
|
252 | 139 | * |
286 | 173 | ||
287 | 174 | for( i = 0; i < n_sfg; ++i ) { |
|
288 | 175 | ||
176 | + | Rcpp::Rcout << "i: " << i << std::endl; |
|
177 | + | ||
289 | 178 | SEXP sfci = sfc[ i ]; |
|
290 | 179 | ||
291 | 180 | cls = sfheaders::utils::getSfgClass( sfci ); |
|
292 | 181 | ||
182 | + | Rcpp::Rcout << "cls: " << cls << std::endl; |
|
183 | + | ||
293 | 184 | dim = cls[0]; |
|
294 | 185 | ||
295 | 186 | if ( dim == "XYZM" ) { |
309 | 200 | sfg_column_idx = get_sfg_column_index( sfg_class ); |
|
310 | 201 | columns[ sfg_column_idx ] = true; |
|
311 | 202 | ||
312 | - | Rcpp::List sfg = get_sfg_coordinates( sfci, sfc_rows, sfg_type ); |
|
203 | + | Rcpp::List sfg = sfheaders::df::get_sfg_coordinates( sfci, sfc_rows, sfg_type ); |
|
313 | 204 | ||
205 | + | // for any other 'sfg', this size is the length of the list |
|
206 | + | // because it goes through the various 'matrix_to_list' / 'vector_to_list' |
|
207 | + | // functions |
|
208 | + | // so a GEOMETRYCOLLECTION needs to be collapsed to this list |
|
209 | + | // (and) |
|
314 | 210 | n_col = sfg.size(); |
|
315 | 211 | ||
316 | - | Rcpp::IntegerVector sfg_cols = get_sfg_cols( n_col, sfg_type, dim ); |
|
212 | + | Rcpp::IntegerVector sfg_cols = sfheaders::df::get_sfg_cols( n_col, sfg_type, dim ); |
|
317 | 213 | ||
318 | 214 | Rcpp::Rcout << "sfg_cols: " << sfg_cols << std::endl; |
|
319 | 215 | Rcpp::Rcout << "n_col: " << n_col << std::endl; |
|
320 | 216 | ||
321 | - | column_index_check( sfg_cols, n_col ); |
|
217 | + | //return sfg; |
|
218 | + | ||
219 | + | //column_index_check( sfg_cols, n_col ); |
|
220 | + | ||
221 | + | Rcpp::Rcout << "index checked" << std::endl; |
|
322 | 222 | ||
223 | + | // for GEOMETRYCOLLECTIONS this needs to loop over each geometry? |
|
224 | + | // or should the 'sfg' be collapsed before it gets here?? |
|
323 | 225 | for( j = 0; j < n_col; ++j ) { |
|
324 | 226 | ||
325 | 227 | Rcpp::NumericVector new_values_vector = sfg[ j ]; |
14 | 14 | namespace sfheaders { |
|
15 | 15 | namespace cast { |
|
16 | 16 | ||
17 | - | inline void column_index_check( Rcpp::IntegerVector& sfg_cols, R_xlen_t& n_col ) { |
|
18 | - | if( sfg_cols.length() != n_col ) { |
|
19 | - | Rcpp::stop("sfheaders - column indexing error - please report this issue, along with an example, at github.com/dcooley/sfheaders"); // #nocov |
|
20 | - | } |
|
21 | - | } |
|
17 | + | // inline void column_index_check( Rcpp::IntegerVector& sfg_cols, R_xlen_t& n_col ) { |
|
18 | + | // if( sfg_cols.length() != n_col ) { |
|
19 | + | // Rcpp::stop("sfheaders - column indexing error - please report this issue, along with an example, at github.com/dcooley/sfheaders"); // #nocov |
|
20 | + | // } |
|
21 | + | // } |
|
22 | 22 | ||
23 | 23 | // inline Rcpp::List vec_to_vec( Rcpp::NumericVector& sfg, R_xlen_t& sfg_rows, double& id ) { |
|
24 | 24 | // return sfheaders::df::vector_to_list( sfg, sfg_rows, id ); |
Files | Coverage |
---|---|
R | 95.67% |
inst/include/sfheaders | 98.04% |
src | 96.76% |
Project Totals (74 files) | 97.90% |