Skip to content

Commit

Permalink
Merge pull request #2 from baslat:use_st_bbox
Browse files Browse the repository at this point in the history
Use_st_bbox
  • Loading branch information
baslat authored Nov 7, 2022
2 parents 8a12872 + 081e633 commit 6163b96
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 89 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
29 changes: 29 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 7 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
Type: Package
Package: bbb
Title: Build Bounding Boxes
Version: 0.4.1
Version: 1.0.0
Author: Abasi Latcham
Maintainer: Bas <abasi.latcham@gmail.com>
Description: Interactively create a bounding box. Drag a rectangle, make a
bounding box.
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)
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.2.1
42 changes: 26 additions & 16 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion R/bbb-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 16 additions & 12 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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
)
}
47 changes: 0 additions & 47 deletions R/utils-tidy-eval.R

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# bbb: build bounding boxes

<!-- badges: start -->
[![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)
<!-- badges: end -->

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
Expand All @@ -25,4 +26,3 @@ inclined to manually call it, you can do so with
``` r
bbb::box()
```

3 changes: 1 addition & 2 deletions man/bbb-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/morph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6163b96

Please sign in to comment.