Skip to content

Commit

Permalink
going to cran
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Mar 20, 2020
1 parent d567a19 commit 63f7a98
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 129 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spatialwidget
Type: Package
Title: Formats Spatial Data For Use in Htmlwidgets
Title: Formats Spatial Data for Use in Htmlwidgets
Version: 0.2.2
Date: 2020-03-19
Date: 2020-03-20
Authors@R: c(
person("David", "Cooley", ,"dcooley@symbolix.com.au", role = c("aut", "cre"))
)
Expand All @@ -25,7 +25,7 @@ LinkingTo:
jsonify (>= 1.1.1),
rapidjsonr,
Rcpp,
sfheaders (>= 0.2.0)
sfheaders (>= 0.2.1)
RoxygenNote: 7.0.2
Suggests:
colourvalues,
Expand Down
4 changes: 3 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
## Release Notes

* Updates v0.2 to v0.2.2
* updated to work with geojsonsf v1.3.3 dependency
* updated to work with geojsonsf v1.3.3 and sfheaders v0.2.1 dependencies



## Test environments
* local OS X install, R 3.6.1
* ubuntu 14.04 (on travis-ci), R 3.5.0
* rhub check with sanitizers
* rhub check for cran
* win-builder (devel and release)

## R CMD check results
Expand Down
Empty file removed src/factors.cpp
Empty file.
125 changes: 0 additions & 125 deletions vignettes/spatialwidget.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -194,64 +194,6 @@ inline Rcpp::List create_geojson(

---

### single-`sfc`-column `sf` to down-casted geometries in pseudo-geojson


```c++
/*
* expects `data` to be an sf object, where the geometry_column is a string
* of the sfc column names (of sf) you want to use as the geometry object inside the GeoJSON.
* This function will down-cast MULTI* objects to their single form
*
*/
inline Rcpp::List create_geojson_downcast(
Rcpp::DataFrame& data,
Rcpp::List& params,
Rcpp::List& lst_defaults,
std::unordered_map< std::string, std::string >& layer_colours,
Rcpp::StringVector& layer_legend,
int& data_rows,
Rcpp::StringVector& parameter_exclusions,
std::string& geometry_column,
bool jsonify_legend
)
```

**in** - `sf` object with one `sfc` column

**out** - MULTI* geometries down-cast to simpler form, in pseudo-geojson

---

### two-`sfc`-column `sf` to down-casted psuedo-geojson


```c++
/*
* expects `data` to be an sf object, where the geometry_column is a string vector
* of the sfc column name (of sf) you want to use as the geometry object inside the GeoJSON.
* This function will down-cast MULTI* objects to their single form
*
*/
inline Rcpp::List create_geojson_downcast(
Rcpp::DataFrame& data,
Rcpp::List& params,
Rcpp::List& lst_defaults,
std::unordered_map< std::string, std::string >& layer_colours,
Rcpp::StringVector& layer_legend,
int& data_rows,
Rcpp::StringVector& parameter_exclusions,
Rcpp::StringVector& geometry_column,
bool jsonify_legend
)
```
**in** - `sf` object with two `sfc` columns
**out** - MULTI* geometries down-cast to simpler form, in pseudo-geojson
---
### `data.frame` with lon & lat columns to pseudo-geojson


Expand Down Expand Up @@ -589,19 +531,6 @@ This structure is useful for sending to an htmlwidget because each object in the

Therefore, most of the GeoJSON functions inside spatialwidget will return the 'atomised' form.

## Downcasting geojson

**Downcasting** is the process of converting MULTI objects to their simpler form. For example, a MULTIPOINT will be down-cast to POINTs (one row/value for each of the multipoints).

```{r}
js <- '{"type":"Feature","properties":{"id":1,"val":"a"},"geometry":{"type":"MultiPoint","coordinates":[[1,4],[2,5],[3,6]]}}'
sf <- geojsonsf::geojson_sf( js )
geo_down <- spatialwidget:::rcpp_sf_to_geojson_downcast( sf, "geometry" )
jsonify::pretty_json( geo_down )
```

See here we started with a single MULTIPOINT (containing three coordinates), and we are returned three POINTs. Also notice the `id` and `val` fields are repeated across the new POINTs.

# GeoJSON C++ API

You can by-pass the `spatialwidget::api::` namepsace and call the `spatialwidget::geojson::` api directly. However, doing so will only convert your data to pseudo-geojson, it won't create colours or legends.
Expand Down Expand Up @@ -633,60 +562,6 @@ substr( geojson, 1, 500)

---

### single-`sfc`-column `sf` to downcasted, atomised pseudo-geojson

```
// down-casts MULTIGEOMETRIES to their simpler geometry
// only for one-column sfc objects
inline Rcpp::StringVector to_geojson_downcast_atomise(
Rcpp::DataFrame& sf,
std::string geometry ) {
```

```{r}
geojson <- spatialwidget:::rcpp_sf_to_geojson_downcast( sf = widget_capitals, geometry_column = "geometry" )
substr( geojson, 1, 500)
```


**in** - `sf` object with one `sfc` column

**out** - pseudo-geojson downcast to simpler form

---

### two-`sfc`-column `sf` to downcasted, atomised pseudo-geojson

```
inline Rcpp::StringVector to_geojson_downcast_atomise(
Rcpp::DataFrame& sf,
Rcpp::StringVector geometries )
{
```

```{r}
feat1 <- '{"type":"Feature","properties":{"id":1},"geometry":{"type":"MultiPoint","coordinates":[[0,0],[2,2],[4,4]]}}'
feat2 <- '{"type":"Feature","properties":{"id":2},"geometry":{"type":"MultiPoint","coordinates":[[1,1],[3,3],[5,5]]}}'
sf1 <- geojsonsf::geojson_sf( feat1 )
sf2 <- geojsonsf::geojson_sf( feat2 )
names( sf2 ) <- c("id.1","geometry.1")
sf <- cbind( sf1, sf2)
geojson <- spatialwidget:::rcpp_sf_to_geojson_multi_column_downcast(
sf = sf
, geometries = c("geometry","geometry.1")
)
geojson
```

**in** - `sf` object with two `sfc` columns

**out** - pseudo-geojson down-cast to simpler form. It will repeat the other columns to the correct length.

---

### single-`sfc`-column `sf` to standard geojson

```
Expand Down

0 comments on commit 63f7a98

Please sign in to comment.