Skip to content

Commit

Permalink
cran realease
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Jan 18, 2019
1 parent 0c62e41 commit 7f0e42a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 39 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: spatialwidget
Type: Package
Title: Converts Spatial Data to Javascript Object Notation (JSON) for Use in Htmlwidgets
Version: 0.2
Date: 2019-01-13
Date: 2019-01-18
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre"))
)
Expand Down
14 changes: 10 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@

## Release Notes

* Updates v0.1 to v0.2
* CRAN Check NOTES: large installed package size
- This library has a lot of required source C++ files which I can't remove


## Test environments
* local OS X install, R 3.5.0
* local OS X install, R 3.5.1
* ubuntu 14.04 (on travis-ci), R 3.5.0
* win-builder (devel and release)

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
0 errors | 0 warnings | 0 notes
60 changes: 30 additions & 30 deletions inst/include/spatialwidget/geojson/geojson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace geojson {
int n_geometries = geometries.size();
int geom;

size_t n_cols = sf.ncol();
size_t n_properties = n_cols - n_geometries;
size_t n_rows = sf.nrows();
int n_cols = sf.ncol();
int n_properties = n_cols - n_geometries;
int n_rows = sf.nrows();
int i, j;
Rcpp::StringVector column_names = sf.names();
Rcpp::StringVector property_names( n_properties );
Expand Down Expand Up @@ -100,18 +100,18 @@ namespace geojson {

const char* geom_column = geometry.c_str();

size_t n_cols = sf.ncol();
size_t n_properties = n_cols - 1; // single geometry column
size_t n_rows = sf.nrows();
int n_cols = sf.ncol();
int n_properties = n_cols - 1; // single geometry column
int n_rows = sf.nrows();
int i, j, i_geometry;
Rcpp::StringVector column_names = sf.names();
Rcpp::StringVector property_names(sf.size() - 1);

size_t property_multiplier = 0;
int property_multiplier = 0;
std::string geom_type;
Rcpp::CharacterVector cls;

size_t property_counter = 0;
int property_counter = 0;
for ( i = 0; i < n_cols; i++ ) {

Rcpp::String this_column = column_names[i];
Expand Down Expand Up @@ -186,22 +186,22 @@ namespace geojson {
int digits)
{

size_t n_geometries = geometries.size();
int n_geometries = geometries.size();
if ( n_geometries != 2 ) {
Rcpp::stop("Only supports 2-column sf objects");
}

size_t n_cols = sf.ncol();
size_t n_rows = sf.nrows();
int n_cols = sf.ncol();
int n_rows = sf.nrows();
int i, j;
size_t geometry, geometry_column;
int geometry, geometry_column;
Rcpp::StringVector column_names = sf.names();
Rcpp::StringVector property_names(sf.size() - 1);

std::string geom_type;
Rcpp::CharacterVector cls;

size_t property_counter = 0;
int property_counter = 0;
for ( i = 0; i < n_cols; i++) {

Rcpp::String this_column = column_names[i];
Expand All @@ -220,7 +220,7 @@ namespace geojson {
for( i = 0; i < n_rows; i++ ) {

int geometry_size = 0;
size_t row_multiplier = 0;
int row_multiplier = 0;
Rcpp::IntegerVector geometry_sizes( n_geometries );

for ( geometry = 0; geometry < n_geometries; geometry++ ) {
Expand Down Expand Up @@ -324,9 +324,9 @@ namespace geojson {
rapidjson::StringBuffer sb;
rapidjson::Writer < rapidjson::StringBuffer > writer( sb );

size_t n_cols = sf.ncol();
size_t n_properties = n_cols - 1;
size_t n_rows = sf.nrows();
int n_cols = sf.ncol();
int n_properties = n_cols - 1;
int n_rows = sf.nrows();
int i, j;
Rcpp::StringVector column_names = sf.names();
Rcpp::StringVector property_names(sf.size() - 1);
Expand Down Expand Up @@ -385,14 +385,14 @@ namespace geojson {
int digits )
{

size_t n_cols = df.ncol();
size_t n_rows = df.nrows();
int n_cols = df.ncol();
int n_rows = df.nrows();

size_t n_lons = geometries.size();
size_t n_lats = geometries.size(); // it is expected the lon & lat data is the same size because
int n_lons = geometries.size();
int n_lats = geometries.size(); // it is expected the lon & lat data is the same size because

size_t n_lonlat = n_lons + n_lats;
size_t n_properties = n_cols - n_lonlat; // LON & LAT columns
int n_lonlat = n_lons + n_lats;
int n_properties = n_cols - n_lonlat; // LON & LAT columns

// it comes as columns on a data.frame
int i, j;
Expand Down Expand Up @@ -488,15 +488,15 @@ namespace geojson {
int digits )
{

size_t n_cols = df.ncol();
size_t n_rows = df.nrows();
int n_cols = df.ncol();
int n_rows = df.nrows();

size_t n_lons = geometries.size();
size_t n_lats = geometries.size(); // it is expected the lon & lat data is the same size because
size_t n_elevs = geometries.size();
int n_lons = geometries.size();
int n_lats = geometries.size(); // it is expected the lon & lat data is the same size because
int n_elevs = geometries.size();

size_t n_lonlat = n_lons + n_lats + n_elevs;
size_t n_properties = n_cols - n_lonlat; // LON & LAT & ELEV columns
int n_lonlat = n_lons + n_lats + n_elevs;
int n_properties = n_cols - n_lonlat; // LON & LAT & ELEV columns

// it comes as columns on a data.frame
int i, j;
Expand Down
20 changes: 16 additions & 4 deletions tests/testthat/test-legends.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ test_that("legends are formatted", {
expect_equal( as.character( res$legend ), '{"fill_colour":{"colour":["#440154FF","#31688EFF","#35B779FF","#FDE725FF"],"variable":["2018-01-01","2018-01-02","2018-01-03","2018-01-04"],"colourType":["fill_colour"],"type":["gradient"],"title":["col"],"css":[""]}}')

## POSIXct
df <- data.frame(lon = c(1,2,-5,0.3), lat = 1:4, col = seq(as.POSIXct("2018-01-01"), as.POSIXct("2018-01-04"), length.out = 4))
df <- data.frame(
lon = c(1,2,-5,0.3)
, lat = 1:4
, col = seq(as.POSIXct("2018-01-01", tz= "UTC")
, as.POSIXct("2018-01-04", tz="UTC")
, length.out = 4)
)

res <- spatialwidget::widget_point(
data = df
Expand All @@ -73,10 +79,16 @@ test_that("legends are formatted", {
, fill_colour = "col"
)

expect_equal( as.character( res$legend ), '{"fill_colour":{"colour":["#440154FF","#31688EFF","#35B779FF","#FDE725FF"],"variable":["2017-12-31T13:00:00","2018-01-01T13:00:00","2018-01-02T13:00:00","2018-01-03T13:00:00"],"colourType":["fill_colour"],"type":["gradient"],"title":["col"],"css":[""]}}')
expect_equal( as.character( res$legend ), '{"fill_colour":{"colour":["#440154FF","#31688EFF","#35B779FF","#FDE725FF"],"variable":["2018-01-01T00:00:00","2018-01-02T00:00:00","2018-01-03T00:00:00","2018-01-04T00:00:00"],"colourType":["fill_colour"],"type":["gradient"],"title":["col"],"css":[""]}}')

## POSIXlt (as POSIXct because in data.frame)
df <- data.frame(lon = c(1,2,-5,0.3), lat = 1:4, col = seq(as.POSIXlt("2018-01-01"), as.POSIXlt("2018-01-04"), length.out = 4))
df <- data.frame(
lon = c(1,2,-5,0.3)
, lat = 1:4
, col = seq(as.POSIXlt("2018-01-01", tz="UTC")
, as.POSIXlt("2018-01-04", tz="UTC")
, length.out = 4)
)

res <- spatialwidget::widget_point(
data = df
Expand All @@ -85,7 +97,7 @@ test_that("legends are formatted", {
, fill_colour = "col"
)

expect_equal( as.character( res$legend ), '{"fill_colour":{"colour":["#440154FF","#31688EFF","#35B779FF","#FDE725FF"],"variable":["2017-12-31T13:00:00","2018-01-01T13:00:00","2018-01-02T13:00:00","2018-01-03T13:00:00"],"colourType":["fill_colour"],"type":["gradient"],"title":["col"],"css":[""]}}')
expect_equal( as.character( res$legend ), '{"fill_colour":{"colour":["#440154FF","#31688EFF","#35B779FF","#FDE725FF"],"variable":["2018-01-01T00:00:00","2018-01-02T00:00:00","2018-01-03T00:00:00","2018-01-04T00:00:00"],"colourType":["fill_colour"],"type":["gradient"],"title":["col"],"css":[""]}}')


})

0 comments on commit 7f0e42a

Please sign in to comment.