An open API service indexing awesome lists of open source software.

https://github.com/knapply/rcppsimdgeojson

(aspirationally) blazing fast rcpp(simdjson) routines for GeoJSON
https://github.com/knapply/rcppsimdgeojson

Last synced: about 1 month ago
JSON representation

(aspirationally) blazing fast rcpp(simdjson) routines for GeoJSON

Awesome Lists containing this project

README

        

---
title: "`{rcppsimdgeojson}`"
output:
github_document:
html_preview: true
toc: true
toc_depth: 5
html_document:
keep_md: yes
always_allow_html: yes
editor_options:
chunk_output_type: console
---

```{r, echo=FALSE}
knitr::opts_chunk$set(
# collapse = TRUE,
fig.align = "center",
comment = "#>",
fig.path = "man/figures/",
# message = FALSE,
warning = FALSE
)

options(width = 150)
```

[![GitHub last commit](https://img.shields.io/github/last-commit/knapply/rcppsimdgeojson.svg)](https://github.com/knapply/rcppsimdgeojson/commits/master)
[![Lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R build status](https://github.com/knapply/rcppsimdgeojson/workflows/R-CMD-check/badge.svg)](https://github.com/knapply/rcppsimdgeojson/actions?workflow=R-CMD-check)
[![Codecov test coverage](https://codecov.io/gh/knapply/rcppsimdgeojson/branch/master/graph/badge.svg)](https://codecov.io/gh/knapply/rcppsimdgeojson?branch=master)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Depends-R](https://img.shields.io/badge/Depends-GNU_R >= 4.0-blue.svg)](https://www.r-project.org/)
[![Depends-C++](https://img.shields.io/badge/Depends-C++17-blue.svg)](https://en.cppreference.com/w/cpp/17)
[![Depends-GCC](https://img.shields.io/badge/Depends-GCC >= 7-red.svg)](https://gcc.gnu.org/)
[![Depends-CLang](https://img.shields.io/badge/Depends-Clang >= 7-red.svg)](https://clang.llvm.org/)
[![Depends-RTools](https://img.shields.io/badge/Depends-RTools >= 40-red.svg)](https://cran.r-project.org/bin/windows/Rtools/)

___WIP: This is still not useful...___

## Installation

```{r, eval=FALSE}
if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")
remotes::install_github("knapply/rcppsimdgeojson")
```

```{r}
geojson_files <- list.files(system.file("geojsonexamples", package = "rcppsimdgeojson"),
recursive = TRUE, pattern = "\\.geojson$", full.names = TRUE)
geojson_files <- geojson_files[!grepl("largeMixedTest", geojson_files, fixed = TRUE)]

names(geojson_files) <- basename(geojson_files)
```

## Conformance

```{r}
identical_w_sf <- vapply(
geojson_files, function(.file) {
identical(rcppsimdgeojson:::.fload_sfc(.file), sf::read_sf(.file)$geometry)
},
logical(1L)
)

stopifnot(all(identical_w_sf))
as.matrix(identical_w_sf)

big_geojson <- path.expand("~/Downloads/bay_delta_89b.geojson")

test <- rcppsimdgeojson:::.fload_sfc(big_geojson)
target <- sf::read_sf(big_geojson)$geometry
stopifnot(identical(test, target))

test
plot(test)
```

## Benchmarking

### ``

#### Big File

```{r}
sprintf("%f MB", file.size(big_geojson) * 1e-6)

microbenchmark::microbenchmark(
rcppsimdgeojson = rcppsimdgeojson:::.fload_sfc(big_geojson),
geojsonsf = geojsonsf:::rcpp_read_sfc_file(big_geojson, mode = "rb",
flatten_geometries = FALSE)
,
times = 5
)
```

#### Tiny Files

```{r}
lapply(geojson_files, function(.file) {
microbenchmark::microbenchmark(
rcppsimdgeojson = rcppsimdgeojson:::.fload_sfc(.file),
geojsonsf = geojsonsf:::rcpp_read_sfc_file(.file, mode = "rb",
flatten_geometries = FALSE),
unit = "relative"
)
})
```

#### Tiny Strings

```{r}
geojson_strings <- vapply(geojson_files, function(.file) {
readChar(.file, nchars = file.size(.file))
}, character(1L))

lapply(geojson_strings, function(.geojson) {
microbenchmark::microbenchmark(
rcppsimdgeojson = rcppsimdgeojson:::.fparse_sfc(.geojson),
geojsonsf = geojsonsf:::rcpp_geojson_to_sfc(.geojson, expand_geometries = FALSE),
unit = "relative"
)
})
```