-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
207 lines (137 loc) · 7.06 KB
/
app.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
source("global.R")
#UI#######################################################################################
ui<-shinyUI(dashboardPage(skin=c("red"),
dashboardHeader(title = "Interaktivni portal komasacije u Barandi", titleWidth="100%"),
dashboardSidebar(
sidebarMenu(
fluidPage(
uiOutput("menu"),
uiOutput("menu1"),
uiOutput("menu2")
))
),
dashboardBody(
tabsetPanel(
tabPanel("Mapa",
fluidRow(
column(12, box(height ="auto", width = "auto", solidHeader = FALSE, status = "info",
leafletOutput("m")%>% withSpinner())),
div(dataTableOutput(head("povrsine_st0")))
)),
tabPanel("Statistika",
fluidRow(
column(12, box(height ="auto", width = "auto", solidHeader = FALSE, status = "info",
plotlyOutput("pie"),
plotlyOutput("pie1"))
))
)
)))
)
#SERVER#############################################################
server <- function(input, output, session) {
output$m <- renderLeaflet({
leaflet(options = leafletOptions(zoomControl = FALSE)) %>%
htmlwidgets::onRender("function(el, x){L.control.zoom({ position: 'bottomright' }).addTo(this)}") %>%
addTiles(group = "OSM (default)") %>%
setView(lng = 20.495850, lat=45.086297, zoom=12)%>%
addPolygons(data = staro_stanje,
weight=0.8,
color= "#ff4d4d",
group = "Staro stanje",
label=~broj_parce,
popup=~povrsina_p)%>%
addPolygons(data = novo_stanje,
weight=0.8,
color= "#1a0000",
group = "Novo stanje",
label=~broj_parce)%>%
addMarkers(data = bunari,
group = "Bunari",
label=~broj_parce)%>%
addLayersControl(baseGroups=character(0),
overlayGroups =c("Staro stanje","Novo stanje","Bunari"),
options = layersControlOptions(collapsed=FALSE)
)%>%
addFullscreenControl(position="bottomright",
pseudoFullscreen = TRUE)%>%
addMeasure(position = "bottomleft",
primaryLengthUnit = "meters",
primaryAreaUnit = "sqmeters",
activeColor = "#3D535D",
completedColor = "#7D4479")%>%
addSearchFeatures(
targetGroups = c('Staro stanje','Novo stanje','Bunari'),
options = searchFeaturesOptions(zoom=15, openPopup=TRUE,firstTipSubmit = TRUE))%>%
addScaleBar(position = c("topleft"), options = scaleBarOptions())
}) #Zavrsavam renderLeaflet funkciju
url <- a("Registar cena", href="http://katastar.rgz.gov.rs/RegistarCenaNepokretnosti/")
output$menu <- renderMenu({
sidebarMenu(
h3("Javni registar cena"),
helpText("Na ovoj stranici mozete pronaci"),
helpText("javni registar cena u Vasoj "),
helpText("katastarskoj opstini, izvor:RGZ"),
helpText(
url
)
)
})
output$menu1 <- renderMenu({
sidebarMenu(
h3("Kratka statistika"),
helpText("Broj parcela"),
helpText("u starom stanju:",broj_parcela_st),
helpText("Broj parcela "),
helpText("u novom stanju:",broj_parcela_nv)
)
})
output$menu2 <- renderMenu({
sidebarMenu(
helpText("Broj ucesnika"),
helpText("u starom stanju:",stari)
#helpText("Broj ucesnika "),
#helpText("u novom stanju:",novi)
)
})
output$pie<-renderPlotly({
colors <- c('rgb(211,94,96)', 'rgb(128,133,133)', 'rgb(144,103,167)', 'rgb(171,104,87)', 'rgb(114,147,203)','rgb(211,94,50)','rgb(211,35,100)')
plot_ly(razredi_data,labels = ~c(X1_raz,X2_raz,X3_raz,X4_raz,X5_raz,X6_raz,komb), values = ~c(X1_raz,X2_raz,X3_raz,X4_raz,X5_raz,X6_raz,komb), type = 'pie',height="400",
textposition = 'inside',
textinfo = 'label',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~c('Prvi razred','Drugi razred','Treci razred','Cetvrti razred','Peti razred','Sesti razred','Kombinacija'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1)))%>%
layout(title = 'Broj parcela starog stanja po procembenim razredima',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
output$pie1<-renderPlotly({
colors <- c('rgb(211,94,96)', 'rgb(128,133,133)')
plot_ly(vlasnistvo_data,labels = ~c(br_staro,br_novo), values = ~c(br_staro,br_novo), type = 'pie',height="400",
textposition = 'inside',
textinfo = 'label',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~c('Vlasnika poseduje parcelu u starom stanju','Vlasnika poseduje parcelu u novom stanju'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1)))%>%
layout(title = 'Broj vlasnika koji poseduju samo 1 parcelu',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
output$povrsine_st0 <- renderDT(
povrsine_st, # data
class = "display nowrap compact", # style
rownames = FALSE,
width="auto",
colnames = c('Broj parcele', 'Povrsina parcele'),
caption = 'Tabela u kojoj mozete proveriti povrsinu Vase parcele pre komasacije'
)
session$onSessionEnded(function(){
dbDisconnect(con)
})
} #Zavrsavam SERVER
# Run the application
shinyApp(ui = ui, server = server)