@@ -4,11 +4,12 @@ library(scales)
44library(lattice )
55library(dplyr )
66library(hash )
7- library(rgdal )
7+ # library(rgdal)
88library(classInt )
99library(tidyr )
1010library(shinyStore )
1111library(stringi )
12+ library(sp )
1213source(" core.R" )
1314
1415# Leaflet bindings are a bit slow; for now we'll just sample to compensate
@@ -35,9 +36,11 @@ colmat.print <- function(nquantiles = 10, upperleft = rgb(0,150,235, maxColorVal
3536 my.pal.1 <- findColours(my.class ,c(upperleft ,bottomleft ))
3637 my.pal.2 <- findColours(my.class ,c(upperright , bottomright ))
3738 col.matrix <- matrix (nrow = 101 , ncol = 101 , NA )
39+ print(my.pal.1 [i ])
3840 for (i in 1 : 101 ){
3941 my.col <- c(paste(my.pal.1 [i ]),paste(my.pal.2 [i ]))
40- col.matrix [102 - i ,] <- findColours(my.class ,my.col )}
42+ col.matrix [102 - i ,] <- findColours(my.class ,my.col )
43+ }
4144 plot(c(1 ,1 ),pch = 19 ,col = my.pal.1 , cex = 0.5 ,xlim = c(0 ,1 ),ylim = c(0 ,1 ),frame.plot = F , xlab = xlab , ylab = ylab ,cex.lab = 1.3 )
4245 for (i in 1 : 101 ){
4346 col.temp <- col.matrix [i - 1 ,]
@@ -135,6 +138,8 @@ function(input, output, session) {
135138 newVal <- paste0(ele ," ---" ,eval(parse(text = paste0(" input$store$" ,ele ))))
136139 extraList = c(extraList , newVal )
137140 }
141+
142+ print(storeNames )
138143 sumData(joinTable ,extraList = extraList )
139144 }, ignoreNULL = FALSE )
140145
@@ -326,14 +331,19 @@ function(input, output, session) {
326331 z [is.na(z )] <- 0
327332 z [startsWith(z ," #" )] <- .75
328333
329- leafletProxy(" map" , data = dist ) %> % clearShapes() %> %
334+ # print(z)
335+ # print(unique(col.matrix)[x])
336+
337+ leafletProxy(" map" , data = st_zm(dist )) %> % clearShapes() %> %
330338 addPolygons(color = " #444444" , weight = 0.01 , smoothFactor = 1.0 ,
331339 opacity = .75 , fillOpacity = z ,
332340 fillColor = unique(col.matrix )[x ]
333341 # highlightOptions = highlightOptions(weight = 1,
334342 # color = "white",
335343 # bringToFront = TRUE)
344+
336345 )
346+
337347 })
338348
339349 # # Show a popup at the given location
@@ -344,9 +354,13 @@ function(input, output, session) {
344354 coords <- as.data.frame(cbind(lng , lat ))
345355 point <- SpatialPoints(coords )
346356 proj4string(point ) <- CRS(" +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" )
357+ point <- st_as_sf(point , coords = c(' y' , ' x' ), crs = st_crs(map ))
347358 findDistrictinDist <- dist [point ,]
359+
360+
348361 findDistrict <- block()[block()$ block == findDistrictinDist $ Block & block()$ district == findDistrictinDist $ District ,]
349-
362+
363+ print(findDistrict )
350364 popupTagList <- tagList(
351365 tags $ h4(" District" ,findDistrict $ district ," - Block" ,findDistrict $ block ),
352366 tags $ h4(" Total Residents: " ,findDistrict $ sum_household ),
0 commit comments