Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
citizenair
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vmm
citizenair
Commits
b9d6c8d0
Commit
b9d6c8d0
authored
Nov 07, 2018
by
Jan Wijffels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the S4 classes in the app
parent
6359503b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
citizenair/inst/apps/citizenair/citizenair.Rmd
+5
-14
citizenair/inst/apps/citizenair/page01-introduction.Rmd
+5
-1
No files found.
citizenair/inst/apps/citizenair/citizenair.Rmd
View file @
b9d6c8d0
...
...
@@ -26,21 +26,12 @@ library(sp)
data("BE_ADMIN_REGION")
dashinput <- list()
dashinput$user_file <- system.file(package = "citizenair", "data-raw", "test_dummy.xls")
dashinput$stationinfo <- content(GET("http://geo.irceline.be/sos/api/v1/stations?expanded=true"))
dashinput$meetstations <- lapply(dashinput$stationinfo, FUN=function(x){
data.frame(id = x$properties$id,
label = x$properties$label,
phenomena = sort(unique(sapply(x$properties$timeseries, FUN=function(x) x$phenomenon$label))), stringsAsFactors = FALSE)
})
dashinput$meetstations <- rbindlist(dashinput$meetstations)
dashinput$region <- subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest")
dashinput$endpoint <- as.Endpoint("http://sosrest.irceline.be/api/v1")
dashinput$endpoint <- as.Endpoint("http://geo.irceline.be/sos/api/v1")
dashinput$srv <- fetch(services(dashinput$endpoint))
dashinput$stations <- stations(dashinput$endpoint, service = dashinput$srv)
dashinput$stations_sp <- as.SpatialPointsDataFrame(dashinput$stations)
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp), FUN=function(idx) gIntersects(dashinput$region, dashinput$stations_sp[idx, ])), ]
dashinput$ca <- new("CitizenAir", endpoint = dashinput$endpoint)
dashinput$region <- subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest")
dashinput$stations_sp <- as_sp(dashinput$ca@stations)
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp),
FUN=function(idx) gIntersects(dashinput$region, dashinput$stations_sp[idx, ])), ]
```
...
...
citizenair/inst/apps/citizenair/page01-introduction.Rmd
View file @
b9d6c8d0
...
...
@@ -89,7 +89,11 @@ output$uiOutput_stations <- renderLeaflet({
map <- leaflet(data = dashinput$region)
map <- addTiles(map)
map <- addPolygons(map, weight = 3, fillOpacity = 0)
map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3, popup = as.character(stations$label))
map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3,
popup = as.character(mapply(label = stations$label, phenomena = stations$phenomena_label,
FUN=function(label, phenomena){
sprintf("<b>Station: %s</b> <br>Meetwaardes:<br> %s", label, paste(sprintf(" - %s ", phenomena), collapse = "<br>"))
})))
if(length(userdata$nearest_station) > 0){
stations <- subset(stations, id %in% userdata$nearest_station)
map <- addPopups(map, data = stations, popup = "Dichtstbijzijnd gevalideerd meetstation")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment