forked from mikemenart/metrohack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
58 lines (43 loc) · 1.3 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
library(shiny)
library(ggmap)
library(ggplot2)
#load feature functions
getCHM <- dget("../chm.R")
#loadBirdData <- dget("../loadBirdData.R")
source("../loadBirdData.R")
lat <- c(41.54, 41.5495)
long <- c(-81.645, -81.62)
region <- make_bbox(long,lat,f=0.05)
myMapType <- "terrain"
map <- get_map(location=region, source="google", maptype=myMapType)
getOverlay <- function(feature, file){
overlay <- NULL
if(feature() == 2){
chm <- getCHM(file())
}
return(overlay)
}
plotBirds <- function(time, file){
if(is.null(file)){
return(NULL)
}
bird_data <- loadBirdData(file$datapath)
coords <- getCoords(bird_data)
#Reformat in some way, this currently does nothing
for(vp in coords$viewpoint){ #[v]iew [p]oint
vp_data <- bird_data[bird_data$PointID == vp, ]
}
#browser()
#adding color=CommonName pushes map of plot
bird_plot <- geom_point(data = bird_data, aes(Longitude, Latitude), size=2, alpha=0.7) # + labs(color = "Common Name"))
return(bird_plot)
}
##########Server Function#########
function(input, output) {
lidar_file <- reactive({input$lidar})
bird_file <- reactive({input$birds})
feature <- reactive({input$feature})
output$map <- renderPlot({
ggmap(map) + plotBirds(input$time, input$birds) + getOverlay(feature, lidar_file)
})
}