Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
Rscript -e 'shinylive::export(appdir = ".", destdir = "docs")'
<<<<<<< HEAD
touch docs/.nojekyll
=======
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
89 changes: 89 additions & 0 deletions src/server.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
library(shiny)

<<<<<<< HEAD
fetchDB <- function(input) {
north_lat <- input$map_background$north
south_lat <- input$map_background$south
leafletProxy("map_background") %>% clearMarkers() %>% clearShapes()

df <- data.frame(c(input$map_background_bounds$west, input$map_background_bounds$east), c(input$map_background_bounds$north, input$map_background_bounds$south))
colnames(df) <- c("X", "Y")

data_sf_orig <- st_as_sf(
df,
coords = c("X", "Y"),
crs = 4326
)

data_sf_3035 <- st_transform(data_sf_orig, 3035)

coords_3035 <- st_coordinates(data_sf_3035)
x_min <- min(coords_3035[, 1])
x_max <- max(coords_3035[, 1])
y_min <- min(coords_3035[, 2])
y_max <- max(coords_3035[, 2])

res <- dbSendQuery(conn, sprintf("SELECT * FROM equipment_access WHERE \"X\" >= %.0f AND \"X\" <= %.0f AND \"Y\" >= %.0f AND \"Y\" <= %.0f LIMIT 10000", x_min, x_max, y_min, y_max))
f <- dbFetch(res)

if (nrow(f) == 0){
print("No squared referenced in this area")
return ()
}

data_sf_4326 <- dbCoordsToLeaflet(f)


for (elt2 in seq_len(nrow(data_sf_4326))){
elt <- data_sf_4326[elt2, ]

#leafletProxy("map_background") %>% addMarkers(
#lng = st_coordinates(elt)[,1],
#lat = st_coordinates(elt)[,2],
#label = elt$Label
#)
bottomRightPoint <- destPoint(st_coordinates(elt)[1,], 135, sqrt(2)*100)
topLeftPoint <- destPoint(st_coordinates(elt)[1,], 315, sqrt(2)*100)
leafletProxy("map_background") %>% addRectangles(
lng1=topLeftPoint[1],
lat1=topLeftPoint[2],
lng2=bottomRightPoint[1],
lat2=bottomRightPoint[2],
color="green"
)

}

}


dbCoordsToLeaflet <- function(df){
data_df_orig <- data.frame(
X = df$X,
Y = df$Y,
Label = df$pop
=======
server <- function(input, output) {

res <- dbSendQuery(conn, "SELECT * FROM equipment_access LIMIT 100000")
Expand All @@ -16,6 +79,7 @@ server <- function(input, output) {
X = f$X,
Y = f$Y,
Label = f$pop
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2
) %>% distinct()

data_sf_orig <- st_as_sf(
Expand All @@ -26,6 +90,27 @@ server <- function(input, output) {

data_sf_4326 <- st_transform(data_sf_orig, 4326)

<<<<<<< HEAD
return (data_sf_4326)

}

server <- function(input, output) {

res <- dbSendQuery(conn, "SELECT * FROM equipment_access LIMIT 10")
f <- dbFetch(res)

leaf <- leaflet() %>%
addTiles()

observeEvent(input$map_background_bounds, {
fetchDB(input)
})

data_sf_4326 <- dbCoordsToLeaflet(f)

=======
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2
for (elt2 in seq_len(nrow(data_sf_4326))){
elt <- data_sf_4326[elt2, ]

Expand All @@ -49,7 +134,11 @@ server <- function(input, output) {
}


<<<<<<< HEAD
print("Server update done!")
=======
print("DONE")
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2


output$map_background <- renderLeaflet({leaf})
Expand Down