Skip to content
Snippets Groups Projects
Commit 9b62365c authored by lq39quba's avatar lq39quba
Browse files

implement irregular timesteps

parent d3793294
No related branches found
No related tags found
No related merge requests found
......@@ -98,14 +98,14 @@ ui <- fluidPage(
column(6,
textInput('project_name', tags$span(style="font-size: 18px; font-weight: bold", 'Project Name'), width='80%',
value = 'TERRANOVA - The European Landscape Learning Initiative',
placeholder='The name(s) of the Project principally responsible for originating this data. Several values should be seperated by comma.'),
placeholder='The name(s) of the Project principally responsible for originating this data. Several values should be separated by comma.'),
#span(textOutput("title_desc"), style="font-size:14px")
),
#project url
column(6,
textInput('project_url', tags$span(style="font-size: 18px; font-weight: bold", 'Project URL'), width='80%',
value = "https://www.terranova-itn.eu",
placeholder='The URL from the project(s) website. Several values should be seperated by comma.')
placeholder='The URL from the project(s) website. Several values should be separated by comma.')
)
),
......@@ -291,12 +291,16 @@ ui <- fluidPage(
"weekly" = "P0000-00-07",
"daily" = "P0000-00-01",
'one timestep' = "P0000-00-00",
"irregular" = "Irregular",
"other" = "other"),
width='80%'),
#other temporal resolution
uiOutput('temporal_resoultion_other'),
#irregular temporal resolution
uiOutput('temporal_resoultion_irregular'),
#temporal extent
uiOutput('temporal_extent'),
......@@ -546,6 +550,15 @@ server <- function(input, output) {
return(list(t,s))
}
})
output$temporal_resoultion_irregular <- renderUI({
if(input$temporal_resolution=='Irregular'){
t <- renderText('Provide the definition of your timesteps as a comma-separated list in the format YYYY-MM-DD or short YYYY.')
s <- textInput('temp_res_irr', '', width='80%', placeholder='YYYY, YYYY, ...')
return(list(t,s))
}
})
#check variables
to_do_list <- c()
......@@ -553,43 +566,45 @@ server <- function(input, output) {
#temporal extent----
output$temporal_extent <- renderUI({
if(input$temporal_resolution=='other'){
#user defined temporal resolution
if(grepl('^P{1}\\d{4}-00-00', input$temp_res_txt)){
if(input$temporal_resolution!='Irregular'){
if(input$temporal_resolution=='other'){
#user defined temporal resolution
if(grepl('^P{1}\\d{4}-00-00', input$temp_res_txt)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "yyyy")
} else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temp_res_txt)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "mm-yyyy")
} else if (grepl('^P{1}\\d{4}-\\d{2}-\\d{2}$', input$temp_res_txt)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "dd-mm-yyyy")
}else{
create <- FALSE
to_do_list <- c(to_do_list, 'Your temporal resolution does not match the ISO duration format.')
}
}else if(input$temporal_resolution=='P0000-00-00'){
#one timestep only
dateInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Date of the dataset*'), width='80%',
startview ='year')
}else if(grepl('^P{1}\\d{4}-00-00$', input$temporal_resolution)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "yyyy")
} else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temp_res_txt)){
} else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temporal_resolution)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "mm-yyyy")
} else if (grepl('^P{1}\\d{4}-\\d{2}-\\d{2}$', input$temp_res_txt)){
} else {
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "dd-mm-yyyy")
}else{
create <- FALSE
to_do_list <- c(to_do_list, 'Your temporal resolution does not match the ISO duration format.')
}
}else if(input$temporal_resolution=='P0000-00-00'){
#one timestep only
dateInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Date of the dataset*'), width='80%',
startview ='year')
}else if(grepl('^P{1}\\d{4}-00-00$', input$temporal_resolution)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "yyyy")
} else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temporal_resolution)){
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "mm-yyyy")
} else {
dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold",
'Start and end date of the dataset*'),
format = "dd-mm-yyyy")
}
})
......@@ -893,14 +908,41 @@ server <- function(input, output) {
}
}
#check the input of the irregulare timesteps
if(input$temporal_resolution=='Irregular'){
timestep_list <- stringr::str_split(input$temp_res_irr, ',')[[1]]
ts_irr_wrong <- FALSE
for(ts in timestep_list){
if(grepl('^\\d{4}-\\d{2}-\\d{2}$', ts) | grepl('^\\d{4}$', ts)){
#pass
}else{
ts_irr_wrong <- TRUE
}
}
if(ts_irr_wrong){
to_do_list <- c(to_do_list, 'You chose "Irregular" temporal resolution and the input you provided does not match the required form: comma-separated YYYY-MM-DD or comma-separated YYYY. Please check.')
create <- FALSE
}
}
#temporal extent
if(input$temporal_resolution=='P0000-00-00'){
if(input$temporal_resolution=='Irregular'){
timestep_list <- stringr::str_split(input$temp_res_irr, ',')[[1]]
ts_last <- length(timestep_list)
t_start <- timestep_list[1]
t_end <- timestep_list[ts_last]#last
timesteps_irr <- paste0('"', paste0(timestep_list, collapse = '", "'), '"')
}else if(input$temporal_resolution=='P0000-00-00'){
t_start <-input$temporal_extent_input
t_end <- input$temporal_extent_input
}else{
t_start <- input$temporal_extent_input[1]
t_end <- input$temporal_extent_input[2]
}
if(input$temporal_resolution!='Irregular'){
timesteps_irr <- '"N/A"'
}
#check terranova type
......@@ -1015,6 +1057,7 @@ server <- function(input, output) {
"ebv_domain": [\n\t\t\t\t"', paste0(ebv_domain_value, collapse = '",\n\t\t\t\t"'),'"\n\t\t\t],
"comment": "',comment,'",
"terranova_type": "', input$terranova_type,'"
"timesteps": [\n\t\t\t\t', timesteps_irr, '\n\t\t\t]
}
]
}')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment