Skip to content

Commit

Permalink
fix: tool doesn't breakw hen obis api is down
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpp7 committed Dec 7, 2023
1 parent 7edb44f commit 0cc3580
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/checkdataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -940,12 +940,17 @@ checkdataset = function(Event = NULL, Occurrence = NULL, eMoF = NULL, IPTreport



depth_rep <- check_depth(GoodCords, report=T, depthmargin = 150) # fails when obis api is down
depth_rep <- tryCatch({suppressWarnings(check_depth(GoodCords, report=T, depthmargin = 150))},
error=function(x) { occurrenceID <- c(NA)
data.frame(occurrenceID) }) # fails when obis api is down. Trycatch solves it



OnLand_rep <- check_onland(GoodCords,report=T, buffer = 3000) %>% mutate (field = 'coordinates_error') # fails when obis api is down
OnLand_rep <- tryCatch({suppressWarnings(check_onland(GoodCords,report=T, buffer = 3000) %>% mutate (field = 'coordinates_error'))},
error=function(x) { occurrenceID <- c(NA)
data.frame(occurrenceID) }) # fails when obis api is down. Trycatch solves it

if (ncol(depth_rep) > 1 & ncol(OnLand_rep) > 1){
goodcord_rep <- GoodCords %>% select(eventID) %>%
mutate (row = row_number()) %>%
inner_join(rbind(depth_rep, OnLand_rep),
Expand All @@ -956,7 +961,7 @@ checkdataset = function(Event = NULL, Occurrence = NULL, eMoF = NULL, IPTreport
mutate (row = row_number()) %>%
inner_join(goodcord_rep,
by=c("eventID")) %>%
select (-eventID)
select (-eventID)}


parentdepts <- ev_flat0 %>% fncols (c("decimalLatitude", "decimalLongitude", "minimumDepthInMeters", "maximumDepthInMeters")) %>%
Expand Down

0 comments on commit 0cc3580

Please sign in to comment.