Skip to content

Commit f4bc216

Browse files
authored
Merge pull request #168 from aloftdata/167-romania-has-once-in-a-while-a-strange-file-uri
Fix (#167) romania deviating files once in a while
2 parents 1392aea + cdf1c95 commit f4bc216

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Implement reading `vpts` data from a local directory (#135).
44
* Clarify HTTP 429 error for the Netherlands (#165).
5+
* For Romania match deviating file format (thanks to Sorin Burcea, #167).
56

67
# getRad 0.2.4
78

R/get_pvol_ro.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@ get_pvol_ro <- function(radar, time, ..., call = rlang::caller_env()) {
33
urls <- glue::glue(
44
"https://opendata.meteoromania.ro/radar/{toupper(substr(radar,3,5))}/{toupper(substr(radar,3,5))}_{strftime(time,'%Y%m%d%H%M', tz='UTC')}0200{params}.hdf"
55
)
6-
read_pvol_from_url_per_param(urls, param = "all", call = call)
6+
tryCatch(
7+
read_pvol_from_url_per_param(urls, param = "all", call = call),
8+
error = function(cnd) {
9+
urls_updated <- glue::glue(
10+
"https://opendata.meteoromania.ro/radar/{toupper(substr(radar,3,5))}/{toupper(substr(radar,3,5))}_{strftime(time,'%Y%m%d%H%M', tz='UTC')}0300{params}.hdf"
11+
)
12+
if (
13+
rlang::has_name(cnd, "parent") && inherits(cnd$parent, "httr2_http_404")
14+
) {
15+
read_pvol_from_url_per_param(urls_updated, param = "all", call = call)
16+
} else {
17+
return(cnd)
18+
}
19+
}
20+
)
721
}

0 commit comments

Comments
 (0)