diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml deleted file mode 100644 index 2bb5ef0..0000000 --- a/.github/workflows/test-coverage.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# 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 }} - ALA_EMAIL: ${{ secrets.ALA_EMAIL }} - - 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(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "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 diff --git a/DESCRIPTION b/DESCRIPTION index 9bac449..25fa8f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: infinitylists Title: A Shiny-Based Application for Generating Place-Based Species Lists for Australian Plants -Version: 0.0.1 +Version: 1.0.0 Authors@R: c( person(given = "Thomas", family = "Mesaglio", role = c("aut", "cre", "cph"), email = "thomasmesaglio@gmail.com", comment = c(ORCID = "0000-0002-1096-6066")), diff --git a/R/global.R b/R/global.R index 6e5d651..68dd419 100644 --- a/R/global.R +++ b/R/global.R @@ -67,6 +67,7 @@ load_place <- function(path) { #' @return Circular polygon geometry. #' @noRd create_circle_polygon <- function(lat, long, radius_m) { + # Create a point in a geographical coordinate system (WGS 84) pt <- sf::st_point(c(long, lat)) pt <- sf::st_sfc(pt, crs = 4326) # Assign WGS 84 CRS diff --git a/R/infinitylists-package.R b/R/infinitylists-package.R index 8b3f3ee..4f579b0 100644 --- a/R/infinitylists-package.R +++ b/R/infinitylists-package.R @@ -60,6 +60,7 @@ utils::globalVariables( "write.csv", "Link", "Repository", - "Establishment means" + "Establishment means", + "repository" ) ) \ No newline at end of file diff --git a/R/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf b/R/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf new file mode 100644 index 0000000..6aec51c --- /dev/null +++ b/R/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf @@ -0,0 +1,12 @@ +name: infinitylists-current-location +title: infinitylists-current-location +username: fontikar +account: fontikar +server: shinyapps.io +hostUrl: https://api.shinyapps.io/v1 +appId: 12113944 +bundleId: 8692331 +url: https://unsw.shinyapps.io/infinitylists-current-location/ +version: 1 +asMultiple: FALSE +asStatic: FALSE diff --git a/R/server.R b/R/server.R index ddbc6a0..d9bcd32 100644 --- a/R/server.R +++ b/R/server.R @@ -38,13 +38,32 @@ #' infinity_server <- function(...) { server <- function(input, output, session) { + + # Render coordinates text + output$lat <- renderText({ + input$geolat + }) + + output$long <- renderText({ + input$geolong + }) + + output$accuracy <- renderText({ + input$accuracy + }) + + output$geolocation <- renderText({ + input$geolocation + }) + + # Observer to handle uploaded KML files uploaded_place <- eventReactive(input$uploadKML, { load_place(input$uploadKML$datapath) }) - circle_polygon <- eventReactive(input$executeButton, { + circle_polygon_choose <- eventReactive(input$executeButton, { lat <- tryCatch( as.numeric(input$latitude), error = function(e) @@ -71,6 +90,33 @@ infinity_server <- function(...) { }) + circle_polygon_geo <-eventReactive(input$executeButton, { + lat <- tryCatch( + as.numeric(input$geolat), + error = function(e) + NA + ) + long <- + tryCatch( + as.numeric(input$geolong), + error = function(e) + NA + ) + radius_m <- + tryCatch( + as.numeric(input$radiusChoice), + error = function(e) + NA + ) + + if (is.na(lat) || is.na(long) || is.na(radius_m)) { + return(NULL) + } + + return(create_circle_polygon(lat, long, radius_m)) + }) + + selected_polygon <- reactive({ switch( input$inputType, @@ -79,7 +125,11 @@ infinity_server <- function(...) { }, "choose" = { - return(circle_polygon()) + return(circle_polygon_choose()) + }, + + "current" = { + return(circle_polygon_geo()) }, "upload" = { diff --git a/R/ui.R b/R/ui.R index 1411045..ecd5506 100644 --- a/R/ui.R +++ b/R/ui.R @@ -5,9 +5,7 @@ # ---------------------- # Define the user interface for the Shiny app ui <- function(){ - - files_in_directory <- list.files(path = system.file(package = "infinitylists", "data/"), pattern = ".parquet") taxa_names <- @@ -40,6 +38,7 @@ ui <- function(){ choices = list( "Preloaded Place" = "preloaded", "Upload KML" = "upload", + "Use current location" = "current", "Choose a lat/long" = "choose" ), selected = "preloaded", @@ -55,6 +54,7 @@ ui <- function(){ selected = "Fowlers Gap, UNSW" ) ), + conditionalPanel( condition = "input.inputType == 'upload'", fileInput( @@ -62,19 +62,72 @@ ui <- function(){ "Upload your own KML", accept = c(".kml") )), + + conditionalPanel( + condition = "input.inputType == 'current'", + + # Get Geolocation + tags$script(' + $(document).ready(function () { + + var options = { + enableHighAccuracy: true, + timeout: 5000, + maximumAge: 0 + }; + + navigator.geolocation.getCurrentPosition(onSuccess, onError); + + function onError (err) { + Shiny.onInputChange("geolocation", false); + } + + function onSuccess (position) { + setTimeout(function () { + var coords = position.coords; + console.log(coords.latitude + ", " + coords.longitude, "," + coords.accuracy); + Shiny.onInputChange("geolocation", true); + Shiny.onInputChange("geolat", coords.latitude); + Shiny.onInputChange("geolong", coords.longitude); + Shiny.onInputChange("accuracy", coords.accuracy); + }, 1100) + } + }); + + +'), + selectInput( + inputId = "radiusChoice", + label = "Choose a radius:", + choices = c( + "100m" = 100, + "500m" = 500, + "1km" = 1000, + "2km" = 2000, + "5km" = 5000, + "10km" = 10000, + "50km" = 50000 + ), + selected = 100 + ), + + actionButton("executeButton", "Go") + ), + + conditionalPanel( condition = "input.inputType == 'choose'", numericInput( "latitude", "Latitude", - value = -33.8688, + value = -34.1182, min = -90, max = 90, step = 0.00001), numericInput( "longitude", "Longitude", - value = 148.2093, + value = 151.0636, min = -180, max = 180, step = 0.00001 @@ -91,7 +144,7 @@ ui <- function(){ "10km" = 10000, "50km" = 50000 ), - selected = 5000 + selected = 100 ), actionButton("executeButton", "Go") ), @@ -200,7 +253,7 @@ ui <- function(){ tags$li("Records considered to have spatial issues by ALA") ), p("More information can be found on these ", tags$a("here", href = "https://support.ala.org.au/support/solutions/articles/6000240256-getting-started-with-the-data-quality-filters")), - + h4("13. Does the app reveal the location of species with sensitive locations?"), p("Species with sensitive locations are not included in our app. Any species for which records have their locality data obscured or generalised (whether by the original data provider, or by the ALA itself) are excluded from the app."), @@ -216,7 +269,13 @@ ui <- function(){ h4("17. Why is the app called 'An Infinity of Lists'?"), p("The app's name is a reference to the book ", tags$a(href = "https://en.wikipedia.org/wiki/The_Infinity_of_Lists", 'The Infinity of Lists'), " by Italian author Umberto Eco."), - ) + ), + tabPanel("Coords", + + h5("Latitude:"), verbatimTextOutput("lat"), + h5("Longitude:"), verbatimTextOutput("long"), + h5("Accuracy (m):"), verbatimTextOutput("accuracy") + ), ) ) ), diff --git a/README.Rmd b/README.Rmd index f856d50..75ce8ba 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,6 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/traitecoevo/infinitylists/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/traitecoevo/infinitylists/actions/workflows/R-CMD-check.yaml) -[![Codecov test coverage](https://codecov.io/gh/traitecoevo/infinitylists/branch/master/graph/badge.svg)](https://app.codecov.io/gh/traitecoevo/infinitylists?branch=master) This shiny-based application allows users to extract plant occurrence data from the Atlas of Living Australia (ALA) and generate a species list for any defined area. All records associated with either a physical voucher (stored in Australian herbaria or museum), a sound file, or a photographic voucher (stored in iNaturalist) are extracted. For each species within the defined area, the application will return voucher type, number of vouchers, date of the most recent voucher, spatial coordinates, voucher location, and the voucher collector. Records are displayed both in a table and on a map, and are downloadable as a CSV. diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 04c5585..0000000 --- a/codecov.yml +++ /dev/null @@ -1,14 +0,0 @@ -comment: false - -coverage: - status: - project: - default: - target: auto - threshold: 1% - informational: true - patch: - default: - target: auto - threshold: 1% - informational: true diff --git a/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf b/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf new file mode 100644 index 0000000..98846f3 --- /dev/null +++ b/rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf @@ -0,0 +1,10 @@ +name: infinitylists-current-location +title: +username: fontikar +account: fontikar +server: shinyapps.io +hostUrl: https://api.shinyapps.io/v1 +appId: 12113944 +bundleId: 8731055 +url: https://unsw.shinyapps.io/infinitylists-current-location/ +version: 1