Skip to content

Commit

Permalink
Release of "Use of Current Location" (#94)
Browse files Browse the repository at this point in the history
* Can retrieve current location

* Enabled high accuracy

* Default to 100m radius

* Bumped version number

* Removed codecoverage
  • Loading branch information
fontikar authored Jul 1, 2024
1 parent fd44581 commit c02ee06
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 77 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/test-coverage.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", comment = c(ORCID = "0000-0002-1096-6066")),
Expand Down
1 change: 1 addition & 0 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion R/infinitylists-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ utils::globalVariables(
"write.csv",
"Link",
"Repository",
"Establishment means"
"Establishment means",
"repository"
)
)
Original file line number Diff line number Diff line change
@@ -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
54 changes: 52 additions & 2 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -79,7 +125,11 @@ infinity_server <- function(...) {
},

"choose" = {
return(circle_polygon())
return(circle_polygon_choose())
},

"current" = {
return(circle_polygon_geo())
},

"upload" = {
Expand Down
73 changes: 66 additions & 7 deletions R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <-
Expand Down Expand Up @@ -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",
Expand All @@ -55,26 +54,80 @@ ui <- function(){
selected = "Fowlers Gap, UNSW"
)
),

conditionalPanel(
condition = "input.inputType == 'upload'",
fileInput(
"uploadKML",
"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
Expand All @@ -91,7 +144,7 @@ ui <- function(){
"10km" = 10000,
"50km" = 50000
),
selected = 5000
selected = 100
),
actionButton("executeButton", "Go")
),
Expand Down Expand Up @@ -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."),
Expand All @@ -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")
),
)
)
),
Expand Down
1 change: 0 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ knitr::opts_chunk$set(

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

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.
Expand Down
14 changes: 0 additions & 14 deletions codecov.yml

This file was deleted.

10 changes: 10 additions & 0 deletions rsconnect/shinyapps.io/fontikar/infinitylists-current-location.dcf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c02ee06

Please sign in to comment.