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
- Host: GitHub
- URL: https://github.com/knapply/rcppsimdgeojson
- Owner: knapply
- Created: 2020-10-26T00:15:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-31T17:16:53.000Z (over 4 years ago)
- Last Synced: 2025-01-16T03:14:24.439Z (3 months ago)
- Language: C++
- Homepage:
- Size: 85 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- awesome-blazingly-fast - rcppsimdgeojson - (aspirationally) blazing fast rcpp(simdjson) routines for GeoJSON (C++)
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)
```[](https://github.com/knapply/rcppsimdgeojson/commits/master)
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://github.com/knapply/rcppsimdgeojson/actions?workflow=R-CMD-check)
[](https://codecov.io/gh/knapply/rcppsimdgeojson?branch=master)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://www.r-project.org/)
[](https://en.cppreference.com/w/cpp/17)
[](https://gcc.gnu.org/)
[](https://clang.llvm.org/)
[](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"
)
})
```