Skip to content

Commit dde8d92

Browse files
authored
Merge pull request #15 from mchlln/update
Update
2 parents 9cc55e9 + 342ab35 commit dde8d92

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
3737
run: |
3838
Rscript -e 'shinylive::export(appdir = ".", destdir = "docs")'
39+
<<<<<<< HEAD
40+
touch docs/.nojekyll
41+
=======
42+
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2
3943

4044
- name: Deploy to GitHub Pages
4145
uses: peaceiris/actions-gh-pages@v3

src/server.R

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
11
library(shiny)
22

3+
<<<<<<< HEAD
4+
fetchDB <- function(input) {
5+
north_lat <- input$map_background$north
6+
south_lat <- input$map_background$south
7+
leafletProxy("map_background") %>% clearMarkers() %>% clearShapes()
8+
9+
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))
10+
colnames(df) <- c("X", "Y")
11+
12+
data_sf_orig <- st_as_sf(
13+
df,
14+
coords = c("X", "Y"),
15+
crs = 4326
16+
)
17+
18+
data_sf_3035 <- st_transform(data_sf_orig, 3035)
19+
20+
coords_3035 <- st_coordinates(data_sf_3035)
21+
x_min <- min(coords_3035[, 1])
22+
x_max <- max(coords_3035[, 1])
23+
y_min <- min(coords_3035[, 2])
24+
y_max <- max(coords_3035[, 2])
25+
26+
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))
27+
f <- dbFetch(res)
28+
29+
if (nrow(f) == 0){
30+
print("No squared referenced in this area")
31+
return ()
32+
}
33+
34+
data_sf_4326 <- dbCoordsToLeaflet(f)
35+
36+
37+
for (elt2 in seq_len(nrow(data_sf_4326))){
38+
elt <- data_sf_4326[elt2, ]
39+
40+
#leafletProxy("map_background") %>% addMarkers(
41+
#lng = st_coordinates(elt)[,1],
42+
#lat = st_coordinates(elt)[,2],
43+
#label = elt$Label
44+
#)
45+
bottomRightPoint <- destPoint(st_coordinates(elt)[1,], 135, sqrt(2)*100)
46+
topLeftPoint <- destPoint(st_coordinates(elt)[1,], 315, sqrt(2)*100)
47+
leafletProxy("map_background") %>% addRectangles(
48+
lng1=topLeftPoint[1],
49+
lat1=topLeftPoint[2],
50+
lng2=bottomRightPoint[1],
51+
lat2=bottomRightPoint[2],
52+
color="green"
53+
)
54+
55+
}
56+
57+
}
58+
59+
60+
dbCoordsToLeaflet <- function(df){
61+
data_df_orig <- data.frame(
62+
X = df$X,
63+
Y = df$Y,
64+
Label = df$pop
65+
=======
366
server <- function(input, output) {
467

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

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

2791
data_sf_4326 <- st_transform(data_sf_orig, 4326)
2892

93+
<<<<<<< HEAD
94+
return (data_sf_4326)
95+
96+
}
97+
98+
server <- function(input, output) {
99+
100+
res <- dbSendQuery(conn, "SELECT * FROM equipment_access LIMIT 10")
101+
f <- dbFetch(res)
102+
103+
leaf <- leaflet() %>%
104+
addTiles()
105+
106+
observeEvent(input$map_background_bounds, {
107+
fetchDB(input)
108+
})
109+
110+
data_sf_4326 <- dbCoordsToLeaflet(f)
111+
112+
=======
113+
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2
29114
for (elt2 in seq_len(nrow(data_sf_4326))){
30115
elt <- data_sf_4326[elt2, ]
31116

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

51136

137+
<<<<<<< HEAD
138+
print("Server update done!")
139+
=======
52140
print("DONE")
141+
>>>>>>> 9cc55e9a43169d65ceef934676ce21c877d692b2
53142

54143

55144
output$map_background <- renderLeaflet({leaf})

0 commit comments

Comments
 (0)