diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74316be..02c236a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/src/server.R b/src/server.R index d91fca2..0a81966 100644 --- a/src/server.R +++ b/src/server.R @@ -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") @@ -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( @@ -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, ] @@ -49,7 +134,11 @@ server <- function(input, output) { } +<<<<<<< HEAD + print("Server update done!") +======= print("DONE") +>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2 output$map_background <- renderLeaflet({leaf})