Skip to content

Commit

Permalink
to master
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Mar 16, 2020
2 parents e4318c6 + 559d52b commit e92ee02
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 312 deletions.
13 changes: 6 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: geojsonsf
Type: Package
Title: GeoJSON to Simple Feature Converter
Version: 1.3.2001
Date: 2019-04-24
Version: 1.3.3
Date: 2020-03-17
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre"))
)
Expand All @@ -13,21 +13,20 @@ BugReports: https://github.com/SymbolixAU/geojsonsf/issues
Encoding: UTF-8
LazyData: true
Depends: R (>= 3.3.0)
SystemRequirements: C++11
LinkingTo:
jsonify (>= 1.1.0),
rapidjsonr (>= 1.1),
jsonify (>= 1.1.1),
rapidjsonr (>= 1.2.0),
Rcpp,
sfheaders (>= 0.1.0)
Imports:
curl,
jsonify (>= 1.1.1),
Rcpp
RoxygenNote: 7.0.2
Suggests:
covr,
jsonify,
knitr,
rmarkdown,
testthat
Remotes:
github::dcooley/sfheaders
VignetteBuilder: knitr
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## v1.3.3

* removed Boost links
* updated tests ready for R v4.0.0

## v1.3.2

* using `rapidjson::FileReadStream` to read large files from disk [issue 64](https://github.com/SymbolixAU/geojsonsf/issues/64)
Expand Down
160 changes: 0 additions & 160 deletions R/scratch.R

This file was deleted.

4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Release Summary

* Updates v1.3 to v1.3.2
* two bug fixes
* Updates v1.3.2 to v1.3.3
* Updated tests ready for R v4.0.0


49 changes: 25 additions & 24 deletions inst/include/geojsonsf/geojson/api/df_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ namespace api {
Rcpp::StringVector& geometry_columns,
int& digits,
bool& factors_as_string
) {
) {

rapidjson::StringBuffer sb;
rapidjson::Writer < rapidjson::StringBuffer > writer( sb );

int n_cols = df.ncol();
int n_rows = df.nrows();
int i, j;
R_xlen_t n_cols = df.ncol();
R_xlen_t n_rows = df.nrows();
R_xlen_t i, j;
Rcpp::StringVector column_names = df.names();

// the sfc_POINT
R_xlen_t n_geometry_columns = geometry_columns.size();
Rcpp::List geometry_vectors( n_geometry_columns );

int n_properties = n_cols - n_geometry_columns;
R_xlen_t n_properties = n_cols - n_geometry_columns;
Rcpp::StringVector property_names( n_properties );

for( i = 0; i < n_geometry_columns; i++ ) {
for( i = 0; i < n_geometry_columns; ++i ) {
Rcpp::String this_geometry = geometry_columns[i];
geometry_vectors[i] = df[ this_geometry ];
}

std::string dim = sfheaders::sfg::sfg_dimension( n_geometry_columns );
Rcpp::CharacterVector cls = Rcpp::CharacterVector::create( dim , "POINT", "sfg");

int property_counter = 0;
R_xlen_t property_counter = 0;

for ( i = 0; i < df.length(); i++ ) {
for ( i = 0; i < df.length(); ++i ) {

Rcpp::String this_column = column_names[i];
int idx = sfheaders::utils::where_is( this_column, geometry_columns );
R_xlen_t idx = sfheaders::utils::where_is( this_column, geometry_columns );

if ( idx == -1 ) { // i.e. it's not in the vector
property_names[property_counter] = column_names[i];
Expand All @@ -61,7 +61,7 @@ namespace api {

writer.StartArray();

for( i = 0; i < n_rows; i++ ) {
for( i = 0; i < n_rows; ++i ) {

writer.StartObject();

Expand All @@ -70,7 +70,7 @@ namespace api {
writer.StartObject();
// properties first, then sfc

for( j = 0; j < n_properties; j++ ) {
for( j = 0; j < n_properties; ++j ) {
const char *h = property_names[ j ];
SEXP this_vec = df[ h ];

Expand All @@ -82,7 +82,7 @@ namespace api {
writer.String("geometry");

Rcpp::NumericVector geom( n_geometry_columns );
for ( j = 0; j < n_geometry_columns; j++ ) {
for ( j = 0; j < n_geometry_columns; ++j ) {
Rcpp::NumericVector this_geometry_vector = geometry_vectors[j];
geom[j] = this_geometry_vector[i];
}
Expand All @@ -104,11 +104,12 @@ namespace api {
Rcpp::DataFrame& df,
Rcpp::StringVector& geometry_columns,
int& digits,
bool& factors_as_string ) {
bool& factors_as_string
) {

int n_cols = df.ncol();
int n_rows = df.nrows();
int i, j;
R_xlen_t n_cols = df.ncol();
R_xlen_t n_rows = df.nrows();
R_xlen_t i, j;
Rcpp::StringVector column_names = df.names();

Rcpp::StringVector geojson( n_rows );
Expand All @@ -117,22 +118,22 @@ namespace api {
R_xlen_t n_geometry_columns = geometry_columns.size();
Rcpp::List geometry_vectors( n_geometry_columns );

int n_properties = n_cols - n_geometry_columns;
R_xlen_t n_properties = n_cols - n_geometry_columns;
Rcpp::StringVector property_names( n_properties );

for ( i = 0; i < n_geometry_columns; i++ ) {
for ( i = 0; i < n_geometry_columns; ++i ) {
Rcpp::String this_geometry = geometry_columns[i];
geometry_vectors[i] = df[ this_geometry ];
}

std::string dim = sfheaders::sfg::sfg_dimension( n_geometry_columns );
Rcpp::CharacterVector cls = Rcpp::CharacterVector::create( dim , "POINT", "sfg");

int property_counter = 0;
for ( i = 0; i < df.length(); i++) {
R_xlen_t property_counter = 0;
for ( i = 0; i < df.length(); ++i) {

Rcpp::String this_column = column_names[i];
int idx = sfheaders::utils::where_is( this_column, geometry_columns );
R_xlen_t idx = sfheaders::utils::where_is( this_column, geometry_columns );

if ( idx == -1 ) { // i.e. it's not in the vector

Expand All @@ -142,7 +143,7 @@ namespace api {
}


for( i = 0; i < n_rows; i++ ) {
for( i = 0; i < n_rows; ++i ) {

rapidjson::StringBuffer sb;
rapidjson::Writer < rapidjson::StringBuffer > writer( sb );
Expand All @@ -155,7 +156,7 @@ namespace api {
writer.StartObject();

// properties first, then sfc
for( j = 0; j < n_properties; j++ ) {
for( j = 0; j < n_properties; ++j ) {
const char *h = property_names[ j ];

SEXP this_vec = df[ h ];
Expand All @@ -172,7 +173,7 @@ namespace api {
}

Rcpp::NumericVector geom( n_geometry_columns );
for ( j = 0; j < n_geometry_columns; j++ ) {
for ( j = 0; j < n_geometry_columns; ++j ) {
Rcpp::NumericVector this_geometry_vector = geometry_vectors[j];
geom[j] = this_geometry_vector[i];
}
Expand Down
Loading

0 comments on commit e92ee02

Please sign in to comment.