Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
Merge branch 'master' into osm_buildings

# Conflicts:
#	.Rbuildignore
#	DESCRIPTION
#	NAMESPACE
#	man/leaflet.extras2.Rd
#	tests/testthat.R
  • Loading branch information
trafficonese committed Sep 1, 2024
2 parents 21ff802 + 96298c7 commit 89907e3
Show file tree
Hide file tree
Showing 266 changed files with 26,078 additions and 81,331 deletions.
21 changes: 13 additions & 8 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
^cran-comments\.md$
^README\.md$
^README\.Rmd$
^\.travis\.yml$
^appveyor\.yml$
^\_pkgdown\.yaml$
^docs$
^CODE_OF_CONDUCT\.md$
^node_modules/$
^node_modules/
^node_modules/.*
^newfeatures/$
^newfeatures/
^newfeatures/.*
^node_modules$
^bower_components$
^newfeatures$
^package\.json$
^package-lock\.json$
^data-raw$
^codecov\.yml$
^_pkgdown\.yml$
^pkgdown$
^\.github$
^CRAN-RELEASE$
^revdep$
^bower_components$
^HowTo\.html$
^HowTo\.md$
^HowTo\.rmd$
^CRAN-SUBMISSION$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug report or feature request
about: Describe a bug you've seen or make a case for a new feature
---

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on <https://stackoverflow.com/> or <https://community.rstudio.com/>.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading <https://www.tidyverse.org/help/#reprex>.

Brief description of the problem

```r
# insert reprex here
```
56 changes: 56 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
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 }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- 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-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

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

48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

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

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

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.Rproj.user
newfeatures/
node_modules/
docs/
bower_components/
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

29 changes: 17 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
Package: leaflet.extras2
Type: Package
Title: Extra Functionality for 'leaflet' Package
Version: 1.0.0
Version: 1.2.2.9000
Authors@R: c(
person("Gatscha", "Sebastian", email = "[email protected]", role = c("aut", "cre"))
person("Gatscha", "Sebastian", email = "[email protected]", role = c("aut", "cre")),
person("Ricardo Rodrigo", "Basa", email = "[email protected]", role = c("ctb")),
person(c("Jeffrey", "O"), "Hanson", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0002-4716-6134"))
)
Description: This package serves as an add-on to the 'leaflet' package by
providing extra functionality via 'leaflet' plugins.
Description: Several 'leaflet' plugins are integrated, which are available as extension to the 'leaflet' package.
License: GPL-3 | file LICENSE
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.1.0),
R (>= 3.5.0),
leaflet (>= 2.0.0)
Imports:
htmlwidgets,
htmltools,
shiny,
jsonlite,
magrittr
magrittr,
utils
Suggests:
jsonlite,
shiny,
sf,
geojsonsf,
sp,
testthat (>= 3.0.0)
URL: https://github.com/trafficonese/leaflet.extras2
testthat (>= 2.1.0),
fontawesome,
htmlwidgets,
covr,
curl
URL: https://trafficonese.github.io/leaflet.extras2/, https://github.com/trafficonese/leaflet.extras2
BugReports: https://github.com/trafficonese/leaflet.extras2/issues
RoxygenNote: 7.3.1
Config/testthat/edition: 3
42 changes: 42 additions & 0 deletions HowTo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## How to include a new plugin ❓

------

Fork this repo on your computer and create a **new branch** with the plugin name.

The plugin [leaflet-arrowheads](https://github.com/slutske22/leaflet-arrowheads) will serve as example for this tutorial.

1. Create a **new directory** in `./inst/htmlwidgets/` with the prefix `lfx-` and the plugin name. This snippet will do that for you:

usethis::use_directory("/inst/htmlwidgets/lfx-arrowhead")

2. Install the **dependencies** via `npm`/`bower` etc if available. If the package cannot be installed, either fork/download the plugin-repo or copy/paste the JavaScript code manually. This plugin can be installed and requires 2 dependencies. I installed them with:

npm install leaflet-arrowheads --save
npm install leaflet-geometryutil --save
This will add the dependencies in the directory `./node_modules/`. Find the directories with the source files and copy those into the new directory `lfx-arrowhead`. In this case the files: **leaflet.geometryutil.js** and **leaflet-arrowheads.js**

3. Create a **new R-file** with the name of the plugin in `./R/`. In this case `arrowhead.R` or copy/paste another R-file and rename it accordingly. I copy/pasted the `antpath.R` file and search/replaced `antpath` with `arrowhead` and `Antpath` with `Arrowhead` and adapted the functions and options according to the plugin.

4. Add a **JavaScript-binding** file in the directory `/inst/htmlwidgets/lfx-arrowhead`. Look at other plugins and their bindings for references and examples. In the beginning I use a lot of `console.log()` and `debugger` statements in the JS-methods to get an idea what the data looks like, if all arguments are passed correctly, etc. In this case I also copy/pasted the file `lfx-ant-path-bindings.js`, renamed it `leaflet-arrowheads-bindings.js` and adapted the JavaScript code.
If the plugin exposes several methods, you can/should write an R-function for every JS-method. The R-function calls the JS-method with `invokeMethod` where the argument *method* should correspond to the JavaScript method you want to invoke. The arrowheads-plugin has the method **deleteArrowheads**. I used that method for two R and JS functions, one where you can remove the arrowheads by **group** (`clearArrowhead`) and one by **layerId** (`removeArrowhead`). In the JS methods `this` always refers to the map-object. If needed, you can also use the `LeafletWidget` object from R-leaflet and the `L` object by leaflet itself.

5. Add an **example** in `./inst/examples/`. I use this directory to demonstrate/test the plugins in **ShinyApps**. Non-interactive examples go straight in the documentation of the function.

6. Add a **test** in `./tests/testthat/` or use this function `usethis::use_test("arrowhead")`

7. **Check** the package and run `devtools::test_coverage()` and try to test all R-code lines. ✅
You can also check the coverage of just one file with `devtools::test_coverage_file(paste0(getwd(),"/tests/testthat/test-arrowhead.R"))`. You may have to load some libraries manually before that.

8. Add the new plugin in the **README.md** with a link to the github repo.

8. Add a short description in the **NEWS.md** file that this plugin is now available.

9. Add the plugin in the `_pkgdown.yml` file and make sure it matches all functions.

10. If everything works correctly, push it to your fork and **open a PR**. I will be happy to merge it as soon as possible! 💚
🤷 If you're stuck somewhere in the process and you just can't get it to work, you can still open a PR and explain what the problem is. I will look into it.

11. 🎉 Celebrate and use it 🏆


62 changes: 58 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,100 @@

S3method("[",leaflet_mapkey_icon_set)
export(addAntpath)
export(addArrowhead)
export(addBuildings)
export(addContextmenu)
export(addEasyprint)
export(addGIBS)
export(addHeightgraph)
export(addHexbin)
export(addHistory)
export(addItemContextmenu)
export(addLabelgun)
export(addLatLngMoving)
export(addLeafletsync)
export(addLeafletsyncDependency)
export(addMapkeyMarkers)
export(addMovingMarker)
export(addOpenweatherCurrent)
export(addOpenweatherTiles)
export(addPlayback)
export(addReachability)
export(addSidebar)
export(addSidebyside)
export(addSpinner)
export(addStationMoving)
export(addTangram)
export(addTimeslider)
export(addVelocity)
export(addWMS)
export(antpathOptions)
export(arrowheadOptions)
export(clearAntpath)
export(clearArrowhead)
export(clearFuture)
export(clearHexbin)
export(clearHistory)
export(closeSidebar)
export(context_mapmenuItems)
export(context_markermenuItems)
export(context_menuItem)
export(disableContextmenu)
export(easyprintMap)
export(easyprintOptions)
export(enableContextmenu)
export(goBackHistory)
export(goForwardHistory)
export(heightgraphOptions)
export(hexbinOptions)
export(hideContextmenu)
export(hideHexbin)
export(historyOptions)
export(insertItemContextmenu)
export(isSynced)
export(leafletsyncOptions)
export(makeMapkeyIcon)
export(mapkeyIconList)
export(mapkeyIcons)
export(mapmenuItems)
export(markermenuItems)
export(menuItem)
export(moveToMoving)
export(movingMarkerOptions)
export(openSidebar)
export(openweatherCurrentOptions)
export(openweatherOptions)
export(pauseMoving)
export(playbackOptions)
export(reachabilityOptions)
export(removeAntpath)
export(removeArrowhead)
export(removeEasyprint)
export(removeItemContextmenu)
export(removePlayback)
export(removeReachability)
export(removeSidebar)
export(removeSidebyside)
export(removeTimeslider)
export(removeVelocity)
export(removeallItemsContextmenu)
export(resumeMoving)
export(setBuildingData)
export(setBuildingStyle)
export(setDate)
export(setDisabledContextmenu)
export(setOptionsVelocity)
export(setTransparent)
export(showContextmenu)
export(showHexbin)
export(sidebar_pane)
export(sidebar_tabs)
export(startMoving)
export(startSpinner)
export(stopMoving)
export(stopSpinner)
export(timesliderOptions)
export(unsync)
export(updateBuildingTime)
export(updateHexbin)
export(velocityOptions)
Expand All @@ -49,8 +104,7 @@ importFrom(htmltools,htmlDependency)
importFrom(htmltools,tagGetAttribute)
importFrom(htmltools,tagList)
importFrom(htmltools,tags)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,read_json)
importFrom(jsonlite,toJSON)
importFrom(magrittr,"%>%")
importFrom(shiny,addResourcePath)
importFrom(utils,adist)
importFrom(utils,globalVariables)
importFrom(utils,packageVersion)
Loading

0 comments on commit 89907e3

Please sign in to comment.