Commit 056468c2 by Jan Wijffels

Comparison station as popup

parent a4a43a41
......@@ -176,6 +176,10 @@ CitizenAir <- R6::R6Class("CitizenAir",
data = x, proj4string = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
x
},
getStationLabel = function(id){
x <- self$stations$stations$label[self$stations$stations$id %in% id]
x
},
getStationsArea = function(){
private$stations_area
},
......
No preview for this file type
......@@ -28,21 +28,50 @@ library(dygraphs)
library(ggplot2)
library(openair)
data("BE_ADMIN_REGION", package = "BelgiumMaps.StatBel")
data("BE_ADMIN_BELGIUM", package = "BelgiumMaps.StatBel")
data("ca", package = "citizenair")
#ca <- CitizenAir$new(endpoint = as.Endpoint("http://geo.irceline.be/sos/api/v1"), stations_area = subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest"))
#ca <- CitizenAir$new(endpoint = as.Endpoint("http://geo.irceline.be/sos/api/v1"), stations_area = BE_ADMIN_BELGIUM)
#save(ca, file = "citizenair/data/ca.RData")
APPDATA <- ca
#APPDATA$setCitizenData(file = system.file(package = "citizenair", "data-raw", "citizenair-example.xls"))
#APPDATA$setComparisonStation(id = "1155")
APPDATA <- CitizenAir$new(endpoint = as.Endpoint("http://geo.irceline.be/sos/api/v1"),
stations_area = subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest"))
#APPDATA <- CitizenAir$new(endpoint = as.Endpoint("http://geo.irceline.be/sos/api/v1"),
# stations_area = subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest"))
APPDATA <- CitizenAir$new(endpoint = as.Endpoint("http://geo.irceline.be/sos/api/v1"), stations_area = BE_ADMIN_BELGIUM)
```
```{r}
plot_timeseries <- function(x, ...){
if(nrow(x) > 0){
x <- setDT(x)
x$ts_id <- paste(x$type, x$phenomena, sep = "-")
period_citizen <- x$time[x$type %in% "citizen"]
if(length(period_citizen) > 0){
#x <- subset(x, date >= (as.Date(min(period_citizen)) - 1) & date <= (as.Date(max(period_citizen)) + 1))
}
ts <- dcast.data.table(data = x, formula = time ~ ts_id, fun.aggregate = mean, na.rm=TRUE, value.var = "value")
ts <- setDF(ts)
g <- xts(ts[, -1], order.by=ts[,1])
g <- dygraph(g, ...)
g <- dyRangeSelector(g, height = 20)
g <- dyLegend(g, show = "always")
g
}else{
g <- NULL
}
g
}
```
```{r}
popups <- list()
popups$download <- modalDialog(title = "Download",
"We connecteren nu naar de IRCEL webservice om data af te halen en te combineren met uw meetgegevens, eventjes geduld, dit scherm sluit vanzelf wanneer dit afgelopen is.",
size = "s", footer = NULL, easyClose = FALSE)
popups$cleaned_data <- modalDialog(
title = "Uw meetgegevens",
h4("Uw heeft de volgende gegevens opgeladen:"),
......@@ -51,6 +80,33 @@ popups$cleaned_data <- modalDialog(
tags$hr(),
DT::dataTableOutput("uiOutput_rawdata", width = "100%", height = "auto"),
size = "l", footer = modalButton("Sluit"), easyClose = TRUE)
popups$select_station <- modalDialog(
title = "Selecteer met welk officieel station u uw meetgegevens wilt vergelijken",
tags$div(tags$blockquote("Op de kaart hieronder kunt u meetstations vinden van de Vlaamse Milieu Maatschappij die dezelfde elementen meten als uw metingen. Selecteer het meetstation waarmee u uw eigen gegevens wil vergelijken door te klikken op een meetstation. Wanneer u klaar bent, klik op Go!, waarna we de gegevens van de VMM webservice afhalen en combineren met uw gegevens.")),
renderUI(tags$h3("Uw selecteerde te vergelijken met: ", citizenair_vmmstation()$label)),
radioGroupButtons(
inputId = "uiInput_selectmeasurement",
label = "Selecteer welke van uw sensorgegevens u wilt vergelijken met een officieel meetstation",
choices = sort(APPDATA$getCitizenData(type = "phenomena"), decreasing = TRUE),
direction = "horizontal", size = "sm",
justified = FALSE, individual = FALSE, status = "primary",
checkIcon = list(yes = icon("ok", lib = "glyphicon"))
),
actionButton(inputId = "uiInput_downloadtimeseries",
label = "Go! Haal de meetgegevens af vanaf de VMM webservice en start de vergelijking",
"data-dismiss"="modal",
icon = icon("arrow-circle-down")),
tags$hr(),
leafletOutput("uiOutput_select_station", width = "100%", height = 300),
size = "l", footer = NULL, easyClose = FALSE)
citizenair_vmmstation <- reactive({
input$uiOutput_select_station_marker_click
id <- input$uiOutput_select_station_marker_click$id
list(id = id, label = APPDATA$getStationLabel(id))
})
## MAIN REACTIVE WHICH LOADS THE EXCEL FILE
citizenair_userdata <- reactive({
......@@ -76,6 +132,10 @@ citizenair_userdata <- reactive({
caption = 'Overzicht van alle meetgegevens per sheet/tijdstip/type meting',
filter = 'top', options = list(pageLength = 5, autoWidth = TRUE, searching = FALSE)))
showModal(popups$cleaned_data)
output$uiOutput_timeseries <- renderDygraph({
plot_timeseries(result$appdata$getCombinedTimeseries(), main = "De tijdreeks van al uw meetgegevens")
})
}
}
result
......@@ -96,3 +156,30 @@ reactive({
```{r child="page02-exploratory.Rmd", eval=TRUE}
```
# Hidden {.hidden}
## Main event
```{r}
## Main trigger for updating graphs
numericInput(inputId = 'uiInput_refresh_counter', label = "How many updates are done", value = 0)
```
## Debugging
```{r}
tags$h3("Input")
renderPrint({
names(input)
})
tags$h3("Output")
renderPrint({
names(output)
})
tags$h3("session")
renderPrint({
names(session)
})
```
......@@ -32,7 +32,7 @@ fileInput("uiInput_xl", label = "Selecteer het bestand met uw metingen: ", accep
#materialSwitch(inputId = "uiInput_addexcel", label = "Combineer excel met vorige excel", value = FALSE, status = "info")
```
### Meetstations van de Vlaamse Overheid {data-height=500}
### Meetstations van de overheid {data-height=500}
```{r}
leafletOutput("uiOutput_stations")
......@@ -52,7 +52,7 @@ output$uiOutput_stations <- renderLeaflet({
if(!is.na(userdata$nearest_station)){
stations <- subset(stations, id %in% userdata$nearest_station)
stations <- head(stations, 1)
map <- addPopups(map, data = stations, popup = sprintf("Dichtste meetstation<br>%s: %s", stations$id, stations$label))
map <- addPopups(map, data = stations, popup = sprintf("Dichtste officieel meetstation<br>%s: %s", stations$id, stations$label))
}
if(nrow(meta) > 0){
map <- addPopups(map, lng = meta$lon, lat = meta$lat, popup = sprintf("<b>Sheet %s: %s</b>", meta$sheet_id, meta$sheet))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment