Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editAttributes() with no arguments causing error #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export(editFeatures)
export(editMap)
export(editMod)
export(editModUI)
export(mapeditAddin)
export(selectFeatures)
export(selectMap)
export(selectMod)
Expand All @@ -33,17 +32,7 @@ importFrom(DT,datatable)
importFrom(DT,editData)
importFrom(DT,renderDataTable)
importFrom(DT,replaceData)
importFrom(leaflet,setView)
importFrom(mapview,mapview)
importFrom(miniUI,gadgetTitleBar)
importFrom(miniUI,miniButtonBlock)
importFrom(miniUI,miniContentPanel)
importFrom(miniUI,miniPage)
importFrom(rstudioapi,getActiveDocumentContext)
importFrom(sf,write_sf)
importFrom(shinyWidgets,actionBttn)
importFrom(shinyWidgets,show_alert)
importFrom(shinyWidgets,switchInput)
importFrom(shinyWidgets,updateSwitchInput)
importFrom(shinyWidgets,useSweetAlert)
importFrom(tmaptools,geocode_OSM)
11 changes: 11 additions & 0 deletions R/editAttributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@
#' }
editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, provider = 'Esri.WorldImagery', testing = FALSE){

DEFAULT_ZOOM <- 'africa'
MSG <- 'When neither sf object nor zoomto is default, map will zoom to Africa'

#create base df if dat missing
if (missing(dat)) {
dat <- data.frame(id = 'CHANGE ME', comments = 'ADD COMMENTS...') %>% mutate(leaf_id = 1)
if (is.null(zoomto)) {
message(MSG)
zoomto <- DEFAULT_ZOOM
}
}

APP_CRS <- 4326
Expand All @@ -105,6 +111,11 @@ editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, pro
user_crs <- APP_CRS
le = TRUE

if (is.null(zoomto)) {
message(MSG)
zoomto <- DEFAULT_ZOOM
}

} else if (any(type %in% class(dat))) {

dat <- dat %>% mutate(leaf_id = 1:nrow(dat)) %>% sf::st_transform(APP_CRS)
Expand Down