@@ -8,19 +8,15 @@ library(lubridate)
88library(rgdal )
99library(data.table )
1010
11- # #################
12- # prepare objects#
13- # #################
14-
15- psts <- NULL
16-
17- # max numbers of points to render by leaflet in the interactive map
18- max.n.points <- 50000
11+ # ################
12+ # prepare objects#
13+ # ################
1914
2015# prepare color ramp
2116colramp <- rev(matlab.like(10 ))
2217
23- # init stamps object
18+ # initialize empty objects
19+ psts <- NULL
2420stamps <- NULL
2521
2622# ###################
@@ -101,6 +97,41 @@ render.stamps <- function(pointsize = 5, setview = TRUE){
10197
10298function (input , output , session ) {
10399
100+ # # Settings ##################################################
101+ # render start settings texts
102+ output $ text.settings <- if (settings $ defaultflag == TRUE ){
103+ renderText({paste(" Values were initially loaded from default settings" )})}else {
104+ renderText({paste(" Values were initially loaded from user settings" )})}
105+
106+ output $ text.max.n.points <- if (settings $ defaultflag == TRUE ){
107+ renderText({paste(" Values are set to default: " , settings $ max.n.points , sep = " " )})}else {
108+ renderText({paste(" Value is set by user: " , settings $ max.n.points , sep = " " )})}
109+
110+ # load default settings
111+ observeEvent(input $ load.def.settings , {
112+ settings <<- list (default = settings $ default ,
113+ max.n.points = settings $ default $ max.n.points ,
114+ defaultflag = settings $ default $ defaultflag )
115+ output $ text.max.n.points <- renderText({paste(" Values are set to default: " , settings $ max.n.points , sep = " " )})
116+ saveRDS(settings , " settings.RData" )
117+ output $ text.settings <- renderText({paste(" Values were loaded from default settings" )})
118+ })
119+
120+ # change max.n.points
121+ # change for current session
122+ observeEvent(input $ set.max.n.points , {
123+ settings $ max.n.points <<- input $ select.max.n.points
124+ settings $ defaultflag <<- FALSE
125+ output $ text.max.n.points <- renderText({paste(" Value is set by user: " , settings $ max.n.points , sep = " " )})
126+ })
127+ # change for current session and save to user settings session
128+ observeEvent(input $ save.max.n.points , {
129+ settings $ max.n.points <<- input $ select.max.n.points
130+ settings $ defaultflag <<- FALSE
131+ output $ text.max.n.points <- renderText({paste(" Value is set by user: " , settings $ max.n.points , sep = " " )})
132+ saveRDS(settings , " settings.RData" )
133+ })
134+
104135# # Interactive Map ###########################################
105136 output $ stusi <- renderUI({
106137 lapply(1 , function (x ) {
@@ -151,22 +182,21 @@ function(input, output, session) {
151182 }else {
152183 # check the numbers of lines
153184 n.points <- nrow(data.table :: fread(paste(" input/stusi/" , input $ stusi , " .csv" , sep = " " ), select = 1L ))
154- if (n.points < = max.n.points ){
185+ if (n.points < = settings $ max.n.points ){
155186 stamps <<- load.stamps(input $ stusi )
156187 render.stamps(pointsize = input $ pcex )
157188 }else {
158189 shinyalert(title = " Number of max points exceeded" ,
159190 text = paste(" You try to load " , n.points , " points where the max number of points is " ,
160- max.n.points , " . Continue to load all points might slow down and eventually crush the Visualizer. " ,
161- " Cancel to make a spatial subset or raise the number of maximum points. " ,
162- " For further instructions switch to the Manual tab." ,
191+ settings $ max.n.points , " . To raise the number of maximum points, go to Settings." ,
163192 sep = " " ),
164- type = " input" ,
165- inputType = " " ,
166- showCancelButton = TRUE ,
167- showConfirmButton = TRUE ,
168- confirmButtonText = " Continue" ,
169- inputId = " ex.max.n.point" )
193+ type = " error"
194+ # inputType = "",
195+ # showCancelButton = TRUE,
196+ # showConfirmButton = TRUE,
197+ # confirmButtonText = "Continue",
198+ # inputId = "ex.max.n.point"
199+ )
170200 output $ stusi <- renderUI({
171201 lapply(1 , function (x ) {
172202 selectInput(" stusi" , " Select case study" , stusi ,
0 commit comments