Skip to content

Commit

Permalink
R_xlen_t and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Mar 15, 2020
1 parent fda0b6c commit c71d532
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 189 deletions.
160 changes: 0 additions & 160 deletions R/scratch.R

This file was deleted.

2 changes: 1 addition & 1 deletion inst/include/geojsonsf/geojson/api/df_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace api {
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 Down
2 changes: 1 addition & 1 deletion inst/include/geojsonsf/geojson/geojson_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace geojson_properties {
std::vector< std::string > n = properties.names();
std::reverse( n.begin(), n.end() );
std::vector< std::string > sv( n.size() );
unsigned int i;
R_xlen_t i;

for( i = 0; i < n.size(); ++i ) {
sv[i] = n[i];
Expand Down
2 changes: 1 addition & 1 deletion inst/include/geojsonsf/geojson/geojson_to_sf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace sf {
Rcpp::List sf(1);
Rcpp::List sfc(1);
Rcpp::List properties(1);
unsigned int doc_ele;
R_xlen_t doc_ele;

if (d.IsObject()) {
Rcpp::List sfg(1);
Expand Down
16 changes: 8 additions & 8 deletions inst/include/geojsonsf/geojson/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ namespace parse {
std::string geom_type;
geojsonsf::validate::validate_geometries(val, sfg_objects);
auto geometries = val["geometries"].GetArray();
unsigned int n = geometries.Size();
unsigned int i;
R_xlen_t n = geometries.Size();
R_xlen_t i;
Rcpp::List geom_collection(n);

for (i = 0; i < n; ++i) {
Expand Down Expand Up @@ -137,8 +137,8 @@ namespace parse {
geojsonsf::geojson_properties::get_property_keys(p, property_keys);
geojsonsf::geojson_properties::get_property_types(p, property_types);

unsigned int geomsize = 1;
unsigned int i;
R_xlen_t geomsize = 1;
R_xlen_t i;

if (expand_geometries && type == "GeometryCollection") {
geojsonsf::validate::validate_geometries( geometry, sfg_objects );
Expand Down Expand Up @@ -185,8 +185,8 @@ namespace parse {

auto features = fc["features"].GetArray();

unsigned int n = features.Size(); // number of features
unsigned int i;
R_xlen_t n = features.Size(); // number of features
R_xlen_t i;

Rcpp::List feature_collection(n);

Expand All @@ -204,7 +204,7 @@ namespace parse {
const Value& v,
Rcpp::List& sfc,
Rcpp::List& properties,
int i,
R_xlen_t i,
Rcpp::NumericVector& bbox,
Rcpp::NumericVector& z_range,
Rcpp::NumericVector& m_range,
Expand Down Expand Up @@ -279,7 +279,7 @@ namespace parse {
Document& d,
Rcpp::List& sfc,
Rcpp::List& properties,
int i,
R_xlen_t i,
Rcpp::NumericVector& bbox,
Rcpp::NumericVector& z_range,
Rcpp::NumericVector& m_range,
Expand Down
28 changes: 14 additions & 14 deletions inst/include/geojsonsf/geojson/writers/writers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace writers {
}

template< typename Writer >
inline void polygon_separator( Writer& writer, int i, int n ) {
inline void polygon_separator( Writer& writer, R_xlen_t i, R_xlen_t n ) {
if (i < ( n - 1 ) ) {
writer.EndArray();
writer.EndArray();
Expand All @@ -107,7 +107,7 @@ namespace writers {
}

template< typename Writer >
inline void line_separator( Writer& writer, int i, int n) {
inline void line_separator( Writer& writer, R_xlen_t i, R_xlen_t n) {
if ( i < ( n - 1 ) ) {
writer.EndArray();
writer.StartArray();
Expand All @@ -116,8 +116,8 @@ namespace writers {

template< typename Writer >
inline void points_to_geojson( Writer& writer, Rcpp::IntegerVector& point, int digits ) {
int n = point.size();
int i;
R_xlen_t n = point.size();
R_xlen_t i;
int value;
writer.StartArray();
for ( i = 0; i < n; ++i ) {
Expand All @@ -138,8 +138,8 @@ namespace writers {

template< typename Writer >
inline void points_to_geojson( Writer& writer, Rcpp::NumericVector& point, int digits ) {
int n = point.size();
int i;
R_xlen_t n = point.size();
R_xlen_t i;
double value;
writer.StartArray();
for ( i = 0; i < n; ++i ) {
Expand Down Expand Up @@ -187,8 +187,8 @@ namespace writers {

template< typename Writer >
inline void linestring_to_geojson( Writer& writer, Rcpp::IntegerMatrix& line, int digits ) {
int i;
int nrow = line.nrow();
R_xlen_t i;
R_xlen_t nrow = line.nrow();
for ( i = 0; i < nrow; ++i ) {
Rcpp::IntegerVector this_row = line(i, Rcpp::_ );
points_to_geojson( writer, this_row, digits );
Expand All @@ -202,8 +202,8 @@ namespace writers {

template< typename Writer >
inline void linestring_to_geojson( Writer& writer, Rcpp::NumericMatrix& line, int digits ) {
int i;
int nrow = line.nrow();
R_xlen_t i;
R_xlen_t nrow = line.nrow();
for ( i = 0; i < nrow; ++i ) {
Rcpp::NumericVector this_row = line(i, Rcpp::_ );
points_to_geojson( writer, this_row, digits );
Expand Down Expand Up @@ -238,8 +238,8 @@ namespace writers {

template< typename Writer >
inline void polygon_to_geojson( Writer& writer, Rcpp::List& sfg, int digits ) {
int i;
int n = sfg.size();
R_xlen_t i;
R_xlen_t n = sfg.size();
for ( i = 0; i < n; ++i ) {
Rcpp::NumericMatrix sfgi = sfg[i];
linestring_to_geojson( writer, sfgi, digits );
Expand All @@ -254,8 +254,8 @@ namespace writers {

template< typename Writer >
inline void multi_polygon_to_geojson( Writer& writer, Rcpp::List& sfg, int digits ) {
int i;
int n = sfg.size();
R_xlen_t i;
R_xlen_t n = sfg.size();
for ( i = 0; i < n; ++i ) {
Rcpp::List sfgi = sfg[i];
polygon_to_geojson( writer, sfgi, digits );
Expand Down
2 changes: 1 addition & 1 deletion inst/include/geojsonsf/wkt/geojson_wkt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "rapidjson/document.h"
using namespace rapidjson;

void coord_separator(std::ostringstream& os, int i, int n);
void coord_separator(std::ostringstream& os, R_xlen_t i, R_xlen_t n);

void begin_wkt(std::ostringstream& os, std::string& geom_type, R_xlen_t& coord_dim );

Expand Down
6 changes: 3 additions & 3 deletions src/geojson_wkt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ void object_separator(std::ostringstream& os) {
os << ",";
}

void coord_separator(std::ostringstream& os, int i, int n) {
void coord_separator(std::ostringstream& os, R_xlen_t i, R_xlen_t n) {
if (i < (n - 1) ) {
os << ",";
}
}

void line_separator_wkt(std::ostringstream& os, int i, int n) {
void line_separator_wkt(std::ostringstream& os, R_xlen_t i, R_xlen_t n) {
if (i < (n - 1) ) {
os << "),(";
}
}

void polygon_separate_wkt(std::ostringstream& os, int i, int n) {
void polygon_separate_wkt(std::ostringstream& os, R_xlen_t i, R_xlen_t n) {
if (i < (n - 1) ) {
os << ")),((";
}
Expand Down

0 comments on commit c71d532

Please sign in to comment.