Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up documentation, configuration, and CI following S2 version update #263

Merged
merged 21 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
^tools/dist$
^compile_commands\.json$
^\.cache$
^docker-compose\.yml$
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand All @@ -8,19 +8,42 @@ on:

name: R-CMD-check

permissions: read-all

jobs:
# Check MacOS first before embarking on the full check matrix
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
- name: Install Abseil (MacOS)
run: brew install abseil
- name: Install minimal dependencies
run: |
R -e 'install.packages(c("wk", "Rcpp", "bit64", "testthat"))'
- name: Install
run: |
R CMD INSTALL .
- name: Test
run: |
R -e 'testthat::test_local()'

R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

needs:
- test

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
# TODO: Solve Abseil linking issue on R 4.0 and R 4.1/Windows
# - {os: windows-latest, r: '4.1'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: '4.2'}
- {os: windows-latest, r: '4.3'}
- {os: windows-latest, r: 'release'}
Expand All @@ -33,7 +56,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -43,25 +66,27 @@ jobs:
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install Abseil (MacOS)
if: matrix.config.os == 'macos-latest'
run: |
brew install abseil

- name: Set Makevars (Ubuntu)
if: matrix.config.os == 'ubuntu-latest'
run: |
mkdir ~/.R && echo "MAKEFLAGS = -j$(nproc)" > ~/.R/Makevars

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

- name: Show install output
if: always()
run: find check -name '00install.out*' -exec cat '{}' \; || true
shell: bash

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
8 changes: 6 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
Expand All @@ -19,8 +21,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -39,7 +43,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
Expand All @@ -8,19 +6,25 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install Abseil (Ubuntu)
run: |
sudo apt-get update && sudo apt-get install -y libabsl-dev

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: covr
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ License: Apache License (== 2.0)
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
SystemRequirements: OpenSSL >= 1.0.1, Abseil >= 20230802.0
LinkingTo:
Rcpp,
Expand Down
34 changes: 21 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ knitr::opts_chunk$set(
# s2

<!-- badges: start -->
![R-CMD-check](https://github.com/r-spatial/s2/workflows/R-CMD-check/badge.svg)
[![codecov](https://codecov.io/gh/r-spatial/s2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/r-spatial/s2)
[![R-CMD-check](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/r-spatial/s2/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-spatial/s2)
[![CRAN](http://www.r-pkg.org/badges/version/s2)](https://cran.r-project.org/package=s2)
[![Downloads](http://cranlogs.r-pkg.org/badges/s2?color=brightgreen)](https://www.r-pkg.org/pkg/s2)
<!-- badges: end -->

The s2 R package provides bindings to Google's [S2Geometry](http://s2geometry.io) library. The package exposes an API similar to Google's [BigQuery Geography API](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions), whose functions also operate on spherical geometries. Package [sf](https://cran.r-project.org/package=sf) uses this package by default for nearly all its geometrical operations on objects with ellipsoidal (unprojected) coordinates; in cases where it doesn't, such as `st_relate()`, it emits a warning.

This package is a complete rewrite of an earlier CRAN package s2 with versions up
This package is a complete rewrite of an earlier CRAN package s2 with versions up
to 0.4-2, for which the sources are found [here](https://github.com/spatstat/s2/).

## Installation
Expand All @@ -42,6 +42,14 @@ And the development version from [GitHub](https://github.com/) with:
remotes::install_github("r-spatial/s2")
```

The S2 package requires [Abseil]() and OpenSSL. You can install these using a system package manager on most platforms:

- Windows: Both OpenSSL and Abseil are available from RTools since R 4.3
- MacOS: `brew install openssl abseil`
- Debian/Ubuntu: `apt-get install libssl-dev libabsl-dev`
- Fedora: `dnf install openssl-devel abseil-cpp-devel`
- Alpine: `apk add abseil-cpp`

## Example

The s2 package provides geometry transformers and predicates similar to those found in [GEOS](https://trac.osgeo.org/geos/), except instead of assuming a planar geometry, s2's functions work in latitude and longitude and assume a spherical geometry:
Expand All @@ -63,9 +71,9 @@ The [sf package](https://r-spatial.github.io/sf/) uses s2 for geographic coordin
library(dplyr)
library(sf)

nc_s2 <- read_sf(system.file("shape/nc.shp", package = "sf")) %>%
mutate(geometry = as_s2_geography(geometry)) %>%
as_tibble() %>%
nc_s2 <- read_sf(system.file("shape/nc.shp", package = "sf")) %>%
mutate(geometry = as_s2_geography(geometry)) %>%
as_tibble() %>%
select(NAME, geometry)

nc_s2
Expand All @@ -74,7 +82,7 @@ nc_s2
Use accessors to extract information about geometries:

```{r}
nc_s2 %>%
nc_s2 %>%
mutate(
area = s2_area(geometry),
perimeter = s2_perimeter(geometry)
Expand All @@ -84,29 +92,29 @@ nc_s2 %>%
Use predicates to subset vectors:

```{r}
nc_s2 %>%
nc_s2 %>%
filter(s2_contains(geometry, "POINT (-80.9313 35.6196)"))
```

Use transformers to create new geometries:

```{r}
nc_s2 %>%
nc_s2 %>%
mutate(geometry = s2_boundary(geometry))
```

Finally, use the WKB or WKT exporters to export to sf or some other package:

```{r}
nc_s2 %>%
mutate(geometry = st_as_sfc(s2_as_binary(geometry))) %>%
nc_s2 %>%
mutate(geometry = st_as_sfc(s2_as_binary(geometry))) %>%
st_as_sf()
```

## Acknowledgment

This project gratefully acknowledges financial [support](https://www.r-consortium.org/projects) from the
This project gratefully acknowledges financial [support](https://www.r-consortium.org/) from the

<a href="https://www.r-consortium.org/projects">
<a href="https://www.r-consortium.org/">
<img src="man/figures/rc300.png" width="300" />
</a>
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<!-- badges: start -->

![R-CMD-check](https://github.com/r-spatial/s2/workflows/R-CMD-check/badge.svg)
[![codecov](https://codecov.io/gh/r-spatial/s2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/r-spatial/s2)
[![R-CMD-check](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/r-spatial/s2/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-spatial/s2)
[![CRAN](http://www.r-pkg.org/badges/version/s2)](https://cran.r-project.org/package=s2)
[![Downloads](http://cranlogs.r-pkg.org/badges/s2?color=brightgreen)](https://www.r-pkg.org/pkg/s2)
<!-- badges: end -->
Expand Down Expand Up @@ -41,6 +41,15 @@ And the development version from [GitHub](https://github.com/) with:
remotes::install_github("r-spatial/s2")
```

The S2 package requires [Abseil]() and OpenSSL. You can install these
using a system package manager on most platforms:

- Windows: Both OpenSSL and Abseil are available from RTools since R 4.3
- MacOS: `brew install openssl abseil`
- Debian/Ubuntu: `apt-get install libssl-dev libabsl-dev`
- Fedora: `dnf install openssl-devel abseil-cpp-devel`
- Alpine: `apk add abseil-cpp`

## Example

The s2 package provides geometry transformers and predicates similar to
Expand Down Expand Up @@ -69,9 +78,9 @@ using `as_s2_geography()`:
library(dplyr)
library(sf)

nc_s2 <- read_sf(system.file("shape/nc.shp", package = "sf")) %>%
mutate(geometry = as_s2_geography(geometry)) %>%
as_tibble() %>%
nc_s2 <- read_sf(system.file("shape/nc.shp", package = "sf")) %>%
mutate(geometry = as_s2_geography(geometry)) %>%
as_tibble() %>%
select(NAME, geometry)

nc_s2
Expand All @@ -88,13 +97,13 @@ nc_s2
#> 8 Gates POLYGON ((-76.46035 36.3738976, -76.5024643 36.4522858, -76.4983…
#> 9 Warren POLYGON ((-78.1347198 36.2365837, -78.1096268 36.2135086, -78.05…
#> 10 Stokes POLYGON ((-80.0240555 36.5450249, -80.0480957 36.5471344, -80.43…
#> # … with 90 more rows
#> # 90 more rows
```

Use accessors to extract information about geometries:

``` r
nc_s2 %>%
nc_s2 %>%
mutate(
area = s2_area(geometry),
perimeter = s2_perimeter(geometry)
Expand All @@ -112,13 +121,13 @@ nc_s2 %>%
#> 8 Gates POLYGON ((-76.46035 36.3738976, -76.5024643 36.… 9.03e8 123170.
#> 9 Warren POLYGON ((-78.1347198 36.2365837, -78.1096268 3… 1.18e9 141073.
#> 10 Stokes POLYGON ((-80.0240555 36.5450249, -80.0480957 3… 1.23e9 140583.
#> # … with 90 more rows
#> # 90 more rows
```

Use predicates to subset vectors:

``` r
nc_s2 %>%
nc_s2 %>%
filter(s2_contains(geometry, "POINT (-80.9313 35.6196)"))
#> # A tibble: 1 × 2
#> NAME geometry
Expand All @@ -129,7 +138,7 @@ nc_s2 %>%
Use transformers to create new geometries:

``` r
nc_s2 %>%
nc_s2 %>%
mutate(geometry = s2_boundary(geometry))
#> # A tibble: 100 × 2
#> NAME geometry
Expand All @@ -144,15 +153,15 @@ nc_s2 %>%
#> 8 Gates LINESTRING (-76.46035 36.3738976, -76.5024643 36.4522858, -76.49…
#> 9 Warren LINESTRING (-78.1347198 36.2365837, -78.1096268 36.2135086, -78.…
#> 10 Stokes LINESTRING (-80.0240555 36.5450249, -80.0480957 36.5471344, -80.…
#> # … with 90 more rows
#> # 90 more rows
```

Finally, use the WKB or WKT exporters to export to sf or some other
package:

``` r
nc_s2 %>%
mutate(geometry = st_as_sfc(s2_as_binary(geometry))) %>%
nc_s2 %>%
mutate(geometry = st_as_sfc(s2_as_binary(geometry))) %>%
st_as_sf()
#> Simple feature collection with 100 features and 1 field
#> Geometry type: GEOMETRY
Expand All @@ -172,13 +181,13 @@ nc_s2 %>%
#> 8 Gates POLYGON ((-76.46035 36.3739, -76.50246 36.45229, -76.49834 36.50…
#> 9 Warren POLYGON ((-78.13472 36.23658, -78.10963 36.21351, -78.05835 36.2…
#> 10 Stokes POLYGON ((-80.02406 36.54502, -80.0481 36.54713, -80.43531 36.55…
#> # … with 90 more rows
#> # 90 more rows
```

## Acknowledgment

This project gratefully acknowledges financial
[support](https://www.r-consortium.org/projects) from the
[support](https://www.r-consortium.org/) from the

<a href="https://www.r-consortium.org/projects">
<a href="https://www.r-consortium.org/">
<img src="man/figures/rc300.png" width="300" /> </a>
Loading
Loading