Skip to content

Commit

Permalink
Geojsonsf (#118)
Browse files Browse the repository at this point in the history
* Start experimenting with geojsonsf

* Fix tests

* Fix test

* Remove geo_list methods

* Change sp examples to sf

* Add geojsonsf, move geojsonio to Suggests

* document

* Remove test that just tests mapshaper

* Use rgdal directly to write sp to tempfile (no geojsonio)

* Define and use expect_equivalent_json to test geojson strings

* Fix tests and examples

* Document

* Make sure sf_to_GeoJSON always returns an FC

* No longer need to install Rcpp from source

* Add test helper to ignore df column order

* Clean up scratch folder

* Update DESCRIPTION

* use checkout@v2

* Simpler example

* change all proj -> crs

* Error in clip_erase when non-identical crs

* Methods for json rather than geo_json; also use jsonify::validate_json instead of geojsonlint

* Update min geojsonsf version and add Remotes to DESCRIPTION

* Don't support POSIXlt

* set test encoding

* remove last geojson method

* silence rgdal CRS warnings; remove geojsonio refs

* document

* Update NEWS

* namespace methods::slot

* test encoding with sf and sp

* Suppress crs assignment warning

* Add test for #91

* Temporarily use geojsonsf branch with encoding fix

* update encoding test for names and values

* Use PR for geojsonsf remote (windows encoding)

* Actions: Use ubuntu-gis-unstable ppa

* Tweaks to GH Actions

* Update CI

* Remove docker-based CI workflow

* CI: don't install spatial sysreqs since installing binaries from rspm

* Udpate imports versions, remove remote from geojsonsf

* Try new minimal CI workflow

* Use v2 actions

* Add old linux to test old v8

* Update gitignore

* CI: Change old Ubuntu from 16.04 to 18.04

* Edit R-CMD-check badge, render README

* documentation in apply_mapshaper_commands fixes #121

* Simplify cmd arg construction by setting NULL defaults

* Use ... to pass common args to apply_mapshaper_commands

* Add quiet parameter. Closes #125

* Add global sys_mem option

* document

* Use ... in clip & erase for common args

* documentation

* Add node mapshaper to CI

* typo

* Remove usages of rgdal and rgeos. Closes #129

* render readme and document

* Update GH actions

* Tweak news, build readme

* sp -> sf

---------

Co-authored-by: David Blodgett <dblodgett@usgs.gov>
  • Loading branch information
ateucher and dblodgett-usgs authored Apr 4, 2023
1 parent d9ba4a2 commit 1168c61
Show file tree
Hide file tree
Showing 71 changed files with 1,484 additions and 1,444 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
29 changes: 0 additions & 29 deletions .github/workflows/R-CMD-check-docker.yaml

This file was deleted.

131 changes: 34 additions & 97 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,123 +1,60 @@
on: [push, pull_request]
# 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
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

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

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

strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'release', args: "--no-manual"}
- { os: macOS-latest, r: 'release', args: "--no-manual"}
- { os: macOS-latest, r: 'release', args: "--no-manual", no_node: true}
- { os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", v8: "libnode-dev", args: "--no-manual"}
- { os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", v8: "libnode-dev"}
- { os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", v8: "libv8-dev"}
- { os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", v8: "libnode-dev", args: "--no-manual"}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
CRAN: ${{ matrix.config.cran }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
cache-version: v3
R_KEEP_PKG_SOURCE: yes

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

- uses: actions/setup-node@v1
if: matrix.config.no_node == false
- uses: actions/setup-node@v3
with:
node-version: '16'

- name: install mapshaper node lib
if: matrix.config.no_node == false
- name: Install mapshaper
run: npm install -g mapshaper

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

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

- uses: r-lib/actions/setup-tinytex@master
if: contains(matrix.config.args, 'no-manual') == false

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ env.cache-version }}-${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-r-${{ matrix.config.r }}-

- name: install macOS system dependencies
if: runner.os == 'macOS'
continue-on-error: true
run: |
brew install pkg-config gdal openssl udunits v8 protobuf
extra-packages: any::rcmdcheck
needs: check

- name: add modern cran/v8 ppa
# default libv8-dev on Xenial (16) and Bionic (18) is old libv8-3.14.5.
# To test on new, add the cran/v8 ppa and install current libnode-dev,
# To test on old, install libv8-dev from existing default ppa
if: runner.os == 'Linux' && contains(matrix.config.v8, 'libnode-dev') == true
run: |
sudo add-apt-repository -y ppa:cran/v8
sudo apt-get -y update
- name: Install remotes package
run: Rscript -e "install.packages('remotes')"

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo add-apt-repository -y ppa:cran/v8
sudo -s eval "$sysreqs"
# install spatial dependencies
sudo apt update
sudo apt install \
libudunits2-dev \
libgdal-dev \
libgeos-dev \
libproj-dev \
${{ matrix.config.v8 }}
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran('rcmdcheck')
shell: Rscript {0}

- name: Check
env:
TMPDIR: ${{ runner.temp }}
run: |
rcmdcheck::rcmdcheck(args = "${{ matrix.config.args }}", error_on = 'warning', check_dir = 'check')
shell: Rscript {0}


- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Test coverage
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'release'
continue-on-error: true
run: |
Rscript -e 'remotes::install_github("r-lib/covr@gh-actions")'
Rscript -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
upload-snapshots: true
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

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

steps:
- uses: actions/checkout@v3

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

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

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
22 changes: 9 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,29 @@ Description: Edit and simplify 'geojson', 'Spatial', and 'sf'
by Matthew Bloch <https://github.com/mbloch/mapshaper/> to perform
topologically-aware polygon simplification, as well as other
operations such as clipping, erasing, dissolving, and converting
'multi-part' to 'single-part' geometries. It relies on the
'geojsonio' package for working with 'geojson' objects, the 'sf'
package for working with 'sf' objects, and the 'sp' and 'rgdal'
packages for working with 'Spatial' objects.
'multi-part' to 'single-part' geometries.
License: MIT + file LICENSE
URL: https://github.com/ateucher/rmapshaper
BugReports: https://github.com/ateucher/rmapshaper/issues
Imports:
geojsonio (>= 0.9.4),
geojsonlint (>= 0.4.0),
jsonlite (>= 1.7.0),
methods,
readr (>= 1.4.0),
sf (>= 0.9-0),
geojsonsf (>= 2.0.2),
jsonify (>= 1.2.0),
readr (>= 2.1.0),
sf (>= 1.0.0),
sp (>= 1.4-0),
V8 (>= 3.4.2)
V8 (>= 4.0.0)
Suggests:
geojsonio,
knitr,
magrittr,
rgdal,
rgeos,
rmarkdown,
testthat (>= 2.1.0),
jsonlite,
covr,
units
VignetteBuilder:
knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
34 changes: 11 additions & 23 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,74 +1,63 @@
# Generated by roxygen2: do not edit by hand

S3method(drop_null_geometries,character)
S3method(drop_null_geometries,geo_json)
S3method(drop_null_geometries,geo_list)
S3method(drop_null_geometries,json)
S3method(ms_clip,SpatialLines)
S3method(ms_clip,SpatialPoints)
S3method(ms_clip,SpatialPolygons)
S3method(ms_clip,character)
S3method(ms_clip,geo_json)
S3method(ms_clip,geo_list)
S3method(ms_clip,json)
S3method(ms_clip,sf)
S3method(ms_clip,sfc)
S3method(ms_dissolve,SpatialPoints)
S3method(ms_dissolve,SpatialPolygons)
S3method(ms_dissolve,character)
S3method(ms_dissolve,geo_json)
S3method(ms_dissolve,geo_list)
S3method(ms_dissolve,json)
S3method(ms_dissolve,sf)
S3method(ms_dissolve,sfc)
S3method(ms_erase,SpatialLines)
S3method(ms_erase,SpatialPoints)
S3method(ms_erase,SpatialPolygons)
S3method(ms_erase,character)
S3method(ms_erase,geo_json)
S3method(ms_erase,geo_list)
S3method(ms_erase,json)
S3method(ms_erase,sf)
S3method(ms_erase,sfc)
S3method(ms_explode,SpatialLines)
S3method(ms_explode,SpatialPolygons)
S3method(ms_explode,character)
S3method(ms_explode,geo_json)
S3method(ms_explode,geo_list)
S3method(ms_explode,json)
S3method(ms_explode,sf)
S3method(ms_explode,sfc)
S3method(ms_filter_fields,SpatialLinesDataFrame)
S3method(ms_filter_fields,SpatialPointsDataFrame)
S3method(ms_filter_fields,SpatialPolygonsDataFrame)
S3method(ms_filter_fields,character)
S3method(ms_filter_fields,geo_json)
S3method(ms_filter_fields,geo_list)
S3method(ms_filter_fields,json)
S3method(ms_filter_fields,sf)
S3method(ms_filter_islands,SpatialPolygons)
S3method(ms_filter_islands,character)
S3method(ms_filter_islands,geo_json)
S3method(ms_filter_islands,geo_list)
S3method(ms_filter_islands,json)
S3method(ms_filter_islands,sf)
S3method(ms_filter_islands,sfc)
S3method(ms_innerlines,SpatialPolygons)
S3method(ms_innerlines,character)
S3method(ms_innerlines,geo_json)
S3method(ms_innerlines,geo_list)
S3method(ms_innerlines,json)
S3method(ms_innerlines,sf)
S3method(ms_innerlines,sfc)
S3method(ms_lines,SpatialPolygons)
S3method(ms_lines,character)
S3method(ms_lines,geo_json)
S3method(ms_lines,geo_list)
S3method(ms_lines,json)
S3method(ms_lines,sf)
S3method(ms_lines,sfc)
S3method(ms_points,SpatialPolygons)
S3method(ms_points,character)
S3method(ms_points,geo_json)
S3method(ms_points,geo_list)
S3method(ms_points,json)
S3method(ms_points,sf)
S3method(ms_points,sfc)
S3method(ms_simplify,SpatialLines)
S3method(ms_simplify,SpatialPolygons)
S3method(ms_simplify,character)
S3method(ms_simplify,geo_json)
S3method(ms_simplify,geo_list)
S3method(ms_simplify,json)
S3method(ms_simplify,sf)
S3method(ms_simplify,sfc)
export(apply_mapshaper_commands)
Expand All @@ -85,7 +74,6 @@ export(ms_lines)
export(ms_points)
export(ms_simplify)
importFrom(V8,v8)
importFrom(geojsonlint,geojson_validate)
importFrom(methods,.hasSlot)
importFrom(methods,as)
importFrom(methods,is)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# rmapshaper (development version)

* Switched to using the `geojsonsf` package instead of `geojsonio` for object conversion (#118).
* Dropped support for `geojson_list` objects. This was a rarely-used class from the `geojsonio` package (#118)
* Arguments `force_FC`, `sys`, and `sys_mem` are now passed to `apply_mapshaper_commands` via `...` rather than explicitly, so they are now documented in the `...` section of each function. This may break some existing code if you were passing values to these arguments by position rather than by name, especially using `force_FC` in `ms_simplify` as it was not at the end of the argument list. It may also change the class of the return value for some input classes and functions (such as `ms_lines` and `ms_innerlines`) as `force_FC` will inherit the default `TRUE` for all functions.
* Added `quiet` option to silence mapshaper console messages when using `sys = TRUE` (#125)
* Added ability to globally set the system memory when using the system mapshaper via `options("mapshaper.sys_mem"=X)`, where `X` is the amount of memory in GB.

# rmapshaper 0.4.6

* Fixed a long-standing issue where `units` columns in `sf` objects would cause failures; all numeric columns of class `"units"` are now converted to numeric before running through mapshaper commands. (#116, thanks @Robinlovelace)
Expand Down
Loading

0 comments on commit 1168c61

Please sign in to comment.