Skip to content

Commit

Permalink
Fix grep issue with Palmas (Las)
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Feb 22, 2022
1 parent be70032 commit ca34f74
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion R/atom_ad_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ catr_atom_get_address_db_to <- function(to,
all <- catr_atom_get_address_db_all()
alldist <- unique(all[, c("territorial_office", "url")])

findto <- grep(to, alldist$territorial_office, ignore.case = TRUE)[1]
# Escape parenthesis
to <- gsub("\\(|\\)", "", to)
allto <- gsub("\\(|\\)", "", alldist$territorial_office)

findto <- grep(to, allto, ignore.case = TRUE)[1]

if (is.na(findto)) {
message("No Territorial office found for ", to)
Expand Down
6 changes: 5 additions & 1 deletion R/atom_bu_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ catr_atom_get_buildings_db_to <- function(to,
all <- catr_atom_get_buildings_db_all()
alldist <- unique(all[, c("territorial_office", "url")])

findto <- grep(to, alldist$territorial_office, ignore.case = TRUE)[1]
# Escape parenthesis
to <- gsub("\\(|\\)", "", to)
allto <- gsub("\\(|\\)", "", alldist$territorial_office)

findto <- grep(to, allto, ignore.case = TRUE)[1]

if (is.na(findto)) {
message("No Territorial office found for ", to)
Expand Down
6 changes: 5 additions & 1 deletion R/atom_cp_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ catr_atom_get_parcels_db_to <- function(to,
all <- catr_atom_get_parcels_db_all()
alldist <- unique(all[, c("territorial_office", "url")])

findto <- grep(to, alldist$territorial_office, ignore.case = TRUE)[1]
# Escape parenthesis
to <- gsub("\\(|\\)", "", to)
allto <- gsub("\\(|\\)", "", alldist$territorial_office)

findto <- grep(to, allto, ignore.case = TRUE)[1]

if (is.na(findto)) {
message("No Territorial office found for ", to)
Expand Down
10 changes: 5 additions & 5 deletions R/utils_atom.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ catr_read_atom <- function(file, top = TRUE, encoding = "UTF-8") {


tbl <- tibble::tibble(
title = title,
url = url,
value = value,
title = trimws(title),
url = trimws(url),
value = trimws(value),
date = date
)

Expand All @@ -46,8 +46,8 @@ catr_read_atom <- function(file, top = TRUE, encoding = "UTF-8") {
date <- as.POSIXct(unlist(feed[1]$entry$updated))

tbl <- tibble::tibble(
title = title,
url = url,
title = trimws(title),
url = trimws(url),
date = date
)

Expand Down

0 comments on commit ca34f74

Please sign in to comment.