forked from petrpajdla/map_oao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.R
77 lines (75 loc) · 2.52 KB
/
data.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
#' Read metadata on OAO
#'
#' Reads and manipulates metadata on OAO.
#'
#' @param dsn Data.
#'
#' @return A \code{sf} object.
#' @export
#'
#' @examples
oao_meta <- function(dsn, client_url) {
sf::st_read(dsn = dsn) %>%
# sf::st_drop_geometry() %>%
dplyr::mutate(
dplyr::across(dplyr::ends_with(c("from", "to")), \(x) format(x, "%d. %m. %Y")),
# dplyr::across(dplyr::ends_with(c("from", "to")), \(x) stringr::str_replace_all(x, "\\s", " ")),
datum_mk = dplyr::if_else(
is.na(mk_to),
dplyr::if_else(
mk_neomezena,
stringr::str_c("od ", mk_from, " na dobu neurčitou"),
stringr::str_c("od ", mk_from)),
stringr::str_c("od ", mk_from, " do ", mk_to)),
datum_av = dplyr::if_else(
is.na(av_to),
dplyr::if_else(
av_neomezena,
stringr::str_c("od ", av_from, " na dobu neurčitou"),
stringr::str_c("od ", av_from)),
stringr::str_c("od ", av_from, " do ", av_to)),
dplyr::across(c("datum_av", "datum_mk"),
\(x) stringr::str_remove_all(x, "(?<=\\s)0")),
opravneni = dplyr::if_else(
!nazev_zkraceny %in% c("Archeologický ústav Brno", "Archeologický ústav Praha"),
dplyr::if_else(
!stringr::str_detect(nazev_zkraceny, "ÚAPP"),
paste0(dplyr::if_else(
!is.na(datum_mk),
paste0("Platnost oprávnění MK ČR ",
dplyr::if_else(!is.na(mk_id),
paste0("(", mk_id, ") "),
""),
datum_mk, ". "),
""),
"Dohoda s AV ČR ", datum_av, "."),
paste0(mk_id, ". Dohoda s AV ČR ", datum_av, ".")),
"Oprávnění v plném rozsahu dle zákona o státní památkové péči."),
web0 = web,
web = dplyr::if_else(
!is.na(web),
paste0("<a target='_blank' href='", web, "'>",
icon_ext_link, " ", web, "</a>"), ""),
web_app = paste0("https://oao.aiscr.cz/#!/detail?oao=", ico),
mail0 = mail,
mail = dplyr::if_else(
!is.na(mail),
paste0("<a target='_blank' href='mailto:", mail, "'>",
icon_mail, " ", mail, "</a>"), "")) %>%
dplyr::arrange(nazev, .locale = "cs")
}
#' Wrapper around \code{sf::st_read}
#'
#' @param dsn Data.
#'
#' @return A \code{sf} object.
#' @export
#'
#' @examples
oao_sf <- function(dsn) {
sf::st_read(dsn = dsn)
}
oao_filter <- function(data, oao) {
data %>%
dplyr::filter(ico %in% oao)
}