diff --git a/.Rbuildignore b/.Rbuildignore index e13c405..31e3754 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..f4b17a4 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,29 @@ +# 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: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + 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::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 diff --git a/DESCRIPTION b/DESCRIPTION index fd543c0..f16d6de 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: bbb Title: Build Bounding Boxes -Version: 0.4.1 +Version: 1.0.0 Author: Abasi Latcham Maintainer: Bas Description: Interactively create a bounding box. Drag a rectangle, make a @@ -9,18 +9,17 @@ Description: Interactively create a bounding box. Drag a rectangle, make a License: MIT + file LICENSE URL: https://github.com/baslat/bbb BugReports: https://github.com/baslat/bbb/issues -Imports: +Imports: glue, leaflet, leaflet.extras, magrittr, - purrr, - rlang (>= 0.1.2), rstudioapi, - shiny, - tibble -Suggests: + sf, + shiny +Suggests: dplyr, + purrr, roxygen2, spelling, testthat (>= 3.0.0) @@ -28,4 +27,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.1 diff --git a/NEWS.md b/NEWS.md index 1917c87..d910942 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,31 +1,41 @@ +# bbb 1.0.0 + +- Use `{sf}` to make the bounding box with `sf::st_bbox()`. + # bbb 0.4.1 -* `box` now returns the code to set CRS attribute with EPSG:4326 in accordance + +- `box` now returns the code to set CRS attribute with EPSG:4326 in accordance with [Stack Exchange](https://gis.stackexchange.com/questions/310091/what-does-the-default-crs-being-epsg3857-in-leaflet-mean) # bbb 0.4.0 -* `box` now returns the code to set CRS attribute with EPSG:3857 in accordance + +- `box` now returns the code to set CRS attribute with EPSG:3857 in accordance with [leaflet documentation](https://rstudio.github.io/leaflet/projections.html) , and this is respected by `morph` -* minor didactic tweaks +- minor didactic tweaks # bbb 0.3.0 -* adds `morph` functions to change the format of bounding boxes -* fixes an incorrect reference in the returned code -* changes to use left, right etc instead of xmin, xmax in returned code -* removes `crayon` from dependencies -* adds `dplyr` to `suggests` + +- adds `morph` functions to change the format of bounding boxes +- fixes an incorrect reference in the returned code +- changes to use left, right etc instead of xmin, xmax in returned code +- removes `crayon` from dependencies +- adds `dplyr` to `suggests` # bbb 0.2.0 -* removes pipe from returned code -* unforces bbox code to print to console -* makes the instructions more explicit -* removes `sf` from dependencies -* removes most of the unnecessary features + +- removes pipe from returned code +- unforces bbox code to print to console +- makes the instructions more explicit +- removes `sf` from dependencies +- removes most of the unnecessary features # bbb 0.1.1 -* forces bbox code to print to console -* comments out creation of global objects + +- forces bbox code to print to console +- comments out creation of global objects # bbb 0.1.0 -* Added a `NEWS.md` file to track changes to the package. + +- Added a `NEWS.md` file to track changes to the package. diff --git a/R/bbb-package.R b/R/bbb-package.R index c1955b4..b30bbda 100644 --- a/R/bbb-package.R +++ b/R/bbb-package.R @@ -4,6 +4,5 @@ # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start -#' @importFrom tibble tibble ## usethis namespace: end NULL diff --git a/R/functions.R b/R/functions.R index 7cf291b..8596690 100644 --- a/R/functions.R +++ b/R/functions.R @@ -6,10 +6,8 @@ #' code_bbox <- function(mbb) { bb_code <- glue::glue( - 'bbox <- c("left" = {mbb[1,1]}, "bottom" = {mbb[2,1]}, "right" = {mbb[1,2]}, "top" = {mbb[2,2]}) - attr(bbox, "class") <- "bbox" - attr(bbox, "crs") <- sf::st_crs(4326)' - ) + 'bbox <- sf::st_bbox(c("xmin" = {mbb[["xmin"]]}, "ymin" = {mbb[["ymin"]]}, "xmax" = {mbb[["xmax"]]}, "ymax" = {mbb[["ymax"]]}), crs = 4326L)' + ) rstudioapi::insertText(text = bb_code) invisible() } @@ -23,12 +21,18 @@ code_bbox <- function(mbb) { #' @return a matrix manual_bbox <- function(coords) { # the + 360 is probably not always valid - left <- coords[[1]][[1]] - right <- coords[[3]][[1]] - bottom <- coords[[1]][[2]] - top <- coords[[3]][[2]] - bb <- rbind(c(left, right), c(bottom, top)) - dimnames(bb) <- list(c("x", "y"), c("min", "max")) - attr(bb, "class") <- "bbox" - return(bb) + xmin <- coords[[1L]][[1L]] + xmax <- coords[[3L]][[1L]] + ymin <- coords[[1L]][[2L]] + ymax <- coords[[3L]][[2L]] + + sf::st_bbox( + c( + "xmin" = xmin, + "ymin" = ymin, + "xmax" = xmax, + "ymax" = ymax + ), + crs = 4326L + ) } diff --git a/R/utils-tidy-eval.R b/R/utils-tidy-eval.R deleted file mode 100644 index b4e6c7f..0000000 --- a/R/utils-tidy-eval.R +++ /dev/null @@ -1,47 +0,0 @@ -#' Tidy eval helpers -#' -#' @description -#' -#' * \code{\link[rlang]{sym}()} creates a symbol from a string and -#' \code{\link[rlang:sym]{syms}()} creates a list of symbols from a -#' character vector. -#' -#' * \code{\link[rlang:nse-defuse]{enquo}()} and -#' \code{\link[rlang:nse-defuse]{enquos}()} delay the execution of one or -#' several function arguments. \code{enquo()} returns a single quoted -#' expression, which is like a blueprint for the delayed computation. -#' \code{enquos()} returns a list of such quoted expressions. -#' -#' * \code{\link[rlang:nse-defuse]{expr}()} quotes a new expression _locally_. It -#' is mostly useful to build new expressions around arguments -#' captured with [enquo()] or [enquos()]: -#' \code{expr(mean(!!enquo(arg), na.rm = TRUE))}. -#' -#' * \code{\link[rlang]{as_name}()} transforms a quoted variable name -#' into a string. Supplying something else than a quoted variable -#' name is an error. -#' -#' That's unlike \code{\link[rlang]{as_label}()} which also returns -#' a single string but supports any kind of R object as input, -#' including quoted function calls and vectors. Its purpose is to -#' summarise that object into a single label. That label is often -#' suitable as a default name. -#' -#' If you don't know what a quoted expression contains (for instance -#' expressions captured with \code{enquo()} could be a variable -#' name, a call to a function, or an unquoted constant), then use -#' \code{as_label()}. If you know you have quoted a simple variable -#' name, or would like to enforce this, use \code{as_name()}. -#' -#' To learn more about tidy eval and how to use these tools, visit -#' \url{https://tidyeval.tidyverse.org} and the -#' \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming -#' section} of \href{https://adv-r.hadley.nz}{Advanced R}. -#' -#' @md -#' @name tidyeval -#' @keywords internal -#' @importFrom rlang expr enquo enquos sym syms .data := as_name as_label -#' @aliases expr enquo enquos sym syms .data := as_name as_label -#' @export expr enquo enquos sym syms .data := as_name as_label -NULL diff --git a/README.md b/README.md index 4f70fc0..f4724c8 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ # bbb: build bounding boxes +[![R-CMD-check](https://github.com/baslat/bbb/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/baslat/bbb/actions/workflows/R-CMD-check.yaml) -The goal of bbb is to allow for the interactive creation of bounding boxes +The goal of bbb is to allow for the interactive creation of spatial bounding boxes inside R Studio. ## Installation @@ -25,4 +26,3 @@ inclined to manually call it, you can do so with ``` r bbb::box() ``` - diff --git a/man/bbb-package.Rd b/man/bbb-package.Rd index 29c8824..e31c112 100644 --- a/man/bbb-package.Rd +++ b/man/bbb-package.Rd @@ -6,8 +6,7 @@ \alias{bbb-package} \title{bbb: Build Bounding Boxes} \description{ -Interactively create a bounding box. Drag a - rectangle, make a bounding box. +Interactively create a bounding box. Drag a rectangle, make a bounding box. } \seealso{ Useful links: diff --git a/man/morph.Rd b/man/morph.Rd index f0f2f6c..df691b4 100644 --- a/man/morph.Rd +++ b/man/morph.Rd @@ -27,5 +27,4 @@ attr(bbox, "class") <- "bbox" bbox2 <- morph(bbox, "xy_string") } - }